30#include <com/sun/star/text/VertOrientation.hpp>
43#include <osl/diagnose.h>
44#include <osl/thread.h>
76using ::editeng::SvxBorderLine;
109 sal_uInt64 BeginSwBlock(
SvStream& rStream)
120 sal_uInt64 whereToWriteEndOfSwBlock = rStream.
Tell();
124 return whereToWriteEndOfSwBlock;
129 void EndSwBlock(
SvStream& rStream, sal_uInt64 whereToWriteEndOfSwBlock)
131 sal_uInt64 endOfSwBlock = rStream.
Tell();
132 rStream.
Seek(whereToWriteEndOfSwBlock);
134 rStream.
Seek(endOfSwBlock);
143 class WriterSpecificAutoFormatBlock
146 explicit WriterSpecificAutoFormatBlock(
SvStream& rStream)
148 , mnWhereToWriteEndOfBlock(BeginSwBlock(rStream))
152 ~WriterSpecificAutoFormatBlock() { EndSwBlock(mrStream, mnWhereToWriteEndOfBlock); }
155 WriterSpecificAutoFormatBlock(WriterSpecificAutoFormatBlock
const&) =
delete;
156 WriterSpecificAutoFormatBlock& operator=(WriterSpecificAutoFormatBlock
const&) =
delete;
159 sal_uInt64 mnWhereToWriteEndOfBlock;
165 sal_uInt64 endOfSwBlock = 0;
166 stream.ReadUInt64( endOfSwBlock );
169 return endOfSwBlock -
stream.Tell();
183 static void Write(
SvStream& rStream, sal_uInt16 fileVersion);
187: m_nTextOrientationVersion(0),
188 m_nVerticalAlignmentVersion(0)
209 WriterSpecificAutoFormatBlock block(rStream);
248 m_aTLBR = std::make_unique<SvxLineItem>(0 );
249 m_aBLTR = std::make_unique<SvxLineItem>(0 );
252 m_aHorJustify = std::make_unique<SvxHorJustifyItem>(SvxCellHorJustify::Standard, 0);
253 m_aVerJustify = std::make_unique<SvxVerJustifyItem>(SvxCellVerJustify::Standard, 0);
254 m_aStacked = std::make_unique<SfxBoolItem>(0 );
263 m_aBox->SetAllDistances(55);
268 m_aTextOrientation(rNew.m_aTextOrientation->
Clone()),
269 m_aVerticalAlignment(rNew.m_aVerticalAlignment->
Clone()),
270 m_sNumFormatString( rNew.m_sNumFormatString ),
271 m_eSysLanguage( rNew.m_eSysLanguage ),
272 m_eNumFormatLanguage( rNew.m_eNumFormatLanguage )
316 sal_Int64
const nSize(WriterSpecificBlockExists(rStream));
317 if (0 < nSize && nSize < std::numeric_limits<sal_uInt16>::max())
329 sal_uInt16 eSys, eLge;
349 WriterSpecificAutoFormatBlock block(rStream);
359 RTL_TEXTENCODING_UTF8);
372 , m_nStrResId( USHRT_MAX )
374 , m_aRepeatHeading( 0 )
375 , m_bLayoutSplit( true )
376 , m_bRowSplit( true )
377 , m_bCollapsingBorders(true)
380 , m_bUserDefined( true )
446 OSL_ENSURE(
nPos < 16,
"wrong area" );
457 OSL_ENSURE(
nPos < 16,
"wrong area" );
499 OSL_ENSURE(
nPos < 16,
"wrong area" );
544 nullptr != (pNumFormat = pNFormatr->
GetEntry( pNumFormatItem->
GetValue() )) )
620 if ( bSingleRowTable || bSingleColTable )
623 if ( !bSingleRowTable )
624 nSingleRowOrColumnId =
nPos + 3;
625 else if ( !bSingleColTable )
626 nSingleRowOrColumnId =
nPos + 12;
628 assert( nSingleRowOrColumnId < 16 );
630 if ( bSingleRowTable )
631 aAutoFormatBox.
SetLine( aLastAutoFormatBox.
GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM );
632 if ( bSingleColTable )
633 aAutoFormatBox.
SetLine( aLastAutoFormatBox.
GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT );
657 if( !sFormat.isEmpty() )
663 eSys,
nType, bNew, nCheckPos);
796 bRet = pFormat->
Load( rStream, rVersions, nVal );
815 RTL_TEXTENCODING_UTF8 );
825 WriterSpecificAutoFormatBlock block(rStream);
836 for(
int i = 0; bRet &&
i < 16; ++
i )
846 bRet = pFormat->
Save( rStream, fileVersion );
862 for (
size_t i=0;
i < aTableTemplateMap.size(); ++
i)
864 if (aTableTemplateMap[
i] ==
nIndex)
865 return "." + OUString::number(
i + 1);
893 static std::vector<sal_Int32>
const aTableTemplateMap
912 return aTableTemplateMap;
919 !nRow ? 0 : ((nRow + 1 == nRows) ? 12 : (4 * (1 + ((nRow - 1) & 1)))));
921 +
static_cast<sal_uInt8>(!nCol ? 0 : (nCol + 1 == nCols ? 3 : (1 + ((nCol - 1) & 1))));
937 return m_pImpl->m_AutoFormats.size();
960 m_pImpl->m_AutoFormats.insert(
m_pImpl->m_AutoFormats.begin() +
i, std::move(pFormat));
970 auto iter = std::find_if(
m_pImpl->m_AutoFormats.begin(),
m_pImpl->m_AutoFormats.end(),
971 [&rName](
const std::unique_ptr<SwTableAutoFormat>& rpFormat) { return rpFormat->GetName() == rName; });
972 if (iter !=
m_pImpl->m_AutoFormats.end())
974 m_pImpl->m_AutoFormats.erase(iter);
977 SAL_INFO(
"sw.core",
"SwTableAutoFormatTable::EraseAutoFormat, SwTableAutoFormat with given name not found");
982 auto const iter(
m_pImpl->m_AutoFormats.begin() +
i);
983 std::unique_ptr<SwTableAutoFormat> pRet(std::move(*iter));
984 m_pImpl->m_AutoFormats.erase(iter);
990 std::unique_ptr<SwTableAutoFormat> pRet;
991 auto iter = std::find_if(
m_pImpl->m_AutoFormats.begin(),
m_pImpl->m_AutoFormats.end(),
992 [&rName](
const std::unique_ptr<SwTableAutoFormat>& rpFormat) { return rpFormat->GetName() == rName; });
993 if (iter !=
m_pImpl->m_AutoFormats.end())
995 pRet = std::move(*iter);
996 m_pImpl->m_AutoFormats.erase(iter);
1003 for (
const auto &rFormat :
m_pImpl->m_AutoFormats)
1005 if (rFormat->GetName() == rName)
1006 return rFormat.get();
1029 aBox.
SetLine( &aLn, SvxBoxItemLine::LEFT );
1030 aBox.
SetLine( &aLn, SvxBoxItemLine::BOTTOM );
1032 for(
i = 0;
i <= 15; ++
i )
1034 aBox.
SetLine(
i <= 3 ? &aLn :
nullptr, SvxBoxItemLine::TOP );
1035 aBox.
SetLine( (3 == (
i & 3 )) ? &aLn :
nullptr, SvxBoxItemLine::RIGHT );
1036 pNew->GetBoxFormat(
i ).SetBox( aBox );
1039 pNew->SetUserDefined(
false);
1040 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1051 SfxMedium aStream( sNm, StreamMode::STD_READ );
1062 SfxMedium aStream(sNm, StreamMode::STD_WRITE );
1072 sal_uInt16 nVal = 0;
1091 if( rStream.
Tell() !=
nPos + nCnt )
1093 OSL_ENSURE(
false,
"The Header contains more or newer Data" );
1103 aVersions.
Load( rStream, nVal );
1111 const size_t nMinRecordSize =
sizeof(sal_uInt16);
1112 const size_t nMaxRecords = rStream.
remainingSize() / nMinRecordSize;
1113 if (
nCount > nMaxRecords)
1115 SAL_WARN(
"sw.core",
"Parsing error: " << nMaxRecords <<
1116 " max possible entries, but " <<
nCount <<
" claimed, truncating");
1121 std::unique_ptr<SwTableAutoFormat> pNew(
1123 bRet = pNew->Load( rStream, aVersions );
1126 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1166 for (
size_t i = 1; bRet &&
i <
m_pImpl->m_AutoFormats.size(); ++
i)
1206 [&
sName](
const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rStyle) { return rStyle.first == sName; });
1212 SAL_INFO(
"sw.core",
"SwCellStyleTable::RemoveBoxFormat, format with given name doesn't exists");
1242 SAL_INFO(
"sw.core",
"SwCellStyleTable::ChangeBoxName, box with given name already exists");
1254 SAL_INFO(
"sw.core",
"SwCellStyleTable::ChangeBoxName, box with given name not found");
sal_uInt32 GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SvStream * GetOutStream()
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
SvStream & ReadCharAsBool(bool &rBool)
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
SvStream & WriteBool(bool b)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt64(sal_uInt64 nuInt64)
void SetVersion(sal_Int32 n)
sal_uInt64 Seek(sal_uInt64 nPos)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
rtl_TextEncoding GetStreamCharSet() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
SvStream & ReadUChar(unsigned char &rChar)
bool SearchFile(OUString &rIniFile, Paths ePath=Paths::UserConfig)
const OUString & GetUserConfigPath() const
static const sal_Int16 VeryThin
const editeng::SvxBorderLine * GetLine(SvxBoxItemLine nLine) const
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
void SetAllDistances(sal_Int16 nNew)
const Color & GetColor() const
const OUString & GetStyleName() const
OUString GetBoxFormatName(const SwBoxAutoFormat &rBoxFormat) const
If found returns its name. If not found returns an empty OUString.
void ChangeBoxFormatName(std::u16string_view sFromName, const OUString &sToName)
void AddBoxFormat(const SwBoxAutoFormat &rBoxFormat, const OUString &sName)
Add a copy of rBoxFormat.
SwCellStyleDescriptor operator[](size_t i) const
std::vector< std::pair< OUString, std::unique_ptr< SwBoxAutoFormat > > > m_aCellStyles
SwBoxAutoFormat * GetBoxFormat(std::u16string_view sName) const
If found returns a ptr to a BoxFormat. If not found returns nullptr.
void RemoveBoxFormat(const OUString &sName)
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
void SetRowSplit(const SwCursor &rCursor, const SwFormatRowSplit &rNew)
SwEditShell const * GetEditShell() const
static std::unique_ptr< SwFormatRowSplit > GetRowSplit(const SwCursor &rCursor)
const SwAttrPool & GetAttrPool() const
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
SwTable is one table in the document model, containing rows (which contain cells).
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
Reference< XOutputStream > stream
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(126)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(116)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
constexpr TypedWhichId< SvxShadowedItem > RES_CHRATR_SHADOWED(13)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(113)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(108)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(119)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SvxContourItem > RES_CHRATR_CONTOUR(4)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(131)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxOverlineItem > RES_CHRATR_OVERLINE(38)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
WhichRangesContainer const aTableSetRange(svl::Items< RES_FILL_ORDER, RES_FRM_SIZE, RES_LR_SPACE, RES_BREAK, RES_HORI_ORIENT, RES_HORI_ORIENT, RES_BACKGROUND, RES_SHADOW, RES_KEEP, RES_KEEP, RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, RES_FRAMEDIR, RES_FRAMEDIR, RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS, RES_FRMATR_GRABBAG, RES_FRMATR_GRABBAG, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1 >)
LanguageType GetAppLanguage()
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral first
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
void Create(SvxFrameDirectionItem &rItem, SvStream &rStrm, sal_uInt16)
SvStream & Store(const SvxFrameDirectionItem &rItem, SvStream &rStrm, sal_uInt16)
SvStream & Store(const SvxShadowItem &rItem, SvStream &rStrm, sal_uInt16)
void Create(SvxShadowItem &rItem, SvStream &rStrm, sal_uInt16)
sal_uInt16 GetVersion(sal_uInt16)
std::shared_ptr< T > make_shared(Args &&... args)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
@ RES_POOLTABLESTYLE_DEFAULT
rtl_TextEncoding GetStoreCharSet(rtl_TextEncoding eEncoding)
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)
static void Write(SvStream &rStream, sal_uInt16 fileVersion)
sal_uInt16 m_nVerticalAlignmentVersion
void Load(SvStream &rStream, sal_uInt16 nVer)
sal_uInt16 m_nTextOrientationVersion
const sal_uInt16 AUTOFORMAT_ID
const sal_uInt16 AUTOFORMAT_ID_680DR25
const sal_uInt16 AUTOFORMAT_DATA_ID_31005
const sal_uInt16 AUTOFORMAT_DATA_ID_504
const sal_uInt16 AUTOFORMAT_ID_358
constexpr OUStringLiteral AUTOTABLE_FORMAT_NAME
const sal_uInt16 AUTOFORMAT_ID_504
In follow-up versions these IDs' values need to increase.
const sal_uInt16 AUTOFORMAT_FILE_VERSION
const sal_uInt16 AUTOFORMAT_ID_X
const sal_uInt16 AUTOFORMAT_DATA_ID_552
const sal_uInt16 AUTOFORMAT_DATA_ID
const sal_uInt16 AUTOFORMAT_ID_31005
const sal_uInt16 AUTOFORMAT_DATA_ID_X
SwTableAutoFormatUpdateFlags