30 #include <com/sun/star/text/VertOrientation.hpp>
43 #include <osl/diagnose.h>
44 #include <osl/thread.h>
74 using ::editeng::SvxBorderLine;
107 sal_uInt64 BeginSwBlock(
SvStream& rStream)
118 sal_uInt64 whereToWriteEndOfSwBlock = rStream.
Tell();
122 return whereToWriteEndOfSwBlock;
127 void EndSwBlock(
SvStream& rStream, sal_uInt64 whereToWriteEndOfSwBlock)
129 sal_uInt64 endOfSwBlock = rStream.
Tell();
130 rStream.
Seek(whereToWriteEndOfSwBlock);
132 rStream.
Seek(endOfSwBlock);
141 class WriterSpecificAutoFormatBlock
144 explicit WriterSpecificAutoFormatBlock(
SvStream& rStream)
146 , mnWhereToWriteEndOfBlock(BeginSwBlock(rStream))
150 ~WriterSpecificAutoFormatBlock() { EndSwBlock(mrStream, mnWhereToWriteEndOfBlock); }
153 WriterSpecificAutoFormatBlock(WriterSpecificAutoFormatBlock
const&) =
delete;
154 WriterSpecificAutoFormatBlock& operator=(WriterSpecificAutoFormatBlock
const&) =
delete;
157 sal_uInt64 mnWhereToWriteEndOfBlock;
163 sal_uInt64 endOfSwBlock = 0;
167 return endOfSwBlock - stream.
Tell();
181 static void Write(
SvStream& rStream, sal_uInt16 fileVersion);
185 : m_nTextOrientationVersion(0),
186 m_nVerticalAlignmentVersion(0)
207 WriterSpecificAutoFormatBlock block(rStream);
246 m_aTLBR = std::make_unique<SvxLineItem>(0 );
247 m_aBLTR = std::make_unique<SvxLineItem>(0 );
250 m_aHorJustify = std::make_unique<SvxHorJustifyItem>(SvxCellHorJustify::Standard, 0);
251 m_aVerJustify = std::make_unique<SvxVerJustifyItem>(SvxCellVerJustify::Standard, 0);
252 m_aStacked = std::make_unique<SfxBoolItem>(0 );
261 m_aBox->SetAllDistances(55);
266 m_aTextOrientation(rNew.m_aTextOrientation->
Clone()),
267 m_aVerticalAlignment(rNew.m_aVerticalAlignment->
Clone()),
268 m_sNumFormatString( rNew.m_sNumFormatString ),
269 m_eSysLanguage( rNew.m_eSysLanguage ),
270 m_eNumFormatLanguage( rNew.m_eNumFormatLanguage )
314 sal_Int64
const nSize(WriterSpecificBlockExists(rStream));
315 if (0 < nSize && nSize < std::numeric_limits<sal_uInt16>::max())
327 sal_uInt16 eSys, eLge;
347 WriterSpecificAutoFormatBlock block(rStream);
357 RTL_TEXTENCODING_UTF8);
365 , m_nStrResId( USHRT_MAX )
367 , m_aRepeatHeading( 0 )
368 , m_bLayoutSplit( true )
369 , m_bRowSplit( true )
370 , m_bCollapsingBorders(true)
373 , m_bUserDefined( true )
439 OSL_ENSURE( nPos < 16,
"wrong area" );
450 OSL_ENSURE( nPos < 16,
"wrong area" );
466 SAL_WARN_IF(!(nPos < 16),
"sw.core",
"GetBoxFormat wrong area");
492 OSL_ENSURE( nPos < 16,
"wrong area" );
537 nullptr != (pNumFormat = pNFormatr->
GetEntry( pNumFormatItem->
GetValue() )) )
613 if ( bSingleRowTable || bSingleColTable )
616 if ( !bSingleRowTable )
617 nSingleRowOrColumnId = nPos + 3;
618 else if ( !bSingleColTable )
619 nSingleRowOrColumnId = nPos + 12;
621 assert( nSingleRowOrColumnId < 16 );
623 if ( bSingleRowTable )
624 aAutoFormatBox.
SetLine( aLastAutoFormatBox.
GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM );
625 if ( bSingleColTable )
626 aAutoFormatBox.
SetLine( aLastAutoFormatBox.
GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT );
629 rSet.
Put( aAutoFormatBox );
650 if( !sFormat.isEmpty() )
656 eSys, nType, bNew, nCheckPos);
782 bRet = pFormat->
Load( rStream, rVersions, nVal );
801 RTL_TEXTENCODING_UTF8 );
811 WriterSpecificAutoFormatBlock block(rStream);
822 for(
int i = 0; bRet &&
i < 16; ++i )
832 bRet = pFormat->
Save( rStream, fileVersion );
840 for (; nIndex < 16; ++nIndex)
848 for (
size_t i=0;
i < aTableTemplateMap.size(); ++
i)
850 if (aTableTemplateMap[
i] == nIndex)
851 return "." + OUString::number(
i + 1);
879 static std::vector<sal_Int32>
const aTableTemplateMap
898 return aTableTemplateMap;
905 !nRow ? 0 : ((nRow + 1 == nRows) ? 12 : (4 * (1 + ((nRow - 1) & 1)))));
907 +
static_cast<sal_uInt8>(!nCol ? 0 : (nCol + 1 == nCols ? 3 : (1 + ((nCol - 1) & 1))));
918 return m_pImpl->m_AutoFormats.size();
923 return *
m_pImpl->m_AutoFormats[i];
927 return *
m_pImpl->m_AutoFormats[i];
941 m_pImpl->m_AutoFormats.insert(
m_pImpl->m_AutoFormats.begin() + i, std::move(pFormat));
951 auto iter = std::find_if(
m_pImpl->m_AutoFormats.begin(),
m_pImpl->m_AutoFormats.end(),
952 [&rName](
const std::unique_ptr<SwTableAutoFormat>& rpFormat) {
return rpFormat->GetName() == rName; });
953 if (iter !=
m_pImpl->m_AutoFormats.end())
955 m_pImpl->m_AutoFormats.erase(iter);
958 SAL_INFO(
"sw.core",
"SwTableAutoFormatTable::EraseAutoFormat, SwTableAutoFormat with given name not found");
963 auto const iter(
m_pImpl->m_AutoFormats.begin() + i);
964 std::unique_ptr<SwTableAutoFormat> pRet(std::move(*iter));
965 m_pImpl->m_AutoFormats.erase(iter);
971 std::unique_ptr<SwTableAutoFormat> pRet;
972 auto iter = std::find_if(
m_pImpl->m_AutoFormats.begin(),
m_pImpl->m_AutoFormats.end(),
973 [&rName](
const std::unique_ptr<SwTableAutoFormat>& rpFormat) {
return rpFormat->GetName() == rName; });
974 if (iter !=
m_pImpl->m_AutoFormats.end())
976 pRet = std::move(*iter);
977 m_pImpl->m_AutoFormats.erase(iter);
984 for (
const auto &rFormat :
m_pImpl->m_AutoFormats)
986 if (rFormat->GetName() == rName)
987 return rFormat.get();
1010 aBox.
SetLine( &aLn, SvxBoxItemLine::LEFT );
1011 aBox.
SetLine( &aLn, SvxBoxItemLine::BOTTOM );
1013 for( i = 0; i <= 15; ++i )
1015 aBox.
SetLine( i <= 3 ? &aLn :
nullptr, SvxBoxItemLine::TOP );
1016 aBox.
SetLine( (3 == ( i & 3 )) ? &aLn :
nullptr, SvxBoxItemLine::RIGHT );
1017 pNew->GetBoxFormat( i ).SetBox( aBox );
1020 pNew->SetUserDefined(
false);
1021 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1032 SfxMedium aStream( sNm, StreamMode::STD_READ );
1043 SfxMedium aStream(sNm, StreamMode::STD_WRITE );
1044 return Save( *aStream.GetOutStream() ) && aStream.Commit();
1053 sal_uInt16 nVal = 0;
1072 if( rStream.
Tell() != nPos + nCnt )
1074 OSL_ENSURE(
false,
"The Header contains more or newer Data" );
1075 rStream.
Seek( nPos + nCnt );
1084 aVersions.
Load( rStream, nVal );
1092 const size_t nMinRecordSize =
sizeof(sal_uInt16);
1093 const size_t nMaxRecords = rStream.
remainingSize() / nMinRecordSize;
1094 if (nCount > nMaxRecords)
1096 SAL_WARN(
"sw.core",
"Parsing error: " << nMaxRecords <<
1097 " max possible entries, but " << nCount <<
" claimed, truncating");
1098 nCount = nMaxRecords;
1100 for (sal_uInt16
i = 0;
i < nCount; ++
i)
1102 std::unique_ptr<SwTableAutoFormat> pNew(
1104 bRet = pNew->Load( rStream, aVersions );
1107 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1147 for (
size_t i = 1; bRet &&
i <
m_pImpl->m_AutoFormats.size(); ++
i)
1181 m_aCellStyles.emplace_back(sName, std::make_unique<SwBoxAutoFormat>(rBoxFormat));
1187 [&sName](
const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rStyle) {
return rStyle.first == sName; });
1193 SAL_INFO(
"sw.core",
"SwCellStyleTable::RemoveBoxFormat, format with given name doesn't exists");
1223 SAL_INFO(
"sw.core",
"SwCellStyleTable::ChangeBoxName, box with given name already exists");
1235 SAL_INFO(
"sw.core",
"SwCellStyleTable::ChangeBoxName, box with given name not found");
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
SvStream & WriteBool(bool b)
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
bool SearchFile(OUString &rIniFile, Paths ePath=Paths::UserConfig)
static const sal_Int16 VeryThin
SvStream & WriteUInt64(sal_uInt64 nuInt64)
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
void Create(SvxFrameDirectionItem &rItem, SvStream &rStrm, sal_uInt16)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & Store(const SvxShadowItem &rItem, SvStream &rStrm, sal_uInt16)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
void RemoveBoxFormat(const OUString &sName)
std::vector< std::pair< OUString, std::unique_ptr< SwBoxAutoFormat > > > m_aCellStyles
void SetRowSplit(const SwCursor &rCursor, const SwFormatRowSplit &rNew)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
const sal_uInt16 AUTOFORMAT_DATA_ID_504
SvStream & ReadCharAsBool(bool &rBool)
void Create(SvxShadowItem &rItem, SvStream &rStrm, sal_uInt16)
SvStream & Store(const SvxFrameDirectionItem &rItem, SvStream &rStrm, sal_uInt16)
sal_uInt64 Seek(sal_uInt64 nPos)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
const sal_uInt16 AUTOFORMAT_ID_X
sal_uInt16 GetRowsToRepeat() const
std::shared_ptr< T > make_shared(Args &&...args)
const sal_uInt16 AUTOFORMAT_DATA_ID
static void Write(SvStream &rStream, sal_uInt16 fileVersion)
SvStream & ReadUInt64(sal_uInt64 &rUInt64)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
SwTableFormat * GetFrameFormat()
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
void ChangeBoxFormatName(std::u16string_view sFromName, const OUString &sToName)
const sal_uInt16 AUTOFORMAT_DATA_ID_X
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
void Load(SvStream &rStream, sal_uInt16 nVer)
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
const editeng::SvxBorderLine * GetLine(SvxBoxItemLine nLine) const
void SetAllDistances(sal_uInt16 nNew)
sal_uInt64 remainingSize()
rtl_TextEncoding GetStoreCharSet(rtl_TextEncoding eEncoding)
const OUString & GetStyleName() const
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
SwTableAutoFormatUpdateFlags
exports com.sun.star. text
const Color & GetColor() const
const sal_uInt16 AUTOFORMAT_ID_504
In follow-up versions these IDs' values need to increase.
const sal_uInt16 AUTOFORMAT_DATA_ID_552
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SwBoxAutoFormat * GetBoxFormat(std::u16string_view sName) const
If found returns a ptr to a BoxFormat. If not found returns nullptr.
const OUString & GetUserConfigPath() const
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
SwEditShell const * GetEditShell() const
const sal_uInt16 AUTOFORMAT_ID
sal_uInt16 GetVersion(sal_uInt16)
constexpr TypedWhichId< SvxShadowedItem > RES_CHRATR_SHADOWED(13)
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(124)
SvStream & ReadUChar(unsigned char &rChar)
constexpr TypedWhichId< SvxOverlineItem > RES_CHRATR_OVERLINE(38)
void SetVersion(sal_Int32 n)
const sal_uInt16 AUTOFORMAT_ID_31005
static std::unique_ptr< SwFormatRowSplit > GetRowSplit(const SwCursor &rCursor)
SwTable is one table in the document model, containing rows (which contain cells).
Reference< XOutputStream > stream
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
const sal_uInt16 AUTOFORMAT_FILE_VERSION
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 m_nTextOrientationVersion
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
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 >)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define SAL_WARN_IF(condition, area, stream)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
#define SAL_INFO(area, stream)
SvStream & WriteUChar(unsigned char nChar)
LanguageType GetAppLanguage()
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
SwCellStyleDescriptor operator[](size_t i) const
rtl_TextEncoding GetStreamCharSet() const
const sal_uInt16 AUTOFORMAT_DATA_ID_31005
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
OUString GetBoxFormatName(const SwBoxAutoFormat &rBoxFormat) const
If found returns its name. If not found returns an empty OUString.
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const sal_uInt16 AUTOFORMAT_ID_680DR25
void AddBoxFormat(const SwBoxAutoFormat &rBoxFormat, const OUString &sName)
Add a copy of rBoxFormat.
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
const sal_uInt16 AUTOFORMAT_ID_358
sal_uInt32 GetValue() const
#define SAL_WARN(area, stream)
constexpr OUStringLiteral first
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr OUStringLiteral AUTOTABLE_FORMAT_NAME
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
sal_uInt16 m_nVerticalAlignmentVersion
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(107)
const SwAttrPool & GetAttrPool() const
bool m_bDetectedRangeSegmentation false
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
constexpr TypedWhichId< SvxContourItem > RES_CHRATR_CONTOUR(4)