29 #include <com/sun/star/text/VertOrientation.hpp>
42 #include <osl/diagnose.h>
43 #include <osl/thread.h>
72 using ::editeng::SvxBorderLine;
100 #define AUTOTABLE_FORMAT_NAME "autotbl.fmt"
105 sal_uInt64 BeginSwBlock(
SvStream& rStream)
116 sal_uInt64 whereToWriteEndOfSwBlock = rStream.
Tell();
120 return whereToWriteEndOfSwBlock;
125 void EndSwBlock(
SvStream& rStream, sal_uInt64 whereToWriteEndOfSwBlock)
127 sal_uInt64 endOfSwBlock = rStream.
Tell();
128 rStream.
Seek(whereToWriteEndOfSwBlock);
130 rStream.
Seek(endOfSwBlock);
139 class WriterSpecificAutoFormatBlock
142 explicit WriterSpecificAutoFormatBlock(
SvStream& rStream)
144 , mnWhereToWriteEndOfBlock(BeginSwBlock(rStream))
148 ~WriterSpecificAutoFormatBlock() { EndSwBlock(mrStream, mnWhereToWriteEndOfBlock); }
151 WriterSpecificAutoFormatBlock(WriterSpecificAutoFormatBlock
const&) =
delete;
152 WriterSpecificAutoFormatBlock& operator=(WriterSpecificAutoFormatBlock
const&) =
delete;
155 sal_uInt64 mnWhereToWriteEndOfBlock;
161 sal_uInt64 endOfSwBlock = 0;
165 return endOfSwBlock - stream.
Tell();
179 static void Write(
SvStream& rStream, sal_uInt16 fileVersion);
184 m_nTextOrientationVersion(0),
185 m_nVerticalAlignmentVersion(0)
206 WriterSpecificAutoFormatBlock block(rStream);
221 m_sNumFormatString(),
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 );
255 m_aMargin = std::make_unique<SvxMarginItem>(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 ),
317 sal_Int64
const nSize(WriterSpecificBlockExists(rStream));
318 if (0 < nSize && nSize < std::numeric_limits<sal_uInt16>::max())
330 sal_uInt16 eSys, eLge;
350 WriterSpecificAutoFormatBlock block(rStream);
360 RTL_TEXTENCODING_UTF8);
371 , m_aRepeatHeading( 0 )
372 , m_bLayoutSplit( true )
373 , m_bRowSplit( true )
374 , m_bCollapsingBorders(true)
377 , m_bUserDefined( true )
389 , m_aKeepWithNextPara()
447 OSL_ENSURE( nPos < 16,
"wrong area" );
458 OSL_ENSURE( nPos < 16,
"wrong area" );
474 SAL_WARN_IF(!(nPos < 16),
"sw.core",
"GetBoxFormat wrong area");
500 OSL_ENSURE( nPos < 16,
"wrong area" );
545 reinterpret_cast<const SfxPoolItem**>(&pNumFormatItem) ) && pNFormatr &&
546 nullptr != (pNumFormat = pNFormatr->
GetEntry( pNumFormatItem->
GetValue() )) )
622 if ( bSingleRowTable || bSingleColTable )
625 if ( !bSingleRowTable )
626 nSingleRowOrColumnId = nPos + 3;
627 else if ( !bSingleColTable )
628 nSingleRowOrColumnId = nPos + 12;
630 assert( nSingleRowOrColumnId < 16 );
632 if ( bSingleRowTable )
633 aAutoFormatBox.
SetLine( aLastAutoFormatBox.
GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM );
634 if ( bSingleColTable )
635 aAutoFormatBox.
SetLine( aLastAutoFormatBox.
GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT );
638 rSet.
Put( aAutoFormatBox );
659 if( !sFormat.isEmpty() )
665 eSys, nType, bNew, nCheckPos);
686 if (
m_aBreak->GetBreak() != SvxBreak::NONE )
795 bRet = pFormat->
Load( rStream, rVersions, nVal );
814 RTL_TEXTENCODING_UTF8 );
824 WriterSpecificAutoFormatBlock block(rStream);
835 for(
int i = 0; bRet &&
i < 16; ++i )
845 bRet = pFormat->
Save( rStream, fileVersion );
853 for (; nIndex < 16; ++nIndex)
861 for (
size_t i=0;
i < aTableTemplateMap.size(); ++
i)
863 if (aTableTemplateMap[
i] == nIndex)
864 return "." + OUString::number(
i + 1);
892 static std::vector<sal_Int32>
const aTableTemplateMap
911 return aTableTemplateMap;
918 !nRow ? 0 : ((nRow + 1 == nRows) ? 12 : (4 * (1 + ((nRow - 1) & 1)))));
920 +
static_cast<sal_uInt8>(!nCol ? 0 : (nCol + 1 == nCols ? 3 : (1 + ((nCol - 1) & 1))));
931 return m_pImpl->m_AutoFormats.size();
936 return *
m_pImpl->m_AutoFormats[i];
940 return *
m_pImpl->m_AutoFormats[i];
954 m_pImpl->m_AutoFormats.insert(
m_pImpl->m_AutoFormats.begin() + i, std::move(pFormat));
964 auto iter = std::find_if(
m_pImpl->m_AutoFormats.begin(),
m_pImpl->m_AutoFormats.end(),
965 [&rName](
const std::unique_ptr<SwTableAutoFormat>& rpFormat) {
return rpFormat->GetName() == rName; });
966 if (iter !=
m_pImpl->m_AutoFormats.end())
968 m_pImpl->m_AutoFormats.erase(iter);
971 SAL_INFO(
"sw.core",
"SwTableAutoFormatTable::EraseAutoFormat, SwTableAutoFormat with given name not found");
976 auto const iter(
m_pImpl->m_AutoFormats.begin() + i);
977 std::unique_ptr<SwTableAutoFormat> pRet(std::move(*iter));
978 m_pImpl->m_AutoFormats.erase(iter);
984 std::unique_ptr<SwTableAutoFormat> pRet;
985 auto iter = std::find_if(
m_pImpl->m_AutoFormats.begin(),
m_pImpl->m_AutoFormats.end(),
986 [&rName](
const std::unique_ptr<SwTableAutoFormat>& rpFormat) {
return rpFormat->GetName() == rName; });
987 if (iter !=
m_pImpl->m_AutoFormats.end())
989 pRet = std::move(*iter);
990 m_pImpl->m_AutoFormats.erase(iter);
997 for (
const auto &rFormat :
m_pImpl->m_AutoFormats)
999 if (rFormat->GetName() == rName)
1000 return rFormat.get();
1023 aBox.
SetLine( &aLn, SvxBoxItemLine::LEFT );
1024 aBox.
SetLine( &aLn, SvxBoxItemLine::BOTTOM );
1026 for( i = 0; i <= 15; ++i )
1028 aBox.
SetLine( i <= 3 ? &aLn :
nullptr, SvxBoxItemLine::TOP );
1029 aBox.
SetLine( (3 == ( i & 3 )) ? &aLn :
nullptr, SvxBoxItemLine::RIGHT );
1030 pNew->GetBoxFormat( i ).SetBox( aBox );
1033 pNew->SetUserDefined(
false);
1034 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1045 SfxMedium aStream( sNm, StreamMode::STD_READ );
1056 SfxMedium aStream(sNm, StreamMode::STD_WRITE );
1057 return Save( *aStream.GetOutStream() ) && aStream.Commit();
1066 sal_uInt16 nVal = 0;
1087 OSL_ENSURE(
false,
"The Header contains more or newer Data" );
1088 rStream.
Seek( nPos + nCnt );
1097 aVersions.
Load( rStream, nVal );
1105 const size_t nMinRecordSize =
sizeof(sal_uInt16);
1106 const size_t nMaxRecords = rStream.
remainingSize() / nMinRecordSize;
1107 if (nCount > nMaxRecords)
1109 SAL_WARN(
"sw.core",
"Parsing error: " << nMaxRecords <<
1110 " max possible entries, but " << nCount <<
" claimed, truncating");
1111 nCount = nMaxRecords;
1113 for (sal_uInt16
i = 0;
i < nCount; ++
i)
1115 std::unique_ptr<SwTableAutoFormat> pNew(
1117 bRet = pNew->Load( rStream, aVersions );
1120 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1160 for (
size_t i = 1; bRet &&
i <
m_pImpl->m_AutoFormats.size(); ++
i)
1194 m_aCellStyles.emplace_back(sName, std::make_unique<SwBoxAutoFormat>(rBoxFormat));
1200 [&sName](
const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rStyle) {
return rStyle.first == sName; });
1206 SAL_INFO(
"sw.core",
"SwCellStyleTable::RemoveBoxFormat, format with given name doesn't exists");
1236 SAL_INFO(
"sw.core",
"SwCellStyleTable::ChangeBoxName, box with given name already exists");
1248 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< SwFormatPageDesc > RES_PAGEDESC(93)
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
bool SearchFile(OUString &rIniFile, Paths ePath=Paths::UserConfig)
SvStream & WriteUInt64(sal_uInt64 nuInt64)
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
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.
#define AUTOTABLE_FORMAT_NAME
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 BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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
sal_uInt16 const aTableSetRange[]
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
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) 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)
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)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
#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 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
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
constexpr TypedWhichId< SvxContourItem > RES_CHRATR_CONTOUR(4)