361 lines
16 KiB
C++
361 lines
16 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
#ifndef SC_AUTOFORM_HXX
|
|
#define SC_AUTOFORM_HXX
|
|
|
|
/*************************************************************************
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
Die akt. Struktur der Autoformatierung darf nicht mehr veraendert werden.
|
|
Diese wird durch unterschiedlichen Code vom StartWriter und vom StarCalc
|
|
eingelesen/geschrieben.
|
|
Sollte sich doch mal eine Aenderung nicht vermeiden lassen, dann auf
|
|
jedenfall in beiden Applikationen aendern.
|
|
|
|
The structure of table auto formatting should not changed. It is used
|
|
by different code of Writer and Calc. If a change is necessary, the
|
|
source code of both applications must be changed!
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
**************************************************************************/
|
|
|
|
#include "scitems.hxx"
|
|
#include <editeng/adjitem.hxx>
|
|
#include <svx/algitem.hxx>
|
|
#include <editeng/boxitem.hxx>
|
|
#include <editeng/brshitem.hxx>
|
|
#include <editeng/cntritem.hxx>
|
|
#include <editeng/colritem.hxx>
|
|
#include <editeng/crsditem.hxx>
|
|
#include <editeng/fhgtitem.hxx>
|
|
#include <editeng/fontitem.hxx>
|
|
#include <editeng/postitem.hxx>
|
|
#include <editeng/shdditem.hxx>
|
|
#include <editeng/udlnitem.hxx>
|
|
#include <editeng/wghtitem.hxx>
|
|
#include <editeng/justifyitem.hxx>
|
|
#include <svx/rotmodit.hxx>
|
|
#include <svl/intitem.hxx>
|
|
#include <editeng/bolnitem.hxx>
|
|
#include "scdllapi.h"
|
|
#include "global.hxx"
|
|
#include "zforauto.hxx"
|
|
|
|
#include <boost/ptr_container/ptr_map.hpp>
|
|
|
|
/**
|
|
A binary blob of writer-specific data. This data typically consists of types that are
|
|
unavailable to Calc (e.g. SwFmtVertOrient), or that Calc doesn't care about.
|
|
|
|
@remarks Note that in autoformat versions prior to AUTOFORMAT_DATA_ID_31005, Calc
|
|
logic handled and stored several writer-specific items (such as ScAutoFormatDataField::aAdjust).
|
|
That logic was preserved. From _31005 onward, writer-specific data should be handled by
|
|
blobs to avoid needlessly complicating the Calc logic.
|
|
*/
|
|
struct AutoFormatSwBlob : ::boost::noncopyable
|
|
{
|
|
sal_uInt8 *pData;
|
|
sal_Size size;
|
|
|
|
AutoFormatSwBlob() : pData(0), size(0)
|
|
{
|
|
}
|
|
|
|
~AutoFormatSwBlob()
|
|
{
|
|
Reset();
|
|
}
|
|
|
|
void Reset()
|
|
{
|
|
delete[] pData;
|
|
pData = 0;
|
|
size = 0;
|
|
}
|
|
};
|
|
|
|
/// Struct with version numbers of the Items
|
|
struct ScAfVersions
|
|
{
|
|
public:
|
|
sal_uInt16 nFontVersion;
|
|
sal_uInt16 nFontHeightVersion;
|
|
sal_uInt16 nWeightVersion;
|
|
sal_uInt16 nPostureVersion;
|
|
sal_uInt16 nUnderlineVersion;
|
|
sal_uInt16 nOverlineVersion;
|
|
sal_uInt16 nCrossedOutVersion;
|
|
sal_uInt16 nContourVersion;
|
|
sal_uInt16 nShadowedVersion;
|
|
sal_uInt16 nColorVersion;
|
|
sal_uInt16 nBoxVersion;
|
|
sal_uInt16 nLineVersion;
|
|
sal_uInt16 nBrushVersion;
|
|
|
|
sal_uInt16 nAdjustVersion;
|
|
AutoFormatSwBlob swVersions;
|
|
|
|
sal_uInt16 nHorJustifyVersion;
|
|
sal_uInt16 nVerJustifyVersion;
|
|
sal_uInt16 nOrientationVersion;
|
|
sal_uInt16 nMarginVersion;
|
|
sal_uInt16 nBoolVersion;
|
|
sal_uInt16 nInt32Version;
|
|
sal_uInt16 nRotateModeVersion;
|
|
|
|
sal_uInt16 nNumFmtVersion;
|
|
|
|
ScAfVersions();
|
|
void Load( SvStream& rStream, sal_uInt16 nVer );
|
|
void Write(SvStream& rStream, sal_uInt16 fileVersion);
|
|
};
|
|
|
|
/// Contains all items for one cell of a table autoformat.
|
|
class ScAutoFormatDataField
|
|
{
|
|
private:
|
|
SvxFontItem aFont;
|
|
SvxFontHeightItem aHeight;
|
|
SvxWeightItem aWeight;
|
|
SvxPostureItem aPosture;
|
|
|
|
SvxFontItem aCJKFont;
|
|
SvxFontHeightItem aCJKHeight;
|
|
SvxWeightItem aCJKWeight;
|
|
SvxPostureItem aCJKPosture;
|
|
|
|
SvxFontItem aCTLFont;
|
|
SvxFontHeightItem aCTLHeight;
|
|
SvxWeightItem aCTLWeight;
|
|
SvxPostureItem aCTLPosture;
|
|
|
|
SvxUnderlineItem aUnderline;
|
|
SvxOverlineItem aOverline;
|
|
SvxCrossedOutItem aCrossedOut;
|
|
SvxContourItem aContour;
|
|
SvxShadowedItem aShadowed;
|
|
SvxColorItem aColor;
|
|
SvxBoxItem aBox;
|
|
SvxLineItem aTLBR;
|
|
SvxLineItem aBLTR;
|
|
SvxBrushItem aBackground;
|
|
|
|
// Writer specific
|
|
SvxAdjustItem aAdjust;
|
|
AutoFormatSwBlob m_swFields;
|
|
|
|
// Calc specific
|
|
SvxHorJustifyItem aHorJustify;
|
|
SvxVerJustifyItem aVerJustify;
|
|
SfxBoolItem aStacked;
|
|
SvxMarginItem aMargin;
|
|
SfxBoolItem aLinebreak;
|
|
// from SO5, 504k on, rotated text
|
|
SfxInt32Item aRotateAngle;
|
|
SvxRotateModeItem aRotateMode;
|
|
|
|
// number format
|
|
ScNumFormatAbbrev aNumFormat;
|
|
|
|
public:
|
|
ScAutoFormatDataField();
|
|
ScAutoFormatDataField( const ScAutoFormatDataField& rCopy );
|
|
~ScAutoFormatDataField();
|
|
|
|
const ScNumFormatAbbrev& GetNumFormat() const { return aNumFormat; }
|
|
const SvxFontItem& GetFont() const { return aFont; }
|
|
const SvxFontHeightItem& GetHeight() const { return aHeight; }
|
|
const SvxWeightItem& GetWeight() const { return aWeight; }
|
|
const SvxPostureItem& GetPosture() const { return aPosture; }
|
|
const SvxFontItem& GetCJKFont() const { return aCJKFont; }
|
|
const SvxFontHeightItem& GetCJKHeight() const { return aCJKHeight; }
|
|
const SvxWeightItem& GetCJKWeight() const { return aCJKWeight; }
|
|
const SvxPostureItem& GetCJKPosture() const { return aCJKPosture; }
|
|
const SvxFontItem& GetCTLFont() const { return aCTLFont; }
|
|
const SvxFontHeightItem& GetCTLHeight() const { return aCTLHeight; }
|
|
const SvxWeightItem& GetCTLWeight() const { return aCTLWeight; }
|
|
const SvxPostureItem& GetCTLPosture() const { return aCTLPosture; }
|
|
const SvxUnderlineItem& GetUnderline() const { return aUnderline; }
|
|
const SvxOverlineItem& GetOverline() const { return aOverline; }
|
|
const SvxCrossedOutItem& GetCrossedOut() const { return aCrossedOut; }
|
|
const SvxContourItem& GetContour() const { return aContour; }
|
|
const SvxShadowedItem& GetShadowed() const { return aShadowed; }
|
|
const SvxColorItem& GetColor() const { return aColor; }
|
|
const SvxHorJustifyItem& GetHorJustify() const { return aHorJustify; }
|
|
const SvxVerJustifyItem& GetVerJustify() const { return aVerJustify; }
|
|
const SfxBoolItem& GetStacked() const { return aStacked; }
|
|
const SfxBoolItem& GetLinebreak() const { return aLinebreak; }
|
|
const SvxMarginItem& GetMargin() const { return aMargin; }
|
|
const SvxBoxItem& GetBox() const { return aBox; }
|
|
const SvxLineItem& GetTLBR() const { return aTLBR; }
|
|
const SvxLineItem& GetBLTR() const { return aBLTR; }
|
|
const SvxBrushItem& GetBackground() const { return aBackground; }
|
|
const SvxAdjustItem& GetAdjust() const { return aAdjust; }
|
|
const SfxInt32Item& GetRotateAngle() const { return aRotateAngle; }
|
|
const SvxRotateModeItem& GetRotateMode() const { return aRotateMode; }
|
|
|
|
void SetNumFormat( const ScNumFormatAbbrev& rNumFormat ) { aNumFormat = rNumFormat; }
|
|
void SetFont( const SvxFontItem& rFont ) { aFont = rFont; }
|
|
void SetHeight( const SvxFontHeightItem& rHeight ) { aHeight = rHeight; }
|
|
void SetWeight( const SvxWeightItem& rWeight ) { aWeight = rWeight; }
|
|
void SetPosture( const SvxPostureItem& rPosture ) { aPosture = rPosture; }
|
|
void SetCJKFont( const SvxFontItem& rCJKFont ) { aCJKFont = rCJKFont; }
|
|
void SetCJKHeight( const SvxFontHeightItem& rCJKHeight ) { aCJKHeight = rCJKHeight; }
|
|
void SetCJKWeight( const SvxWeightItem& rCJKWeight ) { aCJKWeight = rCJKWeight; }
|
|
void SetCJKPosture( const SvxPostureItem& rCJKPosture ) { aCJKPosture = rCJKPosture; }
|
|
void SetCTLFont( const SvxFontItem& rCTLFont ) { aCTLFont = rCTLFont; }
|
|
void SetCTLHeight( const SvxFontHeightItem& rCTLHeight ) { aCTLHeight = rCTLHeight; }
|
|
void SetCTLWeight( const SvxWeightItem& rCTLWeight ) { aCTLWeight = rCTLWeight; }
|
|
void SetCTLPosture( const SvxPostureItem& rCTLPosture ) { aCTLPosture = rCTLPosture; }
|
|
void SetUnderline( const SvxUnderlineItem& rUnderline ) { aUnderline = rUnderline; }
|
|
void SetOverline( const SvxOverlineItem& rOverline ) { aOverline = rOverline; }
|
|
void SetCrossedOut( const SvxCrossedOutItem& rCrossedOut ) { aCrossedOut = rCrossedOut; }
|
|
void SetContour( const SvxContourItem& rContour ) { aContour = rContour; }
|
|
void SetShadowed( const SvxShadowedItem& rShadowed ) { aShadowed = rShadowed; }
|
|
void SetColor( const SvxColorItem& rColor ) { aColor = rColor; }
|
|
void SetHorJustify( const SvxHorJustifyItem& rHorJustify ) { aHorJustify = rHorJustify; }
|
|
void SetVerJustify( const SvxVerJustifyItem& rVerJustify ) { aVerJustify = rVerJustify; }
|
|
void SetStacked( const SfxBoolItem& rStacked ) { aStacked.SetValue( rStacked.GetValue() ); }
|
|
void SetLinebreak( const SfxBoolItem& rLinebreak ) { aLinebreak.SetValue( rLinebreak.GetValue() ); }
|
|
void SetMargin( const SvxMarginItem& rMargin ) { aMargin = rMargin; }
|
|
void SetBox( const SvxBoxItem& rBox ) { aBox = rBox; }
|
|
void SetTLBR( const SvxLineItem& rTLBR ) { aTLBR = rTLBR; }
|
|
void SetBLTR( const SvxLineItem& rBLTR ) { aBLTR = rBLTR; }
|
|
void SetBackground( const SvxBrushItem& rBackground ) { aBackground = rBackground; }
|
|
void SetAdjust( const SvxAdjustItem& rAdjust );
|
|
void SetRotateAngle( const SfxInt32Item& rRotateAngle ) { aRotateAngle.SetValue( rRotateAngle.GetValue() ); }
|
|
void SetRotateMode( const SvxRotateModeItem& rRotateMode ) { aRotateMode.SetValue( rRotateMode.GetValue() ); }
|
|
|
|
sal_Bool Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
|
|
sal_Bool Save( SvStream& rStream, sal_uInt16 fileVersion );
|
|
};
|
|
|
|
|
|
class SC_DLLPUBLIC ScAutoFormatData
|
|
{
|
|
private:
|
|
rtl::OUString aName;
|
|
sal_uInt16 nStrResId;
|
|
// common flags of Calc and Writer
|
|
bool bIncludeFont : 1;
|
|
bool bIncludeJustify : 1;
|
|
bool bIncludeFrame : 1;
|
|
bool bIncludeBackground : 1;
|
|
|
|
// Calc specific flags
|
|
bool bIncludeValueFormat : 1;
|
|
bool bIncludeWidthHeight : 1;
|
|
|
|
// Writer-specific data
|
|
AutoFormatSwBlob m_swFields;
|
|
|
|
ScAutoFormatDataField** ppDataField;
|
|
|
|
SC_DLLPRIVATE ScAutoFormatDataField& GetField( sal_uInt16 nIndex );
|
|
SC_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
|
|
|
|
public:
|
|
ScAutoFormatData();
|
|
ScAutoFormatData( const ScAutoFormatData& rData );
|
|
~ScAutoFormatData();
|
|
|
|
void SetName( const rtl::OUString& rName ) { aName = rName; nStrResId = USHRT_MAX; }
|
|
const rtl::OUString& GetName() const { return aName; }
|
|
|
|
bool GetIncludeValueFormat() const { return bIncludeValueFormat; }
|
|
bool GetIncludeFont() const { return bIncludeFont; }
|
|
bool GetIncludeJustify() const { return bIncludeJustify; }
|
|
bool GetIncludeFrame() const { return bIncludeFrame; }
|
|
bool GetIncludeBackground() const { return bIncludeBackground; }
|
|
bool GetIncludeWidthHeight() const { return bIncludeWidthHeight; }
|
|
|
|
void SetIncludeValueFormat( bool bValueFormat ) { bIncludeValueFormat = bValueFormat; }
|
|
void SetIncludeFont( bool bFont ) { bIncludeFont = bFont; }
|
|
void SetIncludeJustify( bool bJustify ) { bIncludeJustify = bJustify; }
|
|
void SetIncludeFrame( bool bFrame ) { bIncludeFrame = bFrame; }
|
|
void SetIncludeBackground( bool bBackground ) { bIncludeBackground = bBackground; }
|
|
void SetIncludeWidthHeight( bool bWidthHeight ) { bIncludeWidthHeight = bWidthHeight; }
|
|
|
|
const SfxPoolItem* GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
|
|
void PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
|
|
void CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
|
|
|
|
const ScNumFormatAbbrev& GetNumFormat( sal_uInt16 nIndex ) const;
|
|
|
|
bool IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const;
|
|
|
|
void FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, ScDocument& rDoc ) const;
|
|
void GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
|
|
|
|
bool Load( SvStream& rStream, const ScAfVersions& rVersions );
|
|
bool Save( SvStream& rStream, sal_uInt16 fileVersion );
|
|
};
|
|
|
|
class SC_DLLPUBLIC ScAutoFormat
|
|
{
|
|
typedef boost::ptr_map<rtl::OUString, ScAutoFormatData> MapType;
|
|
MapType maData;
|
|
bool mbSaveLater;
|
|
ScAfVersions m_aVersions;
|
|
|
|
public:
|
|
typedef MapType::const_iterator const_iterator;
|
|
typedef MapType::iterator iterator;
|
|
|
|
ScAutoFormat();
|
|
ScAutoFormat(const ScAutoFormat& r);
|
|
~ScAutoFormat();
|
|
bool Load();
|
|
bool Save();
|
|
|
|
void SetSaveLater( bool bSet );
|
|
bool IsSaveLater() const { return mbSaveLater; }
|
|
|
|
const ScAutoFormatData* findByIndex(size_t nIndex) const;
|
|
ScAutoFormatData* findByIndex(size_t nIndex);
|
|
const_iterator find(const ScAutoFormatData* pData) const;
|
|
iterator find(const ScAutoFormatData* pData);
|
|
const_iterator find(const rtl::OUString& rName) const;
|
|
iterator find(const rtl::OUString& rName);
|
|
|
|
bool insert(ScAutoFormatData* pNew);
|
|
void erase(const iterator& it);
|
|
|
|
size_t size() const;
|
|
const_iterator begin() const;
|
|
const_iterator end() const;
|
|
iterator begin();
|
|
iterator end();
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|