LCOV - code coverage report
Current view: top level - libreoffice/sc/inc - autoform.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 87 0.0 %
Date: 2012-12-27 Functions: 0 79 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef SC_AUTOFORM_HXX
      21             : #define SC_AUTOFORM_HXX
      22             : 
      23             : /*************************************************************************
      24             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      25             : 
      26             : 
      27             :     Die akt. Struktur der Autoformatierung darf nicht mehr veraendert werden.
      28             :     Diese wird durch unterschiedlichen Code vom StartWriter und vom StarCalc
      29             :     eingelesen/geschrieben.
      30             :     Sollte sich doch mal eine Aenderung nicht vermeiden lassen, dann auf
      31             :     jedenfall in beiden Applikationen aendern.
      32             : 
      33             :     The structure of table auto formatting should not changed. It is used
      34             :     by different code of Writer and Calc. If a change is necessary, the
      35             :     source code of both applications must be changed!
      36             : 
      37             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      38             : **************************************************************************/
      39             : 
      40             : #include "scitems.hxx"
      41             : #include <editeng/adjitem.hxx>
      42             : #include <svx/algitem.hxx>
      43             : #include <editeng/boxitem.hxx>
      44             : #include <editeng/brshitem.hxx>
      45             : #include <editeng/cntritem.hxx>
      46             : #include <editeng/colritem.hxx>
      47             : #include <editeng/crsditem.hxx>
      48             : #include <editeng/fhgtitem.hxx>
      49             : #include <editeng/fontitem.hxx>
      50             : #include <editeng/postitem.hxx>
      51             : #include <editeng/shdditem.hxx>
      52             : #include <editeng/udlnitem.hxx>
      53             : #include <editeng/wghtitem.hxx>
      54             : #include <editeng/justifyitem.hxx>
      55             : #include <svx/rotmodit.hxx>
      56             : #include <svl/intitem.hxx>
      57             : #include <editeng/bolnitem.hxx>
      58             : #include "scdllapi.h"
      59             : #include "global.hxx"
      60             : #include "zforauto.hxx"
      61             : 
      62             : #include <boost/ptr_container/ptr_map.hpp>
      63             : 
      64             : /**
      65             : A binary blob of writer-specific data. This data typically consists of types that are
      66             : unavailable to Calc (e.g. SwFmtVertOrient), or that Calc doesn't care about.
      67             : 
      68             : @remarks Note that in autoformat versions prior to AUTOFORMAT_DATA_ID_31005, Calc
      69             : logic handled and stored several writer-specific items (such as ScAutoFormatDataField::aAdjust).
      70             : That logic was preserved. From _31005 onward, writer-specific data should be handled by
      71             : blobs to avoid needlessly complicating the Calc logic.
      72             : */
      73             : struct AutoFormatSwBlob : ::boost::noncopyable
      74             : {
      75             :     sal_uInt8 *pData;
      76             :     sal_Size size;
      77             : 
      78           0 :     AutoFormatSwBlob() : pData(0), size(0)
      79             :     {
      80           0 :     }
      81             : 
      82           0 :     ~AutoFormatSwBlob()
      83           0 :     {
      84           0 :         Reset();
      85           0 :     }
      86             : 
      87           0 :     void Reset()
      88             :     {
      89           0 :         delete[] pData;
      90           0 :         pData = 0;
      91           0 :         size = 0;
      92           0 :     }
      93             : };
      94             : 
      95             : /// Struct with version numbers of the Items
      96           0 : struct ScAfVersions
      97             : {
      98             : public:
      99             :     sal_uInt16 nFontVersion;
     100             :     sal_uInt16 nFontHeightVersion;
     101             :     sal_uInt16 nWeightVersion;
     102             :     sal_uInt16 nPostureVersion;
     103             :     sal_uInt16 nUnderlineVersion;
     104             :     sal_uInt16 nOverlineVersion;
     105             :     sal_uInt16 nCrossedOutVersion;
     106             :     sal_uInt16 nContourVersion;
     107             :     sal_uInt16 nShadowedVersion;
     108             :     sal_uInt16 nColorVersion;
     109             :     sal_uInt16 nBoxVersion;
     110             :     sal_uInt16 nLineVersion;
     111             :     sal_uInt16 nBrushVersion;
     112             : 
     113             :     sal_uInt16 nAdjustVersion;
     114             :     AutoFormatSwBlob swVersions;
     115             : 
     116             :     sal_uInt16 nHorJustifyVersion;
     117             :     sal_uInt16 nVerJustifyVersion;
     118             :     sal_uInt16 nOrientationVersion;
     119             :     sal_uInt16 nMarginVersion;
     120             :     sal_uInt16 nBoolVersion;
     121             :     sal_uInt16 nInt32Version;
     122             :     sal_uInt16 nRotateModeVersion;
     123             : 
     124             :     sal_uInt16 nNumFmtVersion;
     125             : 
     126             :     ScAfVersions();
     127             :     void Load( SvStream& rStream, sal_uInt16 nVer );
     128             :     void Write(SvStream& rStream, sal_uInt16 fileVersion);
     129             : };
     130             : 
     131             : /// Contains all items for one cell of a table autoformat.
     132             : class ScAutoFormatDataField
     133             : {
     134             : private:
     135             :     SvxFontItem                 aFont;
     136             :     SvxFontHeightItem           aHeight;
     137             :     SvxWeightItem               aWeight;
     138             :     SvxPostureItem              aPosture;
     139             : 
     140             :     SvxFontItem                 aCJKFont;
     141             :     SvxFontHeightItem           aCJKHeight;
     142             :     SvxWeightItem               aCJKWeight;
     143             :     SvxPostureItem              aCJKPosture;
     144             : 
     145             :     SvxFontItem                 aCTLFont;
     146             :     SvxFontHeightItem           aCTLHeight;
     147             :     SvxWeightItem               aCTLWeight;
     148             :     SvxPostureItem              aCTLPosture;
     149             : 
     150             :     SvxUnderlineItem            aUnderline;
     151             :     SvxOverlineItem             aOverline;
     152             :     SvxCrossedOutItem           aCrossedOut;
     153             :     SvxContourItem              aContour;
     154             :     SvxShadowedItem             aShadowed;
     155             :     SvxColorItem                aColor;
     156             :     SvxBoxItem                  aBox;
     157             :     SvxLineItem                 aTLBR;
     158             :     SvxLineItem                 aBLTR;
     159             :     SvxBrushItem                aBackground;
     160             : 
     161             :     // Writer specific
     162             :     SvxAdjustItem               aAdjust;
     163             :     AutoFormatSwBlob            m_swFields;
     164             : 
     165             :     // Calc specific
     166             :     SvxHorJustifyItem           aHorJustify;
     167             :     SvxVerJustifyItem           aVerJustify;
     168             :     SfxBoolItem                 aStacked;
     169             :     SvxMarginItem               aMargin;
     170             :     SfxBoolItem                 aLinebreak;
     171             :     // from SO5, 504k on, rotated text
     172             :     SfxInt32Item                aRotateAngle;
     173             :     SvxRotateModeItem           aRotateMode;
     174             : 
     175             :     // number format
     176             :     ScNumFormatAbbrev           aNumFormat;
     177             : 
     178             : public:
     179             :                                 ScAutoFormatDataField();
     180             :                                 ScAutoFormatDataField( const ScAutoFormatDataField& rCopy );
     181             :                                 ~ScAutoFormatDataField();
     182             : 
     183           0 :     const ScNumFormatAbbrev&    GetNumFormat() const    { return aNumFormat; }
     184           0 :     const SvxFontItem&          GetFont() const         { return aFont; }
     185           0 :     const SvxFontHeightItem&    GetHeight() const       { return aHeight; }
     186           0 :     const SvxWeightItem&        GetWeight() const       { return aWeight; }
     187           0 :     const SvxPostureItem&       GetPosture() const      { return aPosture; }
     188           0 :     const SvxFontItem&          GetCJKFont() const      { return aCJKFont; }
     189           0 :     const SvxFontHeightItem&    GetCJKHeight() const    { return aCJKHeight; }
     190           0 :     const SvxWeightItem&        GetCJKWeight() const    { return aCJKWeight; }
     191           0 :     const SvxPostureItem&       GetCJKPosture() const   { return aCJKPosture; }
     192           0 :     const SvxFontItem&          GetCTLFont() const      { return aCTLFont; }
     193           0 :     const SvxFontHeightItem&    GetCTLHeight() const    { return aCTLHeight; }
     194           0 :     const SvxWeightItem&        GetCTLWeight() const    { return aCTLWeight; }
     195           0 :     const SvxPostureItem&       GetCTLPosture() const   { return aCTLPosture; }
     196           0 :     const SvxUnderlineItem&     GetUnderline() const    { return aUnderline; }
     197           0 :     const SvxOverlineItem&      GetOverline() const     { return aOverline; }
     198           0 :     const SvxCrossedOutItem&    GetCrossedOut() const   { return aCrossedOut; }
     199           0 :     const SvxContourItem&       GetContour() const      { return aContour; }
     200           0 :     const SvxShadowedItem&      GetShadowed() const     { return aShadowed; }
     201           0 :     const SvxColorItem&         GetColor() const        { return aColor; }
     202           0 :     const SvxHorJustifyItem&    GetHorJustify() const   { return aHorJustify; }
     203           0 :     const SvxVerJustifyItem&    GetVerJustify() const   { return aVerJustify; }
     204           0 :     const SfxBoolItem&          GetStacked() const      { return aStacked; }
     205           0 :     const SfxBoolItem&          GetLinebreak() const    { return aLinebreak; }
     206           0 :     const SvxMarginItem&        GetMargin() const       { return aMargin; }
     207           0 :     const SvxBoxItem&           GetBox() const          { return aBox; }
     208           0 :     const SvxLineItem&          GetTLBR() const         { return aTLBR; }
     209           0 :     const SvxLineItem&          GetBLTR() const         { return aBLTR; }
     210           0 :     const SvxBrushItem&         GetBackground() const   { return aBackground; }
     211             :     const SvxAdjustItem&        GetAdjust() const       { return aAdjust; }
     212           0 :     const SfxInt32Item&         GetRotateAngle() const  { return aRotateAngle; }
     213           0 :     const SvxRotateModeItem&    GetRotateMode() const   { return aRotateMode; }
     214             : 
     215           0 :     void    SetNumFormat( const ScNumFormatAbbrev& rNumFormat )     { aNumFormat = rNumFormat; }
     216           0 :     void    SetFont( const SvxFontItem& rFont )                     { aFont = rFont; }
     217           0 :     void    SetHeight( const SvxFontHeightItem& rHeight )           { aHeight = rHeight; }
     218           0 :     void    SetWeight( const SvxWeightItem& rWeight )               { aWeight = rWeight; }
     219           0 :     void    SetPosture( const SvxPostureItem& rPosture )            { aPosture = rPosture; }
     220           0 :     void    SetCJKFont( const SvxFontItem& rCJKFont )               { aCJKFont = rCJKFont; }
     221           0 :     void    SetCJKHeight( const SvxFontHeightItem& rCJKHeight )     { aCJKHeight = rCJKHeight; }
     222           0 :     void    SetCJKWeight( const SvxWeightItem& rCJKWeight )         { aCJKWeight = rCJKWeight; }
     223           0 :     void    SetCJKPosture( const SvxPostureItem& rCJKPosture )      { aCJKPosture = rCJKPosture; }
     224           0 :     void    SetCTLFont( const SvxFontItem& rCTLFont )               { aCTLFont = rCTLFont; }
     225           0 :     void    SetCTLHeight( const SvxFontHeightItem& rCTLHeight )     { aCTLHeight = rCTLHeight; }
     226           0 :     void    SetCTLWeight( const SvxWeightItem& rCTLWeight )         { aCTLWeight = rCTLWeight; }
     227           0 :     void    SetCTLPosture( const SvxPostureItem& rCTLPosture )      { aCTLPosture = rCTLPosture; }
     228           0 :     void    SetUnderline( const SvxUnderlineItem& rUnderline )      { aUnderline = rUnderline; }
     229           0 :     void    SetOverline( const SvxOverlineItem& rOverline )         { aOverline = rOverline; }
     230           0 :     void    SetCrossedOut( const SvxCrossedOutItem& rCrossedOut )   { aCrossedOut = rCrossedOut; }
     231           0 :     void    SetContour( const SvxContourItem& rContour )            { aContour = rContour; }
     232           0 :     void    SetShadowed( const SvxShadowedItem& rShadowed )         { aShadowed = rShadowed; }
     233           0 :     void    SetColor( const SvxColorItem& rColor )                  { aColor = rColor; }
     234           0 :     void    SetHorJustify( const SvxHorJustifyItem& rHorJustify )   { aHorJustify = rHorJustify; }
     235           0 :     void    SetVerJustify( const SvxVerJustifyItem& rVerJustify )   { aVerJustify = rVerJustify; }
     236           0 :     void    SetStacked( const SfxBoolItem& rStacked )               { aStacked.SetValue( rStacked.GetValue() ); }
     237           0 :     void    SetLinebreak( const SfxBoolItem& rLinebreak )           { aLinebreak.SetValue( rLinebreak.GetValue() ); }
     238           0 :     void    SetMargin( const SvxMarginItem& rMargin )               { aMargin = rMargin; }
     239           0 :     void    SetBox( const SvxBoxItem& rBox )                        { aBox = rBox; }
     240           0 :     void    SetTLBR( const SvxLineItem& rTLBR )                     { aTLBR = rTLBR; }
     241           0 :     void    SetBLTR( const SvxLineItem& rBLTR )                     { aBLTR = rBLTR; }
     242           0 :     void    SetBackground( const SvxBrushItem& rBackground )        { aBackground = rBackground; }
     243             :     void    SetAdjust( const SvxAdjustItem& rAdjust );
     244           0 :     void    SetRotateAngle( const SfxInt32Item& rRotateAngle )      { aRotateAngle.SetValue( rRotateAngle.GetValue() ); }
     245           0 :     void    SetRotateMode( const SvxRotateModeItem& rRotateMode )   { aRotateMode.SetValue( rRotateMode.GetValue() ); }
     246             : 
     247             :     sal_Bool                        Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
     248             :     sal_Bool                        Save( SvStream& rStream, sal_uInt16 fileVersion );
     249             : };
     250             : 
     251             : 
     252             : class SC_DLLPUBLIC ScAutoFormatData
     253             : {
     254             : private:
     255             :     rtl::OUString               aName;
     256             :     sal_uInt16                  nStrResId;
     257             :     // common flags of Calc and Writer
     258             :     bool                        bIncludeFont : 1;
     259             :     bool                        bIncludeJustify : 1;
     260             :     bool                        bIncludeFrame : 1;
     261             :     bool                        bIncludeBackground : 1;
     262             : 
     263             :     // Calc specific flags
     264             :     bool                        bIncludeValueFormat : 1;
     265             :     bool                        bIncludeWidthHeight : 1;
     266             : 
     267             :     // Writer-specific data
     268             :     AutoFormatSwBlob m_swFields;
     269             : 
     270             :     ScAutoFormatDataField**     ppDataField;
     271             : 
     272             :     SC_DLLPRIVATE ScAutoFormatDataField&       GetField( sal_uInt16 nIndex );
     273             :     SC_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
     274             : 
     275             : public:
     276             :     ScAutoFormatData();
     277             :     ScAutoFormatData( const ScAutoFormatData& rData );
     278             :     ~ScAutoFormatData();
     279             : 
     280           0 :     void            SetName( const rtl::OUString& rName )              { aName = rName; nStrResId = USHRT_MAX; }
     281           0 :     const rtl::OUString& GetName() const { return aName; }
     282             : 
     283           0 :     bool            GetIncludeValueFormat() const               { return bIncludeValueFormat; }
     284           0 :     bool            GetIncludeFont() const                      { return bIncludeFont; }
     285           0 :     bool            GetIncludeJustify() const                   { return bIncludeJustify; }
     286           0 :     bool            GetIncludeFrame() const                     { return bIncludeFrame; }
     287           0 :     bool            GetIncludeBackground() const                { return bIncludeBackground; }
     288           0 :     bool            GetIncludeWidthHeight() const               { return bIncludeWidthHeight; }
     289             : 
     290           0 :     void            SetIncludeValueFormat( bool bValueFormat )  { bIncludeValueFormat = bValueFormat; }
     291           0 :     void            SetIncludeFont( bool bFont )                { bIncludeFont = bFont; }
     292           0 :     void            SetIncludeJustify( bool bJustify )          { bIncludeJustify = bJustify; }
     293           0 :     void            SetIncludeFrame( bool bFrame )              { bIncludeFrame = bFrame; }
     294           0 :     void            SetIncludeBackground( bool bBackground )    { bIncludeBackground = bBackground; }
     295           0 :     void            SetIncludeWidthHeight( bool bWidthHeight )  { bIncludeWidthHeight = bWidthHeight; }
     296             : 
     297             :     const SfxPoolItem*          GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
     298             :     void                        PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
     299             :     void                        CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
     300             : 
     301             :     const ScNumFormatAbbrev&    GetNumFormat( sal_uInt16 nIndex ) const;
     302             : 
     303             :     bool                        IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const;
     304             : 
     305             :     void                        FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, ScDocument& rDoc ) const;
     306             :     void                        GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
     307             : 
     308             :     bool                        Load( SvStream& rStream, const ScAfVersions& rVersions );
     309             :     bool                        Save( SvStream& rStream, sal_uInt16 fileVersion );
     310             : };
     311             : 
     312             : class SC_DLLPUBLIC ScAutoFormat
     313             : {
     314             :     typedef boost::ptr_map<rtl::OUString, ScAutoFormatData> MapType;
     315             :     MapType maData;
     316             :     bool mbSaveLater;
     317             :     ScAfVersions m_aVersions;
     318             : 
     319             : public:
     320             :     typedef MapType::const_iterator const_iterator;
     321             :     typedef MapType::iterator iterator;
     322             : 
     323             :     ScAutoFormat();
     324             :     ScAutoFormat(const ScAutoFormat& r);
     325             :     ~ScAutoFormat();
     326             :     bool Load();
     327             :     bool Save();
     328             : 
     329             :     void SetSaveLater( bool bSet );
     330           0 :     bool IsSaveLater() const { return mbSaveLater; }
     331             : 
     332             :     const ScAutoFormatData* findByIndex(size_t nIndex) const;
     333             :     ScAutoFormatData* findByIndex(size_t nIndex);
     334             :     const_iterator find(const ScAutoFormatData* pData) const;
     335             :     iterator find(const ScAutoFormatData* pData);
     336             :     const_iterator find(const rtl::OUString& rName) const;
     337             :     iterator find(const rtl::OUString& rName);
     338             : 
     339             :     bool insert(ScAutoFormatData* pNew);
     340             :     void erase(const iterator& it);
     341             : 
     342             :     size_t size() const;
     343             :     const_iterator begin() const;
     344             :     const_iterator end() const;
     345             :     iterator begin();
     346             :     iterator end();
     347             : };
     348             : 
     349             : 
     350             : #endif
     351             : 
     352             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10