Files
libreoffice/sw/inc/tblafmt.hxx

326 lines
14 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SW_INC_TBLAFMT_HXX
#define INCLUDED_SW_INC_TBLAFMT_HXX
/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* The structure of table auto formatting should not be 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!
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
2000-09-18 16:15:01 +00:00
#include <boost/scoped_ptr.hpp>
#include "hintids.hxx"
2000-09-18 16:15:01 +00:00
#include <svx/algitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/crossedoutitem.hxx>
#include <editeng/contouritem.hxx>
#include <editeng/shdditem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/adjustitem.hxx>
#include <editeng/justifyitem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <editeng/shaditem.hxx>
2000-09-18 16:15:01 +00:00
#include <svx/rotmodit.hxx>
#include <svl/intitem.hxx>
#include <editeng/lineitem.hxx>
#include <fmtpdsc.hxx>
#include <fmtlsplt.hxx>
#include <fmtrowsplt.hxx>
#include <fmtornt.hxx>
#include "swdllapi.h"
2000-09-18 16:15:01 +00:00
struct SwAfVersions;
class SvNumberFormatter;
class SwBoxAutoFormat
2000-09-18 16:15:01 +00:00
{
// common attributes of Calc and Writer
// --- from 641 on: CJK and CTL font settings
2000-09-18 16:15:01 +00:00
SvxFontItem aFont;
SvxFontHeightItem aHeight;
SvxWeightItem aWeight;
SvxPostureItem aPosture;
SvxFontItem aCJKFont;
SvxFontHeightItem aCJKHeight;
SvxWeightItem aCJKWeight;
SvxPostureItem aCJKPosture;
SvxFontItem aCTLFont;
SvxFontHeightItem aCTLHeight;
SvxWeightItem aCTLWeight;
SvxPostureItem aCTLPosture;
2000-09-18 16:15:01 +00:00
SvxUnderlineItem aUnderline;
SvxOverlineItem aOverline;
2000-09-18 16:15:01 +00:00
SvxCrossedOutItem aCrossedOut;
SvxContourItem aContour;
SvxShadowedItem aShadowed;
SvxColorItem aColor;
SvxBoxItem aBox;
SvxLineItem aTLBR;
SvxLineItem aBLTR;
2000-09-18 16:15:01 +00:00
SvxBrushItem aBackground;
// Writer specific
2000-09-18 16:15:01 +00:00
SvxAdjustItem aAdjust;
SvxFrameDirectionItem m_aTextOrientation;
SwFormatVertOrient m_aVerticalAlignment;
2000-09-18 16:15:01 +00:00
// Calc specific
2000-09-18 16:15:01 +00:00
SvxHorJustifyItem aHorJustify;
SvxVerJustifyItem aVerJustify;
SfxBoolItem aStacked;
2000-09-18 16:15:01 +00:00
SvxMarginItem aMargin;
SfxBoolItem aLinebreak;
SfxInt32Item aRotateAngle;
SvxRotateModeItem aRotateMode;
// number format
OUString sNumFormatString;
LanguageType eSysLanguage, eNumFormatLanguage;
2000-09-18 16:15:01 +00:00
public:
SwBoxAutoFormat();
SwBoxAutoFormat( const SwBoxAutoFormat& rNew );
~SwBoxAutoFormat();
2000-09-18 16:15:01 +00:00
int operator==( const SwBoxAutoFormat& rCmp ) const;
SwBoxAutoFormat& operator=( const SwBoxAutoFormat& rNew );
2000-09-18 16:15:01 +00:00
2011-04-25 20:33:33 +02:00
// The get-methods.
2000-09-18 16:15:01 +00:00
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; }
2000-09-18 16:15:01 +00:00
const SvxUnderlineItem &GetUnderline() const { return aUnderline; }
const SvxOverlineItem &GetOverline() const { return aOverline; }
2000-09-18 16:15:01 +00:00
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 SvxAdjustItem &GetAdjust() const { return aAdjust; }
const SvxFrameDirectionItem& GetTextOrientation() const { return m_aTextOrientation; }
const SwFormatVertOrient& GetVerticalAlignment() const { return m_aVerticalAlignment; }
2000-09-18 16:15:01 +00:00
const SvxBoxItem &GetBox() const { return aBox; }
const SvxLineItem &GetTLBR() const { return aTLBR; }
const SvxLineItem &GetBLTR() const { return aBLTR; }
2000-09-18 16:15:01 +00:00
const SvxBrushItem &GetBackground() const { return aBackground; }
void GetValueFormat( OUString& rFormat, LanguageType& rLng, LanguageType& rSys ) const
{ rFormat = sNumFormatString; rLng = eNumFormatLanguage; rSys = eSysLanguage; }
2000-09-18 16:15:01 +00:00
2011-04-25 20:33:33 +02:00
// The set-methods.
2000-09-18 16:15:01 +00:00
void SetFont( const SvxFontItem& rNew ) { aFont = rNew; }
void SetHeight( const SvxFontHeightItem& rNew ) { aHeight = rNew; }
void SetWeight( const SvxWeightItem& rNew ) { aWeight = rNew; }
void SetPosture( const SvxPostureItem& rNew ) { aPosture = rNew; }
void SetCJKFont( const SvxFontItem& rNew ) { aCJKFont = rNew; }
void SetCJKHeight( const SvxFontHeightItem& rNew ) { aCJKHeight = rNew; }
void SetCJKWeight( const SvxWeightItem& rNew ) { aCJKWeight = rNew; }
void SetCJKPosture( const SvxPostureItem& rNew ) { aCJKPosture = rNew; }
void SetCTLFont( const SvxFontItem& rNew ) { aCTLFont = rNew; }
void SetCTLHeight( const SvxFontHeightItem& rNew ) { aCTLHeight = rNew; }
void SetCTLWeight( const SvxWeightItem& rNew ) { aCTLWeight = rNew; }
void SetCTLPosture( const SvxPostureItem& rNew ) { aCTLPosture = rNew; }
2000-09-18 16:15:01 +00:00
void SetUnderline( const SvxUnderlineItem& rNew ) { aUnderline = rNew; }
void SetOverline( const SvxOverlineItem& rNew ) { aOverline = rNew; }
2000-09-18 16:15:01 +00:00
void SetCrossedOut( const SvxCrossedOutItem& rNew ) { aCrossedOut = rNew; }
void SetContour( const SvxContourItem& rNew ) { aContour = rNew; }
void SetShadowed( const SvxShadowedItem& rNew ) { aShadowed = rNew; }
void SetColor( const SvxColorItem& rNew ) { aColor = rNew; }
void SetAdjust( const SvxAdjustItem& rNew )
{
aAdjust.SetAdjust( rNew.GetAdjust() );
aAdjust.SetOneWord( rNew.GetOneWord() );
aAdjust.SetLastBlock( rNew.GetLastBlock() );
}
void SetTextOrientation(const SvxFrameDirectionItem& rNew) { m_aTextOrientation = rNew; }
void SetVerticalAlignment(const SwFormatVertOrient& rNew) { m_aVerticalAlignment = rNew; }
2000-09-18 16:15:01 +00:00
void SetBox( const SvxBoxItem& rNew ) { aBox = rNew; }
void SetBackground( const SvxBrushItem& rNew ) { aBackground = rNew; }
void SetValueFormat( const OUString& rFormat, LanguageType eLng, LanguageType eSys )
{ sNumFormatString = rFormat; eNumFormatLanguage = eLng; eSysLanguage = eSys; }
2000-09-18 16:15:01 +00:00
bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer );
bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
bool SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const;
2000-09-18 16:15:01 +00:00
};
/*
@remarks
A table has a number of lines. These lines seem to correspond with rows, except in the case of
rows spanning more than one line. Each line contains a number of boxes/cells.
AutoFormat properties are retrieved and stored in a grid of 16 table boxes. A sampling approach
is used to read the data. 4 lines are picked, and 4 boxes are picked from each.
The line picking and box picking algorithms are similar. We start at the first line/box, and pick
lines/boxes one by one for a maximum of 3. The 4th line/box is the last line/box in the current
table/line. If we hit the end of lines/boxes, the last line/box encountered is picked several times.
For example, in a 2x3 table, the 4 lines will be [0, 1, 1, 1]. In each line, the boxes will be
[0, 1, 2, 2]. In a 6x5 table, the 4 lines will be [0, 1, 2, 4] and the boxes per line will be
[0, 1, 2, 5].
As you can see, property extraction/application is lossless for tables that are 4x4 or smaller
(and in fact has a bit of redundnacy). For larger tables, we lose any individual cell formatting
for the range [(3,rows - 1) -> (3, cols - 1)]. That formatting is replaced by formatting from
the saved cells:
0 1 2 3 4 5
+-----------------------------------------------------------------------+
0 | Saved | Saved | Saved | | | Saved |
+-----------------------------------------------------------------------+
1 | Saved | Saved | Saved | | | Saved |
+-----------------------------------------------------------------------+
2 | Saved | Saved | Saved | | | Saved |
+-----------------------------------------------------------------------+
3 | | | | | | |
+-----------------------------------------------------------------------+
4 | | | | | | |
+-----------------------------------------------------------------------+
5 | Saved | Saved | Saved | | | Saved |
+-----------+-----------+-----------+-----------+-----------+-----------+
The properties saved are divided into three categories:
1. Character properties: Font, font size, weight, etc.
2. Box properties: Box, cell background
3. Table properties: Properties that are set in the Table->Table Properties dialog.
Character and box properties are stored per cell (and are lossy for tables larger than 4x4). Table
properties are stored per-table, and are lossless.
*/
class SW_DLLPUBLIC SwTableAutoFormat
2000-09-18 16:15:01 +00:00
{
friend void _FinitCore(); // To destroy default pointer.
static SwBoxAutoFormat* pDfltBoxAutoFormat;
2000-09-18 16:15:01 +00:00
OUString m_aName;
sal_uInt16 nStrResId;
2011-04-25 20:33:33 +02:00
// Common flags of Calc and Writer.
bool bInclFont : 1;
bool bInclJustify : 1;
bool bInclFrame : 1;
bool bInclBackground : 1;
bool bInclValueFormat : 1;
2000-09-18 16:15:01 +00:00
2011-04-25 20:33:33 +02:00
// Calc specific flags.
bool bInclWidthHeight : 1;
2000-09-18 16:15:01 +00:00
SwBoxAutoFormat* aBoxAutoFormat[ 16 ];
2000-09-18 16:15:01 +00:00
// Writer-specific options
SvxFormatBreakItem m_aBreak;
SwFormatPageDesc m_aPageDesc;
SvxFormatKeepItem m_aKeepWithNextPara;
sal_uInt16 m_aRepeatHeading;
bool m_bLayoutSplit;
bool m_bRowSplit;
bool m_bCollapsingBorders;
SvxShadowItem m_aShadow;
2000-09-18 16:15:01 +00:00
public:
SwTableAutoFormat( const OUString& rName );
SwTableAutoFormat( const SwTableAutoFormat& rNew );
~SwTableAutoFormat();
2000-09-18 16:15:01 +00:00
SwTableAutoFormat& operator=( const SwTableAutoFormat& rNew );
2000-09-18 16:15:01 +00:00
void SetBoxFormat( const SwBoxAutoFormat& rNew, sal_uInt8 nPos );
const SwBoxAutoFormat& GetBoxFormat( sal_uInt8 nPos ) const;
2000-09-18 16:15:01 +00:00
void SetName( const OUString& rNew ) { m_aName = rNew; nStrResId = USHRT_MAX; }
OUString GetName() const { return m_aName; }
2000-09-18 16:15:01 +00:00
enum UpdateFlags { UPDATE_CHAR = 1, UPDATE_BOX = 2, UPDATE_ALL = 3 };
void UpdateFromSet( sal_uInt8 nPos, const SfxItemSet& rSet,
2000-09-18 16:15:01 +00:00
UpdateFlags eFlags, SvNumberFormatter* );
void UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet, UpdateFlags eFlags,
2000-09-18 16:15:01 +00:00
SvNumberFormatter* ) const ;
void RestoreTableProperties(SwTable &table) const;
void StoreTableProperties(const SwTable &table);
bool IsFont() const { return bInclFont; }
bool IsJustify() const { return bInclJustify; }
bool IsFrame() const { return bInclFrame; }
bool IsBackground() const { return bInclBackground; }
bool IsValueFormat() const { return bInclValueFormat; }
void SetFont( const bool bNew ) { bInclFont = bNew; }
void SetJustify( const bool bNew ) { bInclJustify = bNew; }
void SetFrame( const bool bNew ) { bInclFrame = bNew; }
void SetBackground( const bool bNew ) { bInclBackground = bNew; }
void SetValueFormat( const bool bNew ) { bInclValueFormat = bNew; }
void SetWidthHeight( const bool bNew ) { bInclWidthHeight = bNew; }
bool Load( SvStream& rStream, const SwAfVersions& );
bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
2000-09-18 16:15:01 +00:00
};
class SW_DLLPUBLIC SwTableAutoFormatTable
2000-09-18 16:15:01 +00:00
{
struct Impl;
::boost::scoped_ptr<Impl> m_pImpl;
SAL_DLLPRIVATE bool Load( SvStream& rStream );
SAL_DLLPRIVATE bool Save( SvStream& rStream ) const;
2000-09-18 16:15:01 +00:00
public:
explicit SwTableAutoFormatTable();
~SwTableAutoFormatTable();
size_t size() const;
SwTableAutoFormat const& operator[](size_t i) const;
SwTableAutoFormat & operator[](size_t i);
void InsertAutoFormat(size_t i, SwTableAutoFormat * pFormat);
void EraseAutoFormat(size_t i);
SwTableAutoFormat* ReleaseAutoFormat(size_t i);
2000-09-18 16:15:01 +00:00
bool Load();
bool Save() const;
2000-09-18 16:15:01 +00:00
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */