LCOV - code coverage report
Current view: top level - sw/inc - format.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 21 24 87.5 %
Date: 2014-11-03 Functions: 21 23 91.3 %
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             : #ifndef INCLUDED_SW_INC_FORMAT_HXX
      20             : #define INCLUDED_SW_INC_FORMAT_HXX
      21             : 
      22             : #include <tools/solar.h>
      23             : #include "swdllapi.h"
      24             : #include <swatrset.hxx>
      25             : #include <calbck.hxx>
      26             : #include <hintids.hxx>
      27             : #include <boost/shared_ptr.hpp>
      28             : 
      29             : class IDocumentSettingAccess;
      30             : class IDocumentDrawModelAccess;
      31             : class IDocumentLayoutAccess;
      32             : class IDocumentTimerAccess;
      33             : class IDocumentFieldsAccess;
      34             : class IDocumentChartDataProviderAccess;
      35             : class SwDoc;
      36             : class SfxGrabBagItem;
      37             : 
      38             : namespace drawinglayer { namespace attribute {
      39             :     class SdrAllFillAttributesHelper;
      40             :     typedef boost::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
      41             : }}
      42             : 
      43             : /// Base class for various Writer styles.
      44             : class SW_DLLPUBLIC SwFmt : public SwModify
      45             : {
      46             :     OUString aFmtName;
      47             :     SwAttrSet aSet;
      48             : 
      49             :     sal_uInt16 nWhichId;
      50             :     sal_uInt16 nPoolFmtId;        /**< Id for "automatically" created formats.
      51             :                                        (is not hard attribution!!!) */
      52             :     sal_uInt16 nPoolHelpId;       ///< HelpId for this Pool-style.
      53             :     sal_uInt8 nPoolHlpFileId;     ///< FilePos to Doc to these style helps.
      54             :     bool   bWritten : 1;      ///< TRUE: already written.
      55             :     bool   bAutoFmt : 1;      /**< FALSE: it is a template.
      56             :                                        default is true! */
      57             :     bool   bFmtInDTOR : 1;    /**< TRUE: Format becomes deleted. In order to be able
      58             :                                        to recognize this in FmtChg-message!! */
      59             :     bool   bAutoUpdateFmt : 1;/**< TRUE: Set attributes of a whole paragraph
      60             :                                        at format (UI-side!). */
      61             :     bool bHidden : 1;
      62             :     boost::shared_ptr<SfxGrabBagItem> m_pGrabBagItem; ///< Style InteropGrabBag.
      63             : 
      64             : protected:
      65             :     SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
      66             :             const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
      67             :     SwFmt( SwAttrPool& rPool, const OUString &rFmtNm, const sal_uInt16* pWhichRanges,
      68             :             SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
      69             :     SwFmt( const SwFmt& rFmt );
      70             :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) SAL_OVERRIDE;
      71             : 
      72             : public:
      73             :     TYPEINFO_OVERRIDE();     ///< Already in base class Client.
      74             : 
      75             :     virtual ~SwFmt();
      76             :     SwFmt &operator=(const SwFmt&);
      77             : 
      78             :     /// for Querying of Writer-functions.
      79     4558041 :     sal_uInt16 Which() const { return nWhichId; }
      80             : 
      81             :     /// Query format information.
      82             :     virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
      83             : 
      84             :     /// Copy attributes even among documents.
      85             :     void CopyAttrs( const SwFmt&, bool bReplace=true );
      86             : 
      87             :     /// Delete all attributes that are not in rFmt.
      88             :     void DelDiffs( const SfxItemSet& rSet );
      89         510 :     void DelDiffs( const SwFmt& rFmt ) { DelDiffs( rFmt.GetAttrSet() ); }
      90             : 
      91             :     /// 0 is Default.
      92             :     bool SetDerivedFrom(SwFmt *pDerivedFrom = 0);
      93             : 
      94             :     /// If bInParents is FALSE, search only in this format for attribute.
      95             :     //UUUUinline
      96             :     const SfxPoolItem& GetFmtAttr( sal_uInt16 nWhich,
      97             :                                    bool bInParents = true ) const;
      98             :     //UUUUinline
      99             :     SfxItemState GetItemState( sal_uInt16 nWhich, bool bSrchInParent = true,
     100             :                                     const SfxPoolItem **ppItem = 0 ) const;
     101             :     SfxItemState GetBackgroundState(SvxBrushItem &rItem,
     102             :                                     bool bSrchInParent = true) const;
     103             :     virtual bool SetFmtAttr( const SfxPoolItem& rAttr );
     104             :     virtual bool SetFmtAttr( const SfxItemSet& rSet );
     105             :     virtual bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
     106             : 
     107             :     /** Takes all hints from Delta-Array,
     108             :         @return count of deleted hints. */
     109             :     virtual sal_uInt16 ResetAllFmtAttr();
     110             : 
     111     4011997 :     inline SwFmt* DerivedFrom() const { return (SwFmt*)GetRegisteredIn(); }
     112     1080185 :     inline bool IsDefault() const { return DerivedFrom() == 0; }
     113             : 
     114    30425586 :     inline OUString GetName() const   { return aFmtName; }
     115             :     void SetName( const OUString& rNewName, bool bBroadcast=false );
     116             :     inline void SetName( const sal_Char* pNewName,
     117             :                          bool bBroadcast=false);
     118             : 
     119             :     /// For querying the attribute array.
     120     8488368 :     inline const SwAttrSet& GetAttrSet() const { return aSet; }
     121             : 
     122             :     /** Das Doc wird jetzt am SwAttrPool gesetzt. Dadurch hat man es immer
     123             :        im Zugriff. */
     124     2264188 :     const SwDoc *GetDoc() const         { return aSet.GetDoc(); }
     125     3678567 :           SwDoc *GetDoc()               { return aSet.GetDoc(); }
     126             : 
     127             :     /// Provides access to the document settings interface.
     128             :     const IDocumentSettingAccess* getIDocumentSettingAccess() const;
     129             : 
     130             :     /// Provides access to the document draw model interface.
     131             :     const IDocumentDrawModelAccess* getIDocumentDrawModelAccess() const;
     132             :           IDocumentDrawModelAccess* getIDocumentDrawModelAccess();
     133             : 
     134             :     /// Provides access to the document layout interface.
     135             :     const IDocumentLayoutAccess* getIDocumentLayoutAccess() const;
     136             :           IDocumentLayoutAccess* getIDocumentLayoutAccess();
     137             : 
     138             :      /// Provides access to the document idle timer interface.
     139             :      IDocumentTimerAccess* getIDocumentTimerAccess();
     140             : 
     141             :      /// Provides access to the document idle timer interface.
     142             :     IDocumentFieldsAccess* getIDocumentFieldsAccess();
     143             : 
     144             :      /// Gives access to the chart data-provider.
     145             :     IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
     146             : 
     147             :     /// Get and set Pool style IDs.
     148     5875052 :     sal_uInt16 GetPoolFmtId() const { return nPoolFmtId; }
     149      339338 :     void SetPoolFmtId( sal_uInt16 nId ) { nPoolFmtId = nId; }
     150             : 
     151             :     /// Get and set Help-IDs for document templates.
     152      917096 :     sal_uInt16 GetPoolHelpId() const { return nPoolHelpId; }
     153       92738 :     void SetPoolHelpId( sal_uInt16 nId ) { nPoolHelpId = nId; }
     154      905988 :     sal_uInt8 GetPoolHlpFileId() const { return nPoolHlpFileId; }
     155       92738 :     void SetPoolHlpFileId( sal_uInt8 nId ) { nPoolHlpFileId = nId; }
     156             : 
     157             :     /// Get attribute-description. Returns passed string.
     158           0 :     void GetPresentation( SfxItemPresentation ePres,
     159             :         SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric, OUString &rText ) const
     160           0 :         { aSet.GetPresentation( ePres, eCoreMetric, ePresMetric, rText ); }
     161             : 
     162             :     /// Format-ID for reading/writing:
     163           0 :     void   ResetWritten()    { bWritten = false; }
     164             : 
     165             :     /// Query / set AutoFmt-flag.
     166        8745 :     bool IsAuto() const                 { return bAutoFmt; }
     167      149398 :     void SetAuto( bool bNew = false )   { bAutoFmt = bNew; }
     168             : 
     169      132059 :     bool IsHidden() const                 { return bHidden; }
     170        4866 :     void SetHidden( bool bValue = false ) { bHidden = bValue; }
     171             : 
     172             :     void GetGrabBagItem(com::sun::star::uno::Any& rVal) const;
     173             :     void SetGrabBagItem(const com::sun::star::uno::Any& rVal);
     174             : 
     175             :     /// Query / set bAutoUpdateFmt-flag.
     176      296396 :     bool IsAutoUpdateFmt() const                { return bAutoUpdateFmt; }
     177      201170 :     void SetAutoUpdateFmt( bool bNew = true )   { bAutoUpdateFmt = bNew; }
     178             : 
     179        1671 :     bool IsFmtInDTOR() const { return bFmtInDTOR; }
     180             : 
     181             :     /** GetMethods: Bool indicates whether to search only in Set (FALSE)
     182             :      or also in Parents.
     183             :      If nothing is found the defaulted attribute is returned. */
     184             : 
     185             :     /// Character-attributes - implemented in charatr.hxx
     186             :     inline const SvxPostureItem      &GetPosture( bool = true ) const;
     187             :     inline const SvxWeightItem       &GetWeight( bool = true ) const;
     188             :     inline const SvxShadowedItem     &GetShadowed( bool = true ) const;
     189             :     inline const SvxAutoKernItem     &GetAutoKern( bool = true ) const;
     190             :     inline const SvxWordLineModeItem &GetWordLineMode( bool = true ) const;
     191             :     inline const SvxContourItem      &GetContour( bool = true ) const;
     192             :     inline const SvxKerningItem      &GetKerning( bool = true ) const;
     193             :     inline const SvxUnderlineItem    &GetUnderline( bool = true ) const;
     194             :     inline const SvxOverlineItem     &GetOverline( bool = true ) const;
     195             :     inline const SvxCrossedOutItem   &GetCrossedOut( bool = true ) const;
     196             :     inline const SvxFontHeightItem   &GetSize( bool = true ) const;
     197             :     inline const SvxPropSizeItem     &GetPropSize( bool = true ) const;
     198             :     inline const SvxFontItem         &GetFont( bool = true ) const;
     199             :     inline const SvxColorItem        &GetColor( bool = true ) const;
     200             :     inline const SvxCharSetColorItem &GetCharSetColor( bool = true ) const;
     201             :     inline const SvxLanguageItem     &GetLanguage( bool = true ) const;
     202             :     inline const SvxEscapementItem   &GetEscapement( bool = true ) const;
     203             :     inline const SvxCaseMapItem      &GetCaseMap( bool = true ) const;
     204             :     inline const SvxNoHyphenItem     &GetNoHyphenHere( bool = true ) const;
     205             :     inline const SvxBlinkItem        &GetBlink( bool = true ) const;
     206             :     inline const SvxBrushItem        &GetChrBackground( bool = true ) const;
     207             :     inline const SvxBrushItem        &GetChrHighlight( bool = true ) const;
     208             : 
     209             :     inline const SvxFontItem         &GetCJKFont( bool = true ) const;
     210             :     inline const SvxFontHeightItem   &GetCJKSize( bool = true ) const;
     211             :     inline const SvxLanguageItem     &GetCJKLanguage( bool = true ) const;
     212             :     inline const SvxPostureItem      &GetCJKPosture( bool = true ) const;
     213             :     inline const SvxWeightItem       &GetCJKWeight( bool = true ) const;
     214             :     inline const SvxFontItem         &GetCTLFont( bool = true ) const;
     215             :     inline const SvxFontHeightItem   &GetCTLSize( bool = true ) const;
     216             :     inline const SvxLanguageItem     &GetCTLLanguage( bool = true ) const;
     217             :     inline const SvxPostureItem      &GetCTLPosture( bool = true ) const;
     218             :     inline const SvxWeightItem       &GetCTLWeight( bool = true ) const;
     219             :     inline const SfxBoolItem           &GetWritingDirection( bool = true ) const;
     220             :     inline const SvxEmphasisMarkItem &GetEmphasisMark( bool = true ) const;
     221             :     inline const SvxTwoLinesItem   &Get2Lines( bool = true ) const;
     222             :     inline const SvxCharScaleWidthItem &GetCharScaleW( bool = true ) const;
     223             :     inline const SvxCharRotateItem     &GetCharRotate( bool = true ) const;
     224             :     inline const SvxCharReliefItem     &GetCharRelief( bool = true ) const;
     225             :     inline const SvxCharHiddenItem   &GetCharHidden( bool = true ) const;
     226             :     inline const SvxBoxItem   &GetCharBorder( bool = true ) const;
     227             :     inline const SvxShadowItem   &GetCharShadow( bool = true ) const;
     228             : 
     229             :     /// Frame-attributes - implemented in frmatr.hxx.
     230             :     inline const SwFmtFillOrder           &GetFillOrder( bool = true ) const;
     231             :     inline const SwFmtFrmSize             &GetFrmSize( bool = true ) const;
     232             :     inline const SwFmtHeader          &GetHeader( bool = true ) const;
     233             :     inline const SwFmtFooter          &GetFooter( bool = true ) const;
     234             :     inline const SwFmtSurround            &GetSurround( bool = true ) const;
     235             :     inline const SwFmtHoriOrient      &GetHoriOrient( bool = true ) const;
     236             :     inline const SwFmtAnchor          &GetAnchor( bool = true ) const;
     237             :     inline const SwFmtCol                 &GetCol( bool = true ) const;
     238             :     inline const SvxPaperBinItem      &GetPaperBin( bool = true ) const;
     239             :     inline const SvxLRSpaceItem           &GetLRSpace( bool = true ) const;
     240             :     inline const SvxULSpaceItem           &GetULSpace( bool = true ) const;
     241             :     inline const SwFmtCntnt           &GetCntnt( bool = true ) const;
     242             :     inline const SvxPrintItem             &GetPrint( bool = true ) const;
     243             :     inline const SvxOpaqueItem            &GetOpaque( bool = true ) const;
     244             :     inline const SvxProtectItem           &GetProtect( bool = true ) const;
     245             :     inline const SwFmtVertOrient      &GetVertOrient( bool = true ) const;
     246             :     inline const SvxBoxItem               &GetBox( bool = true ) const;
     247             :     inline const SvxFmtKeepItem         &GetKeep( bool = true ) const;
     248             : 
     249             :     //UUUU Create SvxBrushItem for Background fill (partially for backwards compatibility)
     250             :     SvxBrushItem makeBackgroundBrushItem( bool = true ) const;
     251             : 
     252             :     inline const SvxShadowItem            &GetShadow( bool = true ) const;
     253             :     inline const SwFmtPageDesc            &GetPageDesc( bool = true ) const;
     254             :     inline const SvxFmtBreakItem      &GetBreak( bool = true ) const;
     255             :     inline const SvxMacroItem             &GetMacro( bool = true ) const;
     256             :     inline const SwFmtURL             &GetURL( bool = true ) const;
     257             :     inline const SwFmtEditInReadonly  &GetEditInReadonly( bool = true ) const;
     258             :     inline const SwFmtLayoutSplit     &GetLayoutSplit( bool = true ) const;
     259             :     inline const SwFmtRowSplit          &GetRowSplit( bool = true ) const;
     260             :     inline const SwFmtChain               &GetChain( bool = true ) const;
     261             :     inline const SwFmtLineNumber      &GetLineNumber( bool = true ) const;
     262             :     inline const SwFmtFtnAtTxtEnd     &GetFtnAtTxtEnd( bool = true ) const;
     263             :     inline const SwFmtEndAtTxtEnd     &GetEndAtTxtEnd( bool = true ) const;
     264             :     inline const SwFmtNoBalancedColumns &GetBalancedColumns( bool = true ) const;
     265             :     inline const SvxFrameDirectionItem    &GetFrmDir( bool = true ) const;
     266             :     inline const SwTextGridItem         &GetTextGrid( bool = true ) const;
     267             :     inline const SwHeaderAndFooterEatSpacingItem &GetHeaderAndFooterEatSpacing( bool = true ) const;
     268             :     // #i18732#
     269             :     inline const SwFmtFollowTextFlow    &GetFollowTextFlow(bool = true) const;
     270             :     // #i28701#
     271             :     inline const SwFmtWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(bool = true) const;
     272             :     inline const SdrTextVertAdjustItem& GetTextVertAdjust(bool = true) const;
     273             : 
     274             :     /// Graphics-attributes - implemented in grfatr.hxx
     275             :     inline const SwMirrorGrf          &GetMirrorGrf( bool = true ) const;
     276             :     inline const SwCropGrf            &GetCropGrf( bool = true ) const;
     277             :     inline const SwRotationGrf            &GetRotationGrf(bool = true ) const;
     278             :     inline const SwLuminanceGrf       &GetLuminanceGrf(bool = true ) const;
     279             :     inline const SwContrastGrf            &GetContrastGrf(bool = true ) const;
     280             :     inline const SwChannelRGrf            &GetChannelRGrf(bool = true ) const;
     281             :     inline const SwChannelGGrf            &GetChannelGGrf(bool = true ) const;
     282             :     inline const SwChannelBGrf            &GetChannelBGrf(bool = true ) const;
     283             :     inline const SwGammaGrf           &GetGammaGrf(bool = true ) const;
     284             :     inline const SwInvertGrf          &GetInvertGrf(bool = true ) const;
     285             :     inline const SwTransparencyGrf        &GetTransparencyGrf(bool = true ) const;
     286             :     inline const SwDrawModeGrf            &GetDrawModeGrf(bool = true ) const;
     287             : 
     288             :     /// Paragraph-attributes - implemented in paratr.hxx.
     289             :     inline const SvxLineSpacingItem       &GetLineSpacing( bool = true ) const;
     290             :     inline const SvxAdjustItem            &GetAdjust( bool = true ) const;
     291             :     inline const SvxFmtSplitItem      &GetSplit( bool = true ) const;
     292             :     inline const SwRegisterItem           &GetRegister( bool = true ) const;
     293             :     inline const SwNumRuleItem            &GetNumRule( bool = true ) const;
     294             :     inline const SvxWidowsItem            &GetWidows( bool = true ) const;
     295             :     inline const SvxOrphansItem           &GetOrphans( bool = true ) const;
     296             :     inline const SvxTabStopItem           &GetTabStops( bool = true ) const;
     297             :     inline const SvxHyphenZoneItem        &GetHyphenZone( bool = true ) const;
     298             :     inline const SwFmtDrop                &GetDrop( bool = true ) const;
     299             :     inline const SvxScriptSpaceItem       &GetScriptSpace(bool = true) const;
     300             :     inline const SvxHangingPunctuationItem &GetHangingPunctuation(bool = true) const;
     301             :     inline const SvxForbiddenRuleItem     &GetForbiddenRule(bool = true) const;
     302             :     inline const SvxParaVertAlignItem &GetParaVertAlign(bool = true) const;
     303             :     inline const SvxParaGridItem        &GetParaGrid(bool = true) const;
     304             :     inline const SwParaConnectBorderItem &GetParaConnectBorder(bool = true ) const;
     305             : 
     306             :     /// TableBox attributes - implemented in cellatr.hxx.
     307             :     inline  const SwTblBoxNumFormat     &GetTblBoxNumFmt( bool = true ) const;
     308             :     inline  const SwTblBoxFormula       &GetTblBoxFormula( bool = true ) const;
     309             :     inline  const SwTblBoxValue         &GetTblBoxValue( bool = true ) const;
     310             : 
     311             :     /** SwFmt::IsBackgroundTransparent
     312             : 
     313             :         Virtual method to determine, if background of format is transparent.
     314             :         Default implementation returns false. Thus, subclasses have to overload
     315             :         method, if the specific subclass can have a transparent background.
     316             : 
     317             :         @author OD
     318             : 
     319             :         @return false, default implementation
     320             :     */
     321             :     virtual bool IsBackgroundTransparent() const;
     322             : 
     323             :     /** SwFmt::IsShadowTransparent
     324             : 
     325             :         Virtual method to determine, if shadow of format is transparent.
     326             :         Default implementation returns false. Thus, subclasses have to overload
     327             :         method, if the specific subclass can have a transparent shadow.
     328             : 
     329             :         @author OD
     330             : 
     331             :         @return false, default implementation
     332             :     */
     333             :     virtual bool IsShadowTransparent() const;
     334             : 
     335             :     //UUUU Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
     336             :     virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;
     337             :     virtual bool supportsFullDrawingLayerFillAttributeSet() const;
     338             : };
     339             : 
     340             : inline void SwFmt::SetName( const sal_Char* pNewName,
     341             :                              bool bBroadcast )
     342             : {
     343             :     SetName(OUString::createFromAscii(pNewName), bBroadcast);
     344             : }
     345             : 
     346             : #endif // INCLUDED_SW_INC_FORMAT_HXX
     347             : 
     348             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10