LCOV - code coverage report
Current view: top level - libreoffice/sw/inc - format.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 28 85.7 %
Date: 2012-12-27 Functions: 22 25 88.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef _FORMAT_HXX
      20             : #define _FORMAT_HXX
      21             : 
      22             : #include <tools/solar.h>
      23             : #include "swdllapi.h"
      24             : #include <swatrset.hxx>     ///< For SfxItemPool/-Set, Attr forward decl.
      25             : #include <calbck.hxx>       ///< For SwModify.
      26             : #include <hintids.hxx>
      27             : 
      28             : class IDocumentSettingAccess;
      29             : class IDocumentDrawModelAccess;
      30             : class IDocumentLayoutAccess;
      31             : class IDocumentTimerAccess;
      32             : class IDocumentFieldsAccess;
      33             : class IDocumentChartDataProviderAccess;
      34             : class SwDoc;
      35             : 
      36             : /// Base class for various Writer styles.
      37             : class SW_DLLPUBLIC SwFmt : public SwModify
      38             : {
      39             :     String aFmtName;
      40             :     SwAttrSet aSet;
      41             : 
      42             :     sal_uInt16 nWhichId;
      43             :     sal_uInt16 nFmtId;            ///< Format-ID for reading / writing.
      44             :     sal_uInt16 nPoolFmtId;        /**< Id for "automatically" created formats.
      45             :                                        (is not hard attribution!!!) */
      46             :     sal_uInt16 nPoolHelpId;       ///< HelpId for this Pool-style.
      47             :     sal_uInt8 nPoolHlpFileId;     ///< FilePos to Doc to these style helps.
      48             :     sal_Bool   bWritten : 1;      ///< TRUE: already written.
      49             :     bool   bAutoFmt : 1;      /**< FALSE: it is a template.
      50             :                                        default is true! */
      51             :     sal_Bool   bFmtInDTOR : 1;    /**< TRUE: Format becomes deleted. In order to be able
      52             :                                        to recognize this in FmtChg-message!! */
      53             :     sal_Bool   bAutoUpdateFmt : 1;/**< TRUE: Set attributes of a whole paragraph
      54             :                                        at format (UI-side!). */
      55             :     bool bHidden : 1;
      56             : 
      57             : protected:
      58             :     SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
      59             :             const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
      60             :     SwFmt( SwAttrPool& rPool, const String &rFmtNm, const sal_uInt16* pWhichRanges,
      61             :             SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
      62             :     SwFmt( const SwFmt& rFmt );
      63             :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue );
      64             : 
      65             : public:
      66             :     TYPEINFO();     ///< Already in base class Client.
      67             : 
      68             :     virtual ~SwFmt();
      69             :     SwFmt &operator=(const SwFmt&);
      70             : 
      71             :     /// for Querying of Writer-functions.
      72       69511 :     sal_uInt16 Which() const { return nWhichId; }
      73             : 
      74             : 
      75             :     /// Query format information.
      76             :     virtual bool GetInfo( SfxPoolItem& ) const;
      77             : 
      78             :     /// Copy attributes even among documents.
      79             :     void CopyAttrs( const SwFmt&, sal_Bool bReplace=sal_True );
      80             : 
      81             :     /// Delete all attributes that are not in rFmt.
      82             :     void DelDiffs( const SfxItemSet& rSet );
      83           0 :     void DelDiffs( const SwFmt& rFmt ) { DelDiffs( rFmt.GetAttrSet() ); }
      84             : 
      85             :     /// 0 is Default.
      86             :     sal_Bool SetDerivedFrom(SwFmt *pDerivedFrom = 0);
      87             : 
      88             :     /// If bInParents is FALSE, search only in this format for attribute.
      89             :     inline const SfxPoolItem& GetFmtAttr( sal_uInt16 nWhich,
      90             :                                           sal_Bool bInParents = sal_True ) const;
      91             :     inline SfxItemState GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True,
      92             :                                     const SfxPoolItem **ppItem = 0 ) const;
      93             :     virtual bool SetFmtAttr( const SfxPoolItem& rAttr );
      94             :     virtual bool SetFmtAttr( const SfxItemSet& rSet );
      95             :     virtual bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
      96             : 
      97             :     /** Takes all hints from Delta-Array,
      98             :         @return count of deleted hints. */
      99             :     virtual sal_uInt16 ResetAllFmtAttr();
     100             : 
     101       50572 :     inline SwFmt* DerivedFrom() const { return (SwFmt*)GetRegisteredIn(); }
     102       13598 :     inline sal_Bool IsDefault() const { return DerivedFrom() == 0; }
     103             : 
     104      404918 :     inline const String& GetName() const        { return aFmtName; }
     105             :     void SetName( const String& rNewName, sal_Bool bBroadcast=sal_False );
     106             :     inline void SetName( const sal_Char* pNewName,
     107             :                          sal_Bool bBroadcast=sal_False);
     108             : 
     109             :     /// For querying the attribute array.
     110      145832 :     inline const SwAttrSet& GetAttrSet() const { return aSet; }
     111             : 
     112             :     /** Das Doc wird jetzt am SwAttrPool gesetzt. Dadurch hat man es immer
     113             :        im Zugriff. */
     114       17241 :     const SwDoc *GetDoc() const         { return aSet.GetDoc(); }
     115       43845 :           SwDoc *GetDoc()               { return aSet.GetDoc(); }
     116             : 
     117             :     /// Provides access to the document settings interface.
     118             :     const IDocumentSettingAccess* getIDocumentSettingAccess() const;
     119             : 
     120             :     /// Provides access to the document draw model interface.
     121             :     const IDocumentDrawModelAccess* getIDocumentDrawModelAccess() const;
     122             :           IDocumentDrawModelAccess* getIDocumentDrawModelAccess();
     123             : 
     124             :     /// Provides access to the document layout interface.
     125             :     const IDocumentLayoutAccess* getIDocumentLayoutAccess() const;
     126             :           IDocumentLayoutAccess* getIDocumentLayoutAccess();
     127             : 
     128             :      /// Provides access to the document idle timer interface.
     129             :      IDocumentTimerAccess* getIDocumentTimerAccess();
     130             : 
     131             :      /// Provides access to the document idle timer interface.
     132             :     IDocumentFieldsAccess* getIDocumentFieldsAccess();
     133             : 
     134             :      /// Gives access to the chart data-provider.
     135             :     IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
     136             : 
     137             :     /// Get and set Pool style IDs.
     138      320912 :     sal_uInt16 GetPoolFmtId() const { return nPoolFmtId; }
     139        7159 :     void SetPoolFmtId( sal_uInt16 nId ) { nPoolFmtId = nId; }
     140             : 
     141             :     /// Get and set Help-IDs for document templates.
     142       15769 :     sal_uInt16 GetPoolHelpId() const { return nPoolHelpId; }
     143        3020 :     void SetPoolHelpId( sal_uInt16 nId ) { nPoolHelpId = nId; }
     144       15358 :     sal_uInt8 GetPoolHlpFileId() const { return nPoolHlpFileId; }
     145        3020 :     void SetPoolHlpFileId( sal_uInt8 nId ) { nPoolHlpFileId = nId; }
     146             : 
     147             :     /// Get attribute-description. Returns passed string.
     148           0 :     void GetPresentation( SfxItemPresentation ePres,
     149             :         SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric, String &rText ) const
     150           0 :         { aSet.GetPresentation( ePres, eCoreMetric, ePresMetric, rText ); }
     151             : 
     152             :     /// Format-ID for reading/writing:
     153           0 :     void   ResetWritten()    { bWritten = sal_False; }
     154             : 
     155             :     /// Query / set AutoFmt-flag.
     156           9 :     bool IsAuto() const                 { return bAutoFmt; }
     157        4511 :     void SetAuto( bool bNew = false )   { bAutoFmt = bNew; }
     158             : 
     159        1323 :     bool IsHidden() const                 { return bHidden; }
     160         183 :     void SetHidden( bool bValue = false ) { bHidden = bValue; }
     161             : 
     162             :     /// Query / set bAutoUpdateFmt-flag.
     163        3037 :     sal_Bool IsAutoUpdateFmt() const                { return bAutoUpdateFmt; }
     164        1745 :     void SetAutoUpdateFmt( sal_Bool bNew = sal_True )   { bAutoUpdateFmt = bNew; }
     165             : 
     166          22 :     sal_Bool IsFmtInDTOR() const { return bFmtInDTOR; }
     167             : 
     168             :     /** GetMethods: Bool indicates whether to search only in Set (FALSE)
     169             :      or also in Parents.
     170             :      If nothing is found the defaulted attribute is returned. */
     171             : 
     172             :     /// Character-attributes - implemented in charatr.hxx
     173             :     inline const SvxPostureItem      &GetPosture( sal_Bool = sal_True ) const;
     174             :     inline const SvxWeightItem       &GetWeight( sal_Bool = sal_True ) const;
     175             :     inline const SvxShadowedItem     &GetShadowed( sal_Bool = sal_True ) const;
     176             :     inline const SvxAutoKernItem     &GetAutoKern( sal_Bool = sal_True ) const;
     177             :     inline const SvxWordLineModeItem &GetWordLineMode( sal_Bool = sal_True ) const;
     178             :     inline const SvxContourItem      &GetContour( sal_Bool = sal_True ) const;
     179             :     inline const SvxKerningItem      &GetKerning( sal_Bool = sal_True ) const;
     180             :     inline const SvxUnderlineItem    &GetUnderline( sal_Bool = sal_True ) const;
     181             :     inline const SvxOverlineItem     &GetOverline( sal_Bool = sal_True ) const;
     182             :     inline const SvxCrossedOutItem   &GetCrossedOut( sal_Bool = sal_True ) const;
     183             :     inline const SvxFontHeightItem   &GetSize( sal_Bool = sal_True ) const;
     184             :     inline const SvxPropSizeItem     &GetPropSize( sal_Bool = sal_True ) const;
     185             :     inline const SvxFontItem         &GetFont( sal_Bool = sal_True ) const;
     186             :     inline const SvxColorItem        &GetColor( sal_Bool = sal_True ) const;
     187             :     inline const SvxCharSetColorItem &GetCharSetColor( sal_Bool = sal_True ) const;
     188             :     inline const SvxLanguageItem     &GetLanguage( sal_Bool = sal_True ) const;
     189             :     inline const SvxEscapementItem   &GetEscapement( sal_Bool = sal_True ) const;
     190             :     inline const SvxCaseMapItem      &GetCaseMap( sal_Bool = sal_True ) const;
     191             :     inline const SvxNoHyphenItem     &GetNoHyphenHere( sal_Bool = sal_True ) const;
     192             :     inline const SvxBlinkItem        &GetBlink( sal_Bool = sal_True ) const;
     193             :     inline const SvxBrushItem        &GetChrBackground( sal_Bool = sal_True ) const;
     194             : 
     195             :     inline const SvxFontItem         &GetCJKFont( sal_Bool = sal_True ) const;
     196             :     inline const SvxFontHeightItem   &GetCJKSize( sal_Bool = sal_True ) const;
     197             :     inline const SvxLanguageItem     &GetCJKLanguage( sal_Bool = sal_True ) const;
     198             :     inline const SvxPostureItem      &GetCJKPosture( sal_Bool = sal_True ) const;
     199             :     inline const SvxWeightItem       &GetCJKWeight( sal_Bool = sal_True ) const;
     200             :     inline const SvxFontItem         &GetCTLFont( sal_Bool = sal_True ) const;
     201             :     inline const SvxFontHeightItem   &GetCTLSize( sal_Bool = sal_True ) const;
     202             :     inline const SvxLanguageItem     &GetCTLLanguage( sal_Bool = sal_True ) const;
     203             :     inline const SvxPostureItem      &GetCTLPosture( sal_Bool = sal_True ) const;
     204             :     inline const SvxWeightItem       &GetCTLWeight( sal_Bool = sal_True ) const;
     205             :     inline const SfxBoolItem           &GetWritingDirection( sal_Bool = sal_True ) const;
     206             :     inline const SvxEmphasisMarkItem &GetEmphasisMark( sal_Bool = sal_True ) const;
     207             :     inline const SvxTwoLinesItem   &Get2Lines( sal_Bool = sal_True ) const;
     208             :     inline const SvxCharScaleWidthItem &GetCharScaleW( sal_Bool = sal_True ) const;
     209             :     inline const SvxCharRotateItem     &GetCharRotate( sal_Bool = sal_True ) const;
     210             :     inline const SvxCharReliefItem     &GetCharRelief( sal_Bool = sal_True ) const;
     211             :     inline const SvxCharHiddenItem   &GetCharHidden( sal_Bool = sal_True ) const;
     212             : 
     213             :     /// Frame-attributes - implemented in frmatr.hxx.
     214             :     inline const SwFmtFillOrder           &GetFillOrder( sal_Bool = sal_True ) const;
     215             :     inline const SwFmtFrmSize             &GetFrmSize( sal_Bool = sal_True ) const;
     216             :     inline const SwFmtHeader          &GetHeader( sal_Bool = sal_True ) const;
     217             :     inline const SwFmtFooter          &GetFooter( sal_Bool = sal_True ) const;
     218             :     inline const SwFmtSurround            &GetSurround( sal_Bool = sal_True ) const;
     219             :     inline const SwFmtHoriOrient      &GetHoriOrient( sal_Bool = sal_True ) const;
     220             :     inline const SwFmtAnchor          &GetAnchor( sal_Bool = sal_True ) const;
     221             :     inline const SwFmtCol                 &GetCol( sal_Bool = sal_True ) const;
     222             :     inline const SvxPaperBinItem      &GetPaperBin( sal_Bool = sal_True ) const;
     223             :     inline const SvxLRSpaceItem           &GetLRSpace( sal_Bool = sal_True ) const;
     224             :     inline const SvxULSpaceItem           &GetULSpace( sal_Bool = sal_True ) const;
     225             :     inline const SwFmtCntnt           &GetCntnt( sal_Bool = sal_True ) const;
     226             :     inline const SvxPrintItem             &GetPrint( sal_Bool = sal_True ) const;
     227             :     inline const SvxOpaqueItem            &GetOpaque( sal_Bool = sal_True ) const;
     228             :     inline const SvxProtectItem           &GetProtect( sal_Bool = sal_True ) const;
     229             :     inline const SwFmtVertOrient      &GetVertOrient( sal_Bool = sal_True ) const;
     230             :     inline const SvxBoxItem               &GetBox( sal_Bool = sal_True ) const;
     231             :     inline const SvxFmtKeepItem         &GetKeep( sal_Bool = sal_True ) const;
     232             :     inline const SvxBrushItem           &GetBackground( sal_Bool = sal_True ) const;
     233             :     inline const SvxShadowItem            &GetShadow( sal_Bool = sal_True ) const;
     234             :     inline const SwFmtPageDesc            &GetPageDesc( sal_Bool = sal_True ) const;
     235             :     inline const SvxFmtBreakItem      &GetBreak( sal_Bool = sal_True ) const;
     236             :     inline const SvxMacroItem             &GetMacro( sal_Bool = sal_True ) const;
     237             :     inline const SwFmtURL             &GetURL( sal_Bool = sal_True ) const;
     238             :     inline const SwFmtEditInReadonly  &GetEditInReadonly( sal_Bool = sal_True ) const;
     239             :     inline const SwFmtLayoutSplit     &GetLayoutSplit( sal_Bool = sal_True ) const;
     240             :     inline const SwFmtRowSplit          &GetRowSplit( sal_Bool = sal_True ) const;
     241             :     inline const SwFmtChain               &GetChain( sal_Bool = sal_True ) const;
     242             :     inline const SwFmtLineNumber      &GetLineNumber( sal_Bool = sal_True ) const;
     243             :     inline const SwFmtFtnAtTxtEnd     &GetFtnAtTxtEnd( sal_Bool = sal_True ) const;
     244             :     inline const SwFmtEndAtTxtEnd     &GetEndAtTxtEnd( sal_Bool = sal_True ) const;
     245             :     inline const SwFmtNoBalancedColumns &GetBalancedColumns( sal_Bool = sal_True ) const;
     246             :     inline const SvxFrameDirectionItem    &GetFrmDir( sal_Bool = sal_True ) const;
     247             :     inline const SwTextGridItem         &GetTextGrid( sal_Bool = sal_True ) const;
     248             :     inline const SwHeaderAndFooterEatSpacingItem &GetHeaderAndFooterEatSpacing( sal_Bool = sal_True ) const;
     249             :     // #i18732#
     250             :     inline const SwFmtFollowTextFlow    &GetFollowTextFlow(sal_Bool = sal_True) const;
     251             :     // #i28701#
     252             :     inline const SwFmtWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(sal_Bool = sal_True) const;
     253             : 
     254             :     /// Graphics-attributes - implemented in grfatr.hxx
     255             :     inline const SwMirrorGrf          &GetMirrorGrf( sal_Bool = sal_True ) const;
     256             :     inline const SwCropGrf            &GetCropGrf( sal_Bool = sal_True ) const;
     257             :     inline const SwRotationGrf            &GetRotationGrf(sal_Bool = sal_True ) const;
     258             :     inline const SwLuminanceGrf       &GetLuminanceGrf(sal_Bool = sal_True ) const;
     259             :     inline const SwContrastGrf            &GetContrastGrf(sal_Bool = sal_True ) const;
     260             :     inline const SwChannelRGrf            &GetChannelRGrf(sal_Bool = sal_True ) const;
     261             :     inline const SwChannelGGrf            &GetChannelGGrf(sal_Bool = sal_True ) const;
     262             :     inline const SwChannelBGrf            &GetChannelBGrf(sal_Bool = sal_True ) const;
     263             :     inline const SwGammaGrf           &GetGammaGrf(sal_Bool = sal_True ) const;
     264             :     inline const SwInvertGrf          &GetInvertGrf(sal_Bool = sal_True ) const;
     265             :     inline const SwTransparencyGrf        &GetTransparencyGrf(sal_Bool = sal_True ) const;
     266             :     inline const SwDrawModeGrf            &GetDrawModeGrf(sal_Bool = sal_True ) const;
     267             : 
     268             :     /// Paragraph-attributes - implemented in paratr.hxx.
     269             :     inline const SvxLineSpacingItem       &GetLineSpacing( sal_Bool = sal_True ) const;
     270             :     inline const SvxAdjustItem            &GetAdjust( sal_Bool = sal_True ) const;
     271             :     inline const SvxFmtSplitItem      &GetSplit( sal_Bool = sal_True ) const;
     272             :     inline const SwRegisterItem           &GetRegister( sal_Bool = sal_True ) const;
     273             :     inline const SwNumRuleItem            &GetNumRule( sal_Bool = sal_True ) const;
     274             :     inline const SvxWidowsItem            &GetWidows( sal_Bool = sal_True ) const;
     275             :     inline const SvxOrphansItem           &GetOrphans( sal_Bool = sal_True ) const;
     276             :     inline const SvxTabStopItem           &GetTabStops( sal_Bool = sal_True ) const;
     277             :     inline const SvxHyphenZoneItem        &GetHyphenZone( sal_Bool = sal_True ) const;
     278             :     inline const SwFmtDrop                &GetDrop( sal_Bool = sal_True ) const;
     279             :     inline const SvxScriptSpaceItem       &GetScriptSpace(sal_Bool = sal_True) const;
     280             :     inline const SvxHangingPunctuationItem &GetHangingPunctuation(sal_Bool = sal_True) const;
     281             :     inline const SvxForbiddenRuleItem     &GetForbiddenRule(sal_Bool = sal_True) const;
     282             :     inline const SvxParaVertAlignItem &GetParaVertAlign(sal_Bool = sal_True) const;
     283             :     inline const SvxParaGridItem        &GetParaGrid(sal_Bool = sal_True) const;
     284             :     inline const SwParaConnectBorderItem &GetParaConnectBorder(sal_Bool = sal_True ) const;
     285             : 
     286             :     /// TableBox attributes - implemented in cellatr.hxx.
     287             :     inline  const SwTblBoxNumFormat     &GetTblBoxNumFmt( sal_Bool = sal_True ) const;
     288             :     inline  const SwTblBoxFormula       &GetTblBoxFormula( sal_Bool = sal_True ) const;
     289             :     inline  const SwTblBoxValue         &GetTblBoxValue( sal_Bool = sal_True ) const;
     290             : 
     291             :     /** SwFmt::IsBackgroundTransparent
     292             : 
     293             :         Virtual method to determine, if background of format is transparent.
     294             :         Default implementation returns false. Thus, subclasses have to overload
     295             :         method, if the specific subclass can have a transparent background.
     296             : 
     297             :         @author OD
     298             : 
     299             :         @return false, default implementation
     300             :     */
     301             :     virtual sal_Bool IsBackgroundTransparent() const;
     302             : 
     303             :     /** SwFmt::IsShadowTransparent
     304             : 
     305             :         Virtual method to determine, if shadow of format is transparent.
     306             :         Default implementation returns false. Thus, subclasses have to overload
     307             :         method, if the specific subclass can have a transparent shadow.
     308             : 
     309             :         @author OD
     310             : 
     311             :         @return false, default implementation
     312             :     */
     313             :     virtual sal_Bool IsShadowTransparent() const;
     314             : };
     315             : 
     316             : // --------------- inline Implementations ------------------------
     317             : 
     318       14794 : inline const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich,
     319             :                                              sal_Bool bInParents ) const
     320             : {
     321       14794 :     return aSet.Get( nWhich, bInParents );
     322             : }
     323             : 
     324             : inline void SwFmt::SetName( const sal_Char* pNewName,
     325             :                              sal_Bool bBroadcast )
     326             : {
     327             :     SetName(rtl::OUString::createFromAscii(pNewName), bBroadcast);
     328             : }
     329             : 
     330       65958 : inline SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent,
     331             :                                         const SfxPoolItem **ppItem ) const
     332             : {
     333       65958 :     return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
     334             : }
     335             : 
     336             : #undef inline
     337             : 
     338             : #endif // _FORMAT_HXX
     339             : 
     340             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10