LibreOffice Module sw (master) 1
tblafmt.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <tools/stream.hxx>
22#include <sfx2/docfile.hxx>
23#include <svl/numformat.hxx>
24#include <svl/zforlist.hxx>
25#include <svl/zformat.hxx>
28#include <swtable.hxx>
29#include <swtblfmt.hxx>
30#include <com/sun/star/text/VertOrientation.hpp>
31#include <swtypes.hxx>
32#include <doc.hxx>
33#include <poolfmt.hxx>
34#include <tblafmt.hxx>
35#include <cellatr.hxx>
36#include <SwStyleNameMapper.hxx>
37#include <hintids.hxx>
38#include <fmtornt.hxx>
39#include <editsh.hxx>
40#include <fmtlsplt.hxx>
41#include <fmtrowsplt.hxx>
42#include <sal/log.hxx>
43#include <osl/diagnose.h>
44#include <osl/thread.h>
45
47#include <editeng/boxitem.hxx>
48#include <editeng/brushitem.hxx>
49#include <editeng/colritem.hxx>
52#include <editeng/fontitem.hxx>
54#include <editeng/fhgtitem.hxx>
57#include <editeng/lineitem.hxx>
58#include <editeng/postitem.hxx>
59#include <editeng/shdditem.hxx>
60#include <editeng/udlnitem.hxx>
61#include <editeng/wghtitem.hxx>
62#include <svx/algitem.hxx>
63#include <svx/rotmodit.hxx>
64#include <legacyitem.hxx>
65
66#include <memory>
67#include <utility>
68#include <vector>
69
70/*
71 * XXX: BIG RED NOTICE! Changes MUST be binary file format compatible and MUST
72 * be synchronized with Calc's ScAutoFormat sc/source/core/tool/autoform.cxx
73 */
74
75using ::editeng::SvxBorderLine;
76
77// until SO5PF
78const sal_uInt16 AUTOFORMAT_ID_X = 9501;
79const sal_uInt16 AUTOFORMAT_ID_358 = 9601;
80const sal_uInt16 AUTOFORMAT_DATA_ID_X = 9502;
81
82// from SO5
84const sal_uInt16 AUTOFORMAT_ID_504 = 9801;
85const sal_uInt16 AUTOFORMAT_DATA_ID_504 = 9802;
86
87const sal_uInt16 AUTOFORMAT_DATA_ID_552 = 9902;
88
89// --- from 680/dr25 on: store strings as UTF-8
90const sal_uInt16 AUTOFORMAT_ID_680DR25 = 10021;
91
92// --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
93const sal_uInt16 AUTOFORMAT_ID_31005 = 10041;
94const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
95
96// current version
100
102
103constexpr OUStringLiteral AUTOTABLE_FORMAT_NAME = u"autotbl.fmt";
104
105namespace
106{
108 sal_uInt64 BeginSwBlock(SvStream& rStream)
109 {
110 // We need to write down the offset of the end of the writer-specific data, so that
111 // calc can skip it. We'll only have that value after writing the data, so we
112 // write a placeholder value first, write the data, then jump back and write the
113 // real offset.
114
115 // Note that we explicitly use sal_uInt64 instead of sal_Size (which can be 32
116 // or 64 depending on platform) to ensure 64-bit portability on this front. I don't
117 // actually know if autotbl.fmt as a whole is portable, since that requires all serialization
118 // logic to be written with portability in mind.
119 sal_uInt64 whereToWriteEndOfSwBlock = rStream.Tell();
120
121 rStream.WriteUInt64( 0 ); // endOfSwBlock
122
123 return whereToWriteEndOfSwBlock;
124 }
125
128 void EndSwBlock(SvStream& rStream, sal_uInt64 whereToWriteEndOfSwBlock)
129 {
130 sal_uInt64 endOfSwBlock = rStream.Tell();
131 rStream.Seek(whereToWriteEndOfSwBlock);
132 rStream.WriteUInt64( endOfSwBlock );
133 rStream.Seek(endOfSwBlock);
134 }
135
142 class WriterSpecificAutoFormatBlock
143 {
144 public:
145 explicit WriterSpecificAutoFormatBlock(SvStream& rStream)
146 : mrStream(rStream)
147 , mnWhereToWriteEndOfBlock(BeginSwBlock(rStream))
148 {
149 }
150
151 ~WriterSpecificAutoFormatBlock() { EndSwBlock(mrStream, mnWhereToWriteEndOfBlock); }
152
153 private:
154 WriterSpecificAutoFormatBlock(WriterSpecificAutoFormatBlock const&) = delete;
155 WriterSpecificAutoFormatBlock& operator=(WriterSpecificAutoFormatBlock const&) = delete;
156
157 SvStream& mrStream;
158 sal_uInt64 mnWhereToWriteEndOfBlock;
159 };
160
162 sal_Int64 WriterSpecificBlockExists(SvStream &stream)
163 {
164 sal_uInt64 endOfSwBlock = 0;
165 stream.ReadUInt64( endOfSwBlock );
166
167 // end-of-block pointing to itself indicates a zero-size block.
168 return endOfSwBlock - stream.Tell();
169 }
170}
171
172// Struct with version numbers of the Items
173
175{
176public:
179
180 SwAfVersions();
181 void Load( SvStream& rStream, sal_uInt16 nVer );
182 static void Write(SvStream& rStream, sal_uInt16 fileVersion);
183};
184
186: m_nTextOrientationVersion(0),
187 m_nVerticalAlignmentVersion(0)
188{
189}
190
191void SwAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
192{
193 LoadBlockA(rStream, nVer);
194 if (nVer >= AUTOFORMAT_ID_31005 && WriterSpecificBlockExists(rStream))
195 {
198 }
199 LoadBlockB(rStream, nVer);
200}
201
202void SwAfVersions::Write(SvStream& rStream, sal_uInt16 fileVersion)
203{
204 AutoFormatVersions::WriteBlockA(rStream, fileVersion);
205
206 if (fileVersion >= SOFFICE_FILEFORMAT_50)
207 {
208 WriterSpecificAutoFormatBlock block(rStream);
209
211 rStream.WriteUInt16(legacy::SwFormatVert::GetVersion(fileVersion));
212 }
213
214 AutoFormatVersions::WriteBlockB(rStream, fileVersion);
215}
216
217
218
220: m_aTextOrientation(std::make_unique<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR)),
221 m_aVerticalAlignment(std::make_unique<SwFormatVertOrient>(0, css::text::VertOrientation::NONE, css::text::RelOrientation::FRAME)),
222 m_eSysLanguage(::GetAppLanguage()),
223 m_eNumFormatLanguage(::GetAppLanguage())
224{
225 // need to set default instances for base class AutoFormatBase here
226 // due to resource defines (e.g. RES_CHRATR_FONT) which are not available
227 // in svx and different in the different usages of derivations
228 m_aFont = std::make_unique<SvxFontItem>(*GetDfltAttr( RES_CHRATR_FONT ) );
229 m_aHeight = std::make_unique<SvxFontHeightItem>(240, 100, RES_CHRATR_FONTSIZE );
230 m_aWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
231 m_aPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_POSTURE );
232 m_aCJKFont = std::make_unique<SvxFontItem>(*GetDfltAttr( RES_CHRATR_CJK_FONT ) );
233 m_aCJKHeight = std::make_unique<SvxFontHeightItem>(240, 100, RES_CHRATR_CJK_FONTSIZE );
234 m_aCJKWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_CJK_WEIGHT );
235 m_aCJKPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_CJK_POSTURE );
236 m_aCTLFont = std::make_unique<SvxFontItem>(*GetDfltAttr( RES_CHRATR_CTL_FONT ) );
237 m_aCTLHeight = std::make_unique<SvxFontHeightItem>(240, 100, RES_CHRATR_CTL_FONTSIZE );
238 m_aCTLWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_CTL_WEIGHT );
239 m_aCTLPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_CTL_POSTURE );
240 m_aUnderline = std::make_unique<SvxUnderlineItem>(LINESTYLE_NONE, RES_CHRATR_UNDERLINE );
241 m_aOverline = std::make_unique<SvxOverlineItem>(LINESTYLE_NONE, RES_CHRATR_OVERLINE );
242 m_aCrossedOut = std::make_unique<SvxCrossedOutItem>(STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT );
243 m_aContour = std::make_unique<SvxContourItem>(false, RES_CHRATR_CONTOUR );
244 m_aShadowed = std::make_unique<SvxShadowedItem>(false, RES_CHRATR_SHADOWED );
245 m_aColor = std::make_unique<SvxColorItem>(RES_CHRATR_COLOR );
246 m_aBox = std::make_unique<SvxBoxItem>(RES_BOX );
247 m_aTLBR = std::make_unique<SvxLineItem>(0 );
248 m_aBLTR = std::make_unique<SvxLineItem>(0 );
249 m_aBackground = std::make_unique<SvxBrushItem>(RES_BACKGROUND );
250 m_aAdjust = std::make_unique<SvxAdjustItem>(SvxAdjust::Left, RES_PARATR_ADJUST );
251 m_aHorJustify = std::make_unique<SvxHorJustifyItem>(SvxCellHorJustify::Standard, 0);
252 m_aVerJustify = std::make_unique<SvxVerJustifyItem>(SvxCellVerJustify::Standard, 0);
253 m_aStacked = std::make_unique<SfxBoolItem>(0 );
254 m_aMargin = std::make_unique<SvxMarginItem>( TypedWhichId<SvxMarginItem>(0) );
255 m_aLinebreak = std::make_unique<SfxBoolItem>(0 );
256 m_aRotateAngle = std::make_unique<SfxInt32Item>(0 );
257 m_aRotateMode = std::make_unique<SvxRotateModeItem>(SVX_ROTATE_MODE_STANDARD, TypedWhichId<SvxRotateModeItem>(0) );
258
259// FIXME - add attribute IDs for the diagonal line items
260// aTLBR( RES_... ),
261// aBLTR( RES_... ),
262 m_aBox->SetAllDistances(55);
263}
264
266: AutoFormatBase(rNew),
267 m_aTextOrientation(rNew.m_aTextOrientation->Clone()),
268 m_aVerticalAlignment(rNew.m_aVerticalAlignment->Clone()),
269 m_sNumFormatString( rNew.m_sNumFormatString ),
270 m_eSysLanguage( rNew.m_eSysLanguage ),
271 m_eNumFormatLanguage( rNew.m_eNumFormatLanguage )
272{
273}
274
276{
277}
278
280{
281 // check self-assignment
282 if(this == &rRef)
283 {
284 return *this;
285 }
286
287 // call baseclass implementation
289
290 // copy local members - this will use ::Clone() on all involved Items
296
297 // m_wXObject used to not be copied before 1e2682235cded9a7cd90e55f0bfc60a1285e9a46
298 // "WIP: Further preparations for deeper Item changes" by this operator, so do not do it now, too
299 // rRef.SetXObject(GetXObject());
300
301 return *this;
302}
303
305{
306 return GetBackground().GetColor() == rRight.GetBackground().GetColor();
307}
308
309bool SwBoxAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer )
310{
311 LoadBlockA( rStream, rVersions, nVer );
312
313 if (nVer >= AUTOFORMAT_DATA_ID_31005)
314 {
315 sal_Int64 const nSize(WriterSpecificBlockExists(rStream));
316 if (0 < nSize && nSize < std::numeric_limits<sal_uInt16>::max())
317 {
319 // HORRIBLE HACK to read both 32-bit and 64-bit "long": abuse nSize
320 legacy::SwFormatVert::Create(*m_aVerticalAlignment, rStream, /*rVersions.m_nVerticalAlignmentVersion*/ nSize);
321 }
322 }
323
324 LoadBlockB( rStream, rVersions, nVer );
325
326 if( 0 == rVersions.nNumFormatVersion )
327 {
328 sal_uInt16 eSys, eLge;
329 // --- from 680/dr25 on: store strings as UTF-8
330 rtl_TextEncoding eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
331 m_sNumFormatString = rStream.ReadUniOrByteString( eCharSet );
332 rStream.ReadUInt16( eSys ).ReadUInt16( eLge );
335 if ( m_eSysLanguage == LANGUAGE_SYSTEM ) // from old versions (Calc)
337 }
338
339 return ERRCODE_NONE == rStream.GetError();
340}
341
342bool SwBoxAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
343{
344 SaveBlockA( rStream, fileVersion );
345
346 if (fileVersion >= SOFFICE_FILEFORMAT_50)
347 {
348 WriterSpecificAutoFormatBlock block(rStream);
349
352 }
353
354 SaveBlockB( rStream, fileVersion );
355
356 // --- from 680/dr25 on: store strings as UTF-8
358 RTL_TEXTENCODING_UTF8);
359 rStream.WriteUInt16( static_cast<sal_uInt16>(m_eSysLanguage) ).WriteUInt16( static_cast<sal_uInt16>(m_eNumFormatLanguage) );
360
361 return ERRCODE_NONE == rStream.GetError();
362}
363
365 : m_aName( std::move(aName) )
366 , m_nStrResId( USHRT_MAX )
367 , m_aKeepWithNextPara(std::make_shared<SvxFormatKeepItem>(false, RES_KEEP))
368 , m_aRepeatHeading( 0 )
369 , m_bLayoutSplit( true )
370 , m_bRowSplit( true )
371 , m_bCollapsingBorders(true)
373 , m_bHidden( false )
374 , m_bUserDefined( true )
375{
376 m_bInclFont = true;
377 m_bInclJustify = true;
378 m_bInclFrame = true;
379 m_bInclBackground = true;
380 m_bInclValueFormat = true;
381 m_bInclWidthHeight = true;
382}
383
386{
388 rp = nullptr;
389 *this = rNew;
390}
391
393{
394 if (&rNew == this)
395 return *this;
396
397 for( sal_uInt8 n = 0; n < 16; ++n )
398 {
399 if( m_aBoxAutoFormat[ n ] )
400 delete m_aBoxAutoFormat[ n ];
401
402 SwBoxAutoFormat* pFormat = rNew.m_aBoxAutoFormat[ n ];
403 if( pFormat ) // if is set -> copy
404 m_aBoxAutoFormat[ n ] = new SwBoxAutoFormat( *pFormat );
405 else // else default
406 m_aBoxAutoFormat[ n ] = nullptr;
407 }
408
409 m_aName = rNew.m_aName;
417
418 m_aKeepWithNextPara.reset(rNew.m_aKeepWithNextPara->Clone());
423 m_aShadow.reset(rNew.m_aShadow->Clone());
424 m_bHidden = rNew.m_bHidden;
426
427 return *this;
428}
429
431{
433 for( sal_uInt8 n = 0; n < 16; ++n, ++ppFormat )
434 if( *ppFormat )
435 delete *ppFormat;
436}
437
439{
440 OSL_ENSURE( nPos < 16, "wrong area" );
441
443 if( pFormat ) // if is set -> copy
444 *m_aBoxAutoFormat[ nPos ] = rNew;
445 else // else set anew
446 m_aBoxAutoFormat[ nPos ] = new SwBoxAutoFormat( rNew );
447}
448
450{
451 OSL_ENSURE( nPos < 16, "wrong area" );
452
454 if( pFormat ) // if is set -> copy
455 return *pFormat;
456 else // else return the default
457 {
458 // If it doesn't exist yet:
462 }
463}
464
466{
467 SAL_WARN_IF(!(nPos < 16), "sw.core", "GetBoxFormat wrong area");
468
469 SwBoxAutoFormat** pFormat = &m_aBoxAutoFormat[ nPos ];
470 if( !*pFormat )
471 {
472 // If default doesn't exist yet:
476 }
477 return **pFormat;
478}
479
481{
484
486}
487
489 const SfxItemSet& rSet,
491 SvNumberFormatter const * pNFormatr)
492{
493 OSL_ENSURE( nPos < 16, "wrong area" );
494
496 if( !pFormat ) // if is set -> copy
497 {
498 pFormat = new SwBoxAutoFormat;
499 m_aBoxAutoFormat[ nPos ] = pFormat;
500 }
501
503 {
504 pFormat->SetFont( rSet.Get( RES_CHRATR_FONT ) );
505 pFormat->SetHeight( rSet.Get( RES_CHRATR_FONTSIZE ) );
506 pFormat->SetWeight( rSet.Get( RES_CHRATR_WEIGHT ) );
507 pFormat->SetPosture( rSet.Get( RES_CHRATR_POSTURE ) );
508 pFormat->SetCJKFont( rSet.Get( RES_CHRATR_CJK_FONT ) );
512 pFormat->SetCTLFont( rSet.Get( RES_CHRATR_CTL_FONT ) );
519 pFormat->SetContour( rSet.Get( RES_CHRATR_CONTOUR ) );
521 pFormat->SetColor( rSet.Get( RES_CHRATR_COLOR ) );
522 pFormat->SetAdjust( rSet.Get( RES_PARATR_ADJUST ) );
523 }
524 if( !(SwTableAutoFormatUpdateFlags::Box & eFlags) )
525 return;
526
527 pFormat->SetBox( rSet.Get( RES_BOX ) );
528// FIXME - add attribute IDs for the diagonal line items
529// pFormat->SetTLBR( (SvxLineItem&)rSet.Get( RES_... ) );
530// pFormat->SetBLTR( (SvxLineItem&)rSet.Get( RES_... ) );
531 pFormat->SetBackground( rSet.Get( RES_BACKGROUND ) );
534
535 const SwTableBoxNumFormat* pNumFormatItem;
536 const SvNumberformat* pNumFormat = nullptr;
537 if( pNFormatr && (pNumFormatItem = rSet.GetItemIfSet( RES_BOXATR_FORMAT )) &&
538 nullptr != (pNumFormat = pNFormatr->GetEntry( pNumFormatItem->GetValue() )) )
539 pFormat->SetValueFormat( pNumFormat->GetFormatstring(),
540 pNumFormat->GetLanguage(),
542 else
543 {
544 // default
545 pFormat->SetValueFormat( OUString(), LANGUAGE_SYSTEM,
547 }
548
549 // we cannot handle the rest, that's specific to StarCalc
550}
551
552void SwTableAutoFormat::UpdateToSet(const sal_uInt8 nPos, const bool bSingleRowTable, const bool bSingleColTable, SfxItemSet& rSet,
553 SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter* pNFormatr) const
554{
555 const SwBoxAutoFormat& rChg = GetBoxFormat( nPos );
556
558 {
559 if( IsFont() )
560 {
561 rSet.Put( rChg.GetFont() );
562 rSet.Put( rChg.GetHeight() );
563 rSet.Put( rChg.GetWeight() );
564 rSet.Put( rChg.GetPosture() );
565 // do not insert empty CJK font
566 const SvxFontItem& rCJKFont = rChg.GetCJKFont();
567 if (!rCJKFont.GetStyleName().isEmpty())
568 {
569 rSet.Put( rChg.GetCJKFont() );
570 rSet.Put( rChg.GetCJKHeight() );
571 rSet.Put( rChg.GetCJKWeight() );
572 rSet.Put( rChg.GetCJKPosture() );
573 }
574 else
575 {
576 rSet.Put( rChg.GetHeight().CloneSetWhich(RES_CHRATR_CJK_FONTSIZE) );
577 rSet.Put( rChg.GetWeight().CloneSetWhich(RES_CHRATR_CJK_WEIGHT) );
578 rSet.Put( rChg.GetPosture().CloneSetWhich(RES_CHRATR_CJK_POSTURE) );
579 }
580 // do not insert empty CTL font
581 const SvxFontItem& rCTLFont = rChg.GetCTLFont();
582 if (!rCTLFont.GetStyleName().isEmpty())
583 {
584 rSet.Put( rChg.GetCTLFont() );
585 rSet.Put( rChg.GetCTLHeight() );
586 rSet.Put( rChg.GetCTLWeight() );
587 rSet.Put( rChg.GetCTLPosture() );
588 }
589 else
590 {
591 rSet.Put( rChg.GetHeight().CloneSetWhich(RES_CHRATR_CTL_FONTSIZE) );
592 rSet.Put( rChg.GetWeight().CloneSetWhich(RES_CHRATR_CTL_WEIGHT) );
593 rSet.Put( rChg.GetPosture().CloneSetWhich(RES_CHRATR_CTL_POSTURE) );
594 }
595 rSet.Put( rChg.GetUnderline() );
596 rSet.Put( rChg.GetOverline() );
597 rSet.Put( rChg.GetCrossedOut() );
598 rSet.Put( rChg.GetContour() );
599 rSet.Put( rChg.GetShadowed() );
600 rSet.Put( rChg.GetColor() );
601 }
602 if( IsJustify() )
603 rSet.Put( rChg.GetAdjust() );
604 }
605
606 if( !(SwTableAutoFormatUpdateFlags::Box & eFlags) )
607 return;
608
609 if( IsFrame() )
610 {
611 SvxBoxItem aAutoFormatBox = rChg.GetBox();
612
613 // No format box is adequate to specify the borders of single column/row tables, so combine first/last.
614 if ( bSingleRowTable || bSingleColTable )
615 {
616 sal_uInt8 nSingleRowOrColumnId = 15; //LAST_ROW_END_COLUMN
617 if ( !bSingleRowTable )
618 nSingleRowOrColumnId = nPos + 3; //LAST COLUMN (3, 7, 11, 15)
619 else if ( !bSingleColTable )
620 nSingleRowOrColumnId = nPos + 12; //LAST ROW (12, 13, 14, 15)
621
622 assert( nSingleRowOrColumnId < 16 );
623 const SvxBoxItem aLastAutoFormatBox( GetBoxFormat(nSingleRowOrColumnId).GetBox() );
624 if ( bSingleRowTable )
625 aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM );
626 if ( bSingleColTable )
627 aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT );
628 }
629
630 rSet.Put( aAutoFormatBox );
631// FIXME - uncomment the lines to put the diagonal line items
632// rSet.Put( rChg.GetTLBR() );
633// rSet.Put( rChg.GetBLTR() );
634 }
635 if( IsBackground() )
636 rSet.Put( rChg.GetBackground() );
637
639
640 // Do not put a VertAlign when it has default value.
641 // It prevents the export of default value by automatic cell-styles export.
642 if (rChg.GetVerticalAlignment().GetVertOrient() != GetDefaultBoxFormat().GetVerticalAlignment().GetVertOrient())
644
645 if( !(IsValueFormat() && pNFormatr) )
646 return;
647
648 OUString sFormat;
649 LanguageType eLng, eSys;
650 rChg.GetValueFormat( sFormat, eLng, eSys );
651 if( !sFormat.isEmpty() )
652 {
654 bool bNew;
655 sal_Int32 nCheckPos;
656 sal_uInt32 nKey = pNFormatr->GetIndexPuttingAndConverting( sFormat, eLng,
657 eSys, nType, bNew, nCheckPos);
658 rSet.Put( SwTableBoxNumFormat( nKey ));
659 }
660 else
662
663 // we cannot handle the rest, that's specific to StarCalc
664}
665
667{
668 SwTableFormat* pFormat = table.GetFrameFormat();
669 if (!pFormat)
670 return;
671
672 SwDoc *pDoc = pFormat->GetDoc();
673 if (!pDoc)
674 return;
675
677
680 if ( m_aKeepWithNextPara->GetValue() )
683
684 pFormat->SetFormatAttr(rSet);
685
686 SwEditShell *pShell = pDoc->GetEditShell();
688
689 table.SetRowsToRepeat(m_aRepeatHeading);
690}
691
693{
694 SwTableFormat* pFormat = table.GetFrameFormat();
695 if (!pFormat)
696 return;
697
698 SwDoc *pDoc = pFormat->GetDoc();
699 if (!pDoc)
700 return;
701
702 SwEditShell *pShell = pDoc->GetEditShell();
703 std::unique_ptr<SwFormatRowSplit> pRowSplit = SwDoc::GetRowSplit(*pShell->getShellCursor(false));
704 m_bRowSplit = pRowSplit && pRowSplit->GetValue();
705 pRowSplit.reset();
706
707 const SfxItemSet &rSet = pFormat->GetAttrSet();
708
709 const SwFormatLayoutSplit &layoutSplit = rSet.Get(RES_LAYOUT_SPLIT);
710 m_bLayoutSplit = layoutSplit.GetValue();
712
714 m_aRepeatHeading = table.GetRowsToRepeat();
716}
717
719{
720 return GetBoxFormat(3) == GetBoxFormat(2);
721}
723{
724 return GetBoxFormat(0) == GetBoxFormat(1);
725}
727{
728 return GetBoxFormat(14) == GetBoxFormat(15);
729}
731{
732 return GetBoxFormat(12) == GetBoxFormat(13);
733}
734
735bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions )
736{
737 sal_uInt16 nVal = 0;
738 rStream.ReadUInt16( nVal );
739 bool bRet = ERRCODE_NONE == rStream.GetError();
740
741 if( bRet && (nVal == AUTOFORMAT_DATA_ID_X ||
742 (AUTOFORMAT_DATA_ID_504 <= nVal && nVal <= AUTOFORMAT_DATA_ID)) )
743 {
744 bool b;
745 // --- from 680/dr25 on: store strings as UTF-8
746 rtl_TextEncoding eCharSet = (nVal >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
747 m_aName = rStream.ReadUniOrByteString( eCharSet );
748 if( AUTOFORMAT_DATA_ID_552 <= nVal )
749 {
750 rStream.ReadUInt16( m_nStrResId );
751 // start from 3d because default is added via constructor
753 {
755 }
756 else
757 m_nStrResId = USHRT_MAX;
758 }
759 rStream.ReadCharAsBool( b ); m_bInclFont = b;
760 rStream.ReadCharAsBool( b ); m_bInclJustify = b;
761 rStream.ReadCharAsBool( b ); m_bInclFrame = b;
762 rStream.ReadCharAsBool( b ); m_bInclBackground = b;
763 rStream.ReadCharAsBool( b ); m_bInclValueFormat = b;
764 rStream.ReadCharAsBool( b ); m_bInclWidthHeight = b;
765
766 if (nVal >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream))
767 {
768 //this only exists for file format compat
769 SvxFormatBreakItem aBreak(SvxBreak::NONE, RES_BREAK);
772
774
776 }
777
778 bRet = ERRCODE_NONE== rStream.GetError();
779
780 for( sal_uInt8 i = 0; bRet && i < 16; ++i )
781 {
782 SwBoxAutoFormat* pFormat = new SwBoxAutoFormat;
783 bRet = pFormat->Load( rStream, rVersions, nVal );
784 if( bRet )
785 m_aBoxAutoFormat[ i ] = pFormat;
786 else
787 {
788 delete pFormat;
789 break;
790 }
791 }
792 }
793 m_bUserDefined = false;
794 return bRet;
795}
796
797bool SwTableAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
798{
800 // --- from 680/dr25 on: store strings as UTF-8
802 RTL_TEXTENCODING_UTF8 );
803 rStream.WriteUInt16( m_nStrResId );
804 rStream.WriteBool( m_bInclFont );
805 rStream.WriteBool( m_bInclJustify );
806 rStream.WriteBool( m_bInclFrame );
807 rStream.WriteBool( m_bInclBackground );
808 rStream.WriteBool( m_bInclValueFormat );
809 rStream.WriteBool( m_bInclWidthHeight );
810
811 {
812 WriterSpecificAutoFormatBlock block(rStream);
813 //this only exists for file format compat
814 SvxFormatBreakItem aBreak(SvxBreak::NONE, RES_BREAK);
819 }
820
821 bool bRet = ERRCODE_NONE == rStream.GetError();
822
823 for( int i = 0; bRet && i < 16; ++i )
824 {
825 SwBoxAutoFormat* pFormat = m_aBoxAutoFormat[ i ];
826 if( !pFormat ) // if not set -> write default
827 {
828 // If it doesn't exist yet:
831 pFormat = s_pDefaultBoxAutoFormat;
832 }
833 bRet = pFormat->Save( rStream, fileVersion );
834 }
835 return bRet;
836}
837
839{
840 sal_Int32 nIndex = 0;
841 for (; nIndex < 16; ++nIndex)
842 if (m_aBoxAutoFormat[nIndex] == &rBoxFormat) break;
843
844 // box format doesn't belong to this table format
845 if (16 <= nIndex)
846 return OUString();
847
848 const std::vector<sal_Int32> aTableTemplateMap = GetTableTemplateMap();
849 for (size_t i=0; i < aTableTemplateMap.size(); ++i)
850 {
851 if (aTableTemplateMap[i] == nIndex)
852 return "." + OUString::number(i + 1);
853 }
854
855 // box format doesn't belong to a table template
856 return OUString();
857}
858
859/*
860 * Mapping schema
861 * 0 1 2 3 4 5
862 * +-----------------------------------------------------------------------+
863 * 0 | FRSC | FR | FREC | | | FRENC |
864 * +-----------------------------------------------------------------------+
865 * 1 | FC | ER | EC | | | LC |
866 * +-----------------------------------------------------------------------+
867 * 2 | OR | OC | BODY | | | BCKG |
868 * +-----------------------------------------------------------------------+
869 * 3 | | | | | | |
870 * +-----------------------------------------------------------------------+
871 * 4 | | | | | | |
872 * +-----------------------------------------------------------------------+
873 * 5 | LRSC | LR | LREC | | | LRENC |
874 * +-----------+-----------+-----------+-----------+-----------+-----------+
875 * ODD = 1, 3, 5, ...
876 * EVEN = 2, 4, 6, ...
877 */
878const std::vector<sal_Int32> & SwTableAutoFormat::GetTableTemplateMap()
879{
880 static std::vector<sal_Int32> const aTableTemplateMap
881 {
882 1 , // FIRST_ROW // FR
883 13, // LAST_ROW // LR
884 4 , // FIRST_COLUMN // FC
885 7 , // LAST_COLUMN // LC
886 5 , // EVEN_ROWS // ER
887 8 , // ODD_ROWS // OR
888 6 , // EVEN_COLUMNS // EC
889 9 , // ODD_COLUMNS // OC
890 10, // BODY
891 11, // BACKGROUND // BCKG
892 0 , // FIRST_ROW_START_COLUMN // FRSC
893 3 , // FIRST_ROW_END_COLUMN // FRENC
894 12, // LAST_ROW_START_COLUMN // LRSC
895 15, // LAST_ROW_END_COLUMN // LRENC
896 2 , // FIRST_ROW_EVEN_COLUMN // FREC
897 14, // LAST_ROW_EVEN_COLUMN // LREC
898 };
899 return aTableTemplateMap;
900}
901
902sal_uInt8 SwTableAutoFormat::CountPos(sal_uInt32 nCol, sal_uInt32 nCols, sal_uInt32 nRow,
903 sal_uInt32 nRows)
904{
905 sal_uInt8 nRet = static_cast<sal_uInt8>(
906 !nRow ? 0 : ((nRow + 1 == nRows) ? 12 : (4 * (1 + ((nRow - 1) & 1)))));
907 nRet = nRet
908 + static_cast<sal_uInt8>(!nCol ? 0 : (nCol + 1 == nCols ? 3 : (1 + ((nCol - 1) & 1))));
909 return nRet;
910}
911
913{
914 std::vector<std::unique_ptr<SwTableAutoFormat>> m_AutoFormats;
915};
916
918{
919 return m_pImpl->m_AutoFormats.size();
920}
921
923{
924 return *m_pImpl->m_AutoFormats[i];
925}
927{
928 return *m_pImpl->m_AutoFormats[i];
929}
930
932{
933 // don't insert when we already have style of this name
934 if (FindAutoFormat(rTableStyle.GetName()))
935 return;
936
937 InsertAutoFormat(size(), std::make_unique<SwTableAutoFormat>(rTableStyle));
938}
939
940void SwTableAutoFormatTable::InsertAutoFormat(size_t const i, std::unique_ptr<SwTableAutoFormat> pFormat)
941{
942 m_pImpl->m_AutoFormats.insert(m_pImpl->m_AutoFormats.begin() + i, std::move(pFormat));
943}
944
946{
947 m_pImpl->m_AutoFormats.erase(m_pImpl->m_AutoFormats.begin() + i);
948}
949
951{
952 auto iter = std::find_if(m_pImpl->m_AutoFormats.begin(), m_pImpl->m_AutoFormats.end(),
953 [&rName](const std::unique_ptr<SwTableAutoFormat>& rpFormat) { return rpFormat->GetName() == rName; });
954 if (iter != m_pImpl->m_AutoFormats.end())
955 {
956 m_pImpl->m_AutoFormats.erase(iter);
957 return;
958 }
959 SAL_INFO("sw.core", "SwTableAutoFormatTable::EraseAutoFormat, SwTableAutoFormat with given name not found");
960}
961
962std::unique_ptr<SwTableAutoFormat> SwTableAutoFormatTable::ReleaseAutoFormat(size_t const i)
963{
964 auto const iter(m_pImpl->m_AutoFormats.begin() + i);
965 std::unique_ptr<SwTableAutoFormat> pRet(std::move(*iter));
966 m_pImpl->m_AutoFormats.erase(iter);
967 return pRet;
968}
969
970std::unique_ptr<SwTableAutoFormat> SwTableAutoFormatTable::ReleaseAutoFormat(const OUString& rName)
971{
972 std::unique_ptr<SwTableAutoFormat> pRet;
973 auto iter = std::find_if(m_pImpl->m_AutoFormats.begin(), m_pImpl->m_AutoFormats.end(),
974 [&rName](const std::unique_ptr<SwTableAutoFormat>& rpFormat) { return rpFormat->GetName() == rName; });
975 if (iter != m_pImpl->m_AutoFormats.end())
976 {
977 pRet = std::move(*iter);
978 m_pImpl->m_AutoFormats.erase(iter);
979 }
980 return pRet;
981}
982
984{
985 for (const auto &rFormat : m_pImpl->m_AutoFormats)
986 {
987 if (rFormat->GetName() == rName)
988 return rFormat.get();
989 }
990
991 return nullptr;
992}
993
995{
996}
997
999 : m_pImpl(new Impl)
1000{
1001 std::unique_ptr<SwTableAutoFormat> pNew(new SwTableAutoFormat(
1003
1004 sal_uInt8 i;
1005
1006 Color aColor( COL_BLACK );
1007 SvxBoxItem aBox( RES_BOX );
1008
1009 aBox.SetAllDistances(55);
1010 SvxBorderLine aLn( &aColor, SvxBorderLineWidth::VeryThin );
1011 aBox.SetLine( &aLn, SvxBoxItemLine::LEFT );
1012 aBox.SetLine( &aLn, SvxBoxItemLine::BOTTOM );
1013
1014 for( i = 0; i <= 15; ++i )
1015 {
1016 aBox.SetLine( i <= 3 ? &aLn : nullptr, SvxBoxItemLine::TOP );
1017 aBox.SetLine( (3 == ( i & 3 )) ? &aLn : nullptr, SvxBoxItemLine::RIGHT );
1018 pNew->GetBoxFormat( i ).SetBox( aBox );
1019 }
1020
1021 pNew->SetUserDefined(false);
1022 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1023}
1024
1026{
1028 return;
1029 OUString sNm(AUTOTABLE_FORMAT_NAME);
1030 SvtPathOptions aOpt;
1031 if( aOpt.SearchFile( sNm ))
1032 {
1033 SfxMedium aStream( sNm, StreamMode::STD_READ );
1034 Load( *aStream.GetInStream() );
1035 }
1036}
1037
1039{
1041 return false;
1042 SvtPathOptions aPathOpt;
1043 const OUString sNm( aPathOpt.GetUserConfigPath() + "/" + AUTOTABLE_FORMAT_NAME );
1044 SfxMedium aStream(sNm, StreamMode::STD_WRITE );
1045 return Save( *aStream.GetOutStream() ) && aStream.Commit();
1046}
1047
1049{
1050 bool bRet = ERRCODE_NONE == rStream.GetError();
1051 if (bRet)
1052 {
1053 // Attention: We need to read a general Header here
1054 sal_uInt16 nVal = 0;
1055 rStream.ReadUInt16( nVal );
1056 bRet = ERRCODE_NONE == rStream.GetError();
1057
1058 if( bRet )
1059 {
1060 SwAfVersions aVersions;
1061
1062 // Default version is 5.0, unless we detect an old format ID.
1063 sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_50;
1064 if(nVal < AUTOFORMAT_ID_31005)
1065 nFileVers = SOFFICE_FILEFORMAT_40;
1066
1067 if( nVal == AUTOFORMAT_ID_358 ||
1068 (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
1069 {
1070 sal_uInt8 nChrSet, nCnt;
1071 sal_uInt64 nPos = rStream.Tell();
1072 rStream.ReadUChar( nCnt ).ReadUChar( nChrSet );
1073 if( rStream.Tell() != nPos + nCnt )
1074 {
1075 OSL_ENSURE( false, "The Header contains more or newer Data" );
1076 rStream.Seek( nPos + nCnt );
1077 }
1078 rStream.SetStreamCharSet( static_cast<rtl_TextEncoding>(nChrSet) );
1079 rStream.SetVersion( nFileVers );
1080 }
1081
1082 if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
1083 (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
1084 {
1085 aVersions.Load( rStream, nVal ); // Item versions
1086
1087 sal_uInt16 nCount = 0;
1088 rStream.ReadUInt16( nCount );
1089
1090 bRet = ERRCODE_NONE== rStream.GetError();
1091 if (bRet)
1092 {
1093 const size_t nMinRecordSize = sizeof(sal_uInt16);
1094 const size_t nMaxRecords = rStream.remainingSize() / nMinRecordSize;
1095 if (nCount > nMaxRecords)
1096 {
1097 SAL_WARN("sw.core", "Parsing error: " << nMaxRecords <<
1098 " max possible entries, but " << nCount << " claimed, truncating");
1099 nCount = nMaxRecords;
1100 }
1101 for (sal_uInt16 i = 0; i < nCount; ++i)
1102 {
1103 std::unique_ptr<SwTableAutoFormat> pNew(
1104 new SwTableAutoFormat( OUString() ));
1105 bRet = pNew->Load( rStream, aVersions );
1106 if( bRet )
1107 {
1108 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1109 }
1110 else
1111 {
1112 break;
1113 }
1114 }
1115 }
1116 }
1117 else
1118 {
1119 bRet = false;
1120 }
1121 }
1122 }
1123 return bRet;
1124}
1125
1127{
1128 bool bRet = ERRCODE_NONE == rStream.GetError();
1129 if (bRet)
1130 {
1132
1133 // Attention: We need to save a general Header here
1134 rStream.WriteUInt16( AUTOFORMAT_ID )
1135 .WriteUChar( 2 ) // Character count of the Header including this value
1136 .WriteUChar( GetStoreCharSet( ::osl_getThreadTextEncoding() ) );
1137
1138 bRet = ERRCODE_NONE == rStream.GetError();
1139 if (!bRet)
1140 return false;
1141
1142 // Write this version number for all attributes
1144
1145 rStream.WriteUInt16( m_pImpl->m_AutoFormats.size() - 1 );
1146 bRet = ERRCODE_NONE == rStream.GetError();
1147
1148 for (size_t i = 1; bRet && i < m_pImpl->m_AutoFormats.size(); ++i)
1149 {
1150 SwTableAutoFormat const& rFormat = *m_pImpl->m_AutoFormats[i];
1151 bRet = rFormat.Save(rStream, AUTOFORMAT_FILE_VERSION);
1152 }
1153 }
1154 rStream.FlushBuffer();
1155 return bRet;
1156}
1157
1159{ }
1160
1162{
1163}
1164
1166{
1167 return m_aCellStyles.size();
1168}
1169
1171{
1172 m_aCellStyles.clear();
1173}
1174
1176{
1178}
1179
1180void SwCellStyleTable::AddBoxFormat(const SwBoxAutoFormat& rBoxFormat, const OUString& sName)
1181{
1182 m_aCellStyles.emplace_back(sName, std::make_unique<SwBoxAutoFormat>(rBoxFormat));
1183}
1184
1185void SwCellStyleTable::RemoveBoxFormat(const OUString& sName)
1186{
1187 auto iter = std::find_if(m_aCellStyles.begin(), m_aCellStyles.end(),
1188 [&sName](const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rStyle) { return rStyle.first == sName; });
1189 if (iter != m_aCellStyles.end())
1190 {
1191 m_aCellStyles.erase(iter);
1192 return;
1193 }
1194 SAL_INFO("sw.core", "SwCellStyleTable::RemoveBoxFormat, format with given name doesn't exists");
1195}
1196
1198{
1199 for (size_t i=0; i < m_aCellStyles.size(); ++i)
1200 {
1201 if (m_aCellStyles[i].second.get() == &rBoxFormat)
1202 return m_aCellStyles[i].first;
1203 }
1204
1205 // box format not found
1206 return OUString();
1207}
1208
1209SwBoxAutoFormat* SwCellStyleTable::GetBoxFormat(std::u16string_view sName) const
1210{
1211 for (size_t i=0; i < m_aCellStyles.size(); ++i)
1212 {
1213 if (m_aCellStyles[i].first == sName)
1214 return m_aCellStyles[i].second.get();
1215 }
1216
1217 return nullptr;
1218}
1219
1220void SwCellStyleTable::ChangeBoxFormatName(std::u16string_view sFromName, const OUString& sToName)
1221{
1222 if (!GetBoxFormat(sToName))
1223 {
1224 SAL_INFO("sw.core", "SwCellStyleTable::ChangeBoxName, box with given name already exists");
1225 return;
1226 }
1227 for (size_t i=0; i < m_aCellStyles.size(); ++i)
1228 {
1229 if (m_aCellStyles[i].first == sFromName)
1230 {
1231 m_aCellStyles[i].first = sToName;
1232 // changed successfully
1233 return;
1234 }
1235 }
1236 SAL_INFO("sw.core", "SwCellStyleTable::ChangeBoxName, box with given name not found");
1237}
1238/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
std::unique_ptr< SvxFontHeightItem > m_aCJKHeight
void SetColor(const SvxColorItem &rNew)
std::unique_ptr< SvxAdjustItem > m_aAdjust
const SvxContourItem & GetContour() const
std::unique_ptr< SvxShadowedItem > m_aShadowed
std::unique_ptr< SvxLineItem > m_aBLTR
bool SaveBlockB(SvStream &rStream, sal_uInt16 fileVersion) const
const SvxColorItem & GetColor() const
std::unique_ptr< SvxCrossedOutItem > m_aCrossedOut
void SetCJKWeight(const SvxWeightItem &rNew)
std::unique_ptr< SfxBoolItem > m_aLinebreak
const SvxWeightItem & GetWeight() const
std::unique_ptr< SvxPostureItem > m_aCTLPosture
std::unique_ptr< SvxWeightItem > m_aWeight
void SetCJKHeight(const SvxFontHeightItem &rNew)
const SvxBoxItem & GetBox() const
void SetBackground(const SvxBrushItem &rNew)
std::unique_ptr< SvxPostureItem > m_aCJKPosture
std::unique_ptr< SvxFontHeightItem > m_aHeight
void SetShadowed(const SvxShadowedItem &rNew)
bool LoadBlockB(SvStream &rStream, const AutoFormatVersions &rVersions, sal_uInt16 nVer)
std::unique_ptr< SvxBrushItem > m_aBackground
const SvxFontHeightItem & GetCJKHeight() const
bool SaveBlockA(SvStream &rStream, sal_uInt16 fileVersion) const
const SvxWeightItem & GetCTLWeight() const
std::unique_ptr< SfxBoolItem > m_aStacked
const SvxFontItem & GetCTLFont() const
std::unique_ptr< SvxVerJustifyItem > m_aVerJustify
void SetHeight(const SvxFontHeightItem &rNew)
std::unique_ptr< SvxOverlineItem > m_aOverline
void SetCJKPosture(const SvxPostureItem &rNew)
const SvxPostureItem & GetPosture() const
std::unique_ptr< SfxInt32Item > m_aRotateAngle
const SvxFontItem & GetFont() const
const SvxWeightItem & GetCJKWeight() const
void SetBox(const SvxBoxItem &rNew)
std::unique_ptr< SvxFontItem > m_aCJKFont
const SvxPostureItem & GetCJKPosture() const
const SvxOverlineItem & GetOverline() const
bool LoadBlockA(SvStream &rStream, const AutoFormatVersions &rVersions, sal_uInt16 nVer)
const SvxFontItem & GetCJKFont() const
const SvxAdjustItem & GetAdjust() const
void SetContour(const SvxContourItem &rNew)
void SetCTLFont(const SvxFontItem &rNew)
std::unique_ptr< SvxMarginItem > m_aMargin
void SetOverline(const SvxOverlineItem &rNew)
std::unique_ptr< SvxColorItem > m_aColor
void SetWeight(const SvxWeightItem &rNew)
std::unique_ptr< SvxFontHeightItem > m_aCTLHeight
const SvxShadowedItem & GetShadowed() const
void SetUnderline(const SvxUnderlineItem &rNew)
std::unique_ptr< SvxBoxItem > m_aBox
std::unique_ptr< SvxFontItem > m_aCTLFont
const SvxFontHeightItem & GetCTLHeight() const
const SvxBrushItem & GetBackground() const
void SetCTLPosture(const SvxPostureItem &rNew)
std::unique_ptr< SvxWeightItem > m_aCTLWeight
void SetPosture(const SvxPostureItem &rNew)
const SvxFontHeightItem & GetHeight() const
void SetCJKFont(const SvxFontItem &rNew)
void SetCTLWeight(const SvxWeightItem &rNew)
void SetCrossedOut(const SvxCrossedOutItem &rNew)
std::unique_ptr< SvxFontItem > m_aFont
std::unique_ptr< SvxContourItem > m_aContour
std::unique_ptr< SvxPostureItem > m_aPosture
const SvxPostureItem & GetCTLPosture() const
void SetAdjust(const SvxAdjustItem &rNew)
std::unique_ptr< SvxWeightItem > m_aCJKWeight
const SvxCrossedOutItem & GetCrossedOut() const
std::unique_ptr< SvxRotateModeItem > m_aRotateMode
void SetFont(const SvxFontItem &rNew)
AutoFormatBase & operator=(const AutoFormatBase &)
std::unique_ptr< SvxUnderlineItem > m_aUnderline
std::unique_ptr< SvxLineItem > m_aTLBR
const SvxUnderlineItem & GetUnderline() const
void SetCTLHeight(const SvxFontHeightItem &rNew)
std::unique_ptr< SvxHorJustifyItem > m_aHorJustify
sal_uInt32 GetValue() const
bool 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()
SvStream * GetInStream()
bool Commit()
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
sal_uInt32 GetIndexPuttingAndConverting(OUString &rString, LanguageType eLnge, LanguageType eSysLnge, SvNumFormatType &rType, bool &rNewInserted, sal_Int32 &rCheckPos)
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
LanguageType GetLanguage() const
const OUString & GetFormatstring() const
SvStream & ReadCharAsBool(bool &rBool)
sal_uInt64 Tell() const
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
ErrCode GetError() const
void FlushBuffer()
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
const OUString & GetNumFormatString() const
Definition: tblafmt.hxx:77
void SetTextOrientation(const SvxFrameDirectionItem &rNew)
Definition: tblafmt.hxx:82
OUString m_sNumFormatString
Definition: tblafmt.hxx:53
const LanguageType & GetNumFormatLanguage() const
Definition: tblafmt.hxx:79
const LanguageType & GetSysLanguage() const
Definition: tblafmt.hxx:78
void GetValueFormat(OUString &rFormat, LanguageType &rLng, LanguageType &rSys) const
Definition: tblafmt.hxx:74
void SetSysLanguage(const LanguageType &rNew)
Definition: tblafmt.hxx:89
std::unique_ptr< SwFormatVertOrient > m_aVerticalAlignment
Definition: tblafmt.hxx:50
void SetNumFormatString(const OUString &rNew)
Definition: tblafmt.hxx:88
std::unique_ptr< SvxFrameDirectionItem > m_aTextOrientation
Definition: tblafmt.hxx:49
const SwFormatVertOrient & GetVerticalAlignment() const
Definition: tblafmt.hxx:72
LanguageType m_eNumFormatLanguage
Definition: tblafmt.hxx:55
void SetVerticalAlignment(const SwFormatVertOrient &rNew)
Definition: tblafmt.hxx:83
bool Load(SvStream &rStream, const SwAfVersions &rVersions, sal_uInt16 nVer)
Definition: tblafmt.cxx:309
SwBoxAutoFormat & operator=(const SwBoxAutoFormat &rRef)
assignment-op (still used)
Definition: tblafmt.cxx:279
void SetNumFormatLanguage(const LanguageType &rNew)
Definition: tblafmt.hxx:90
LanguageType m_eSysLanguage
Definition: tblafmt.hxx:54
void SetValueFormat(const OUString &rFormat, LanguageType eLng, LanguageType eSys)
Definition: tblafmt.hxx:85
bool operator==(const SwBoxAutoFormat &rRight) const
Comparing based of boxes backgrounds.
Definition: tblafmt.cxx:304
bool Save(SvStream &rStream, sal_uInt16 fileVersion) const
Definition: tblafmt.cxx:342
const SvxFrameDirectionItem & GetTextOrientation() const
Definition: tblafmt.hxx:71
OUString GetBoxFormatName(const SwBoxAutoFormat &rBoxFormat) const
If found returns its name. If not found returns an empty OUString.
Definition: tblafmt.cxx:1197
void ChangeBoxFormatName(std::u16string_view sFromName, const OUString &sToName)
Definition: tblafmt.cxx:1220
size_t size() const
Definition: tblafmt.cxx:1165
void AddBoxFormat(const SwBoxAutoFormat &rBoxFormat, const OUString &sName)
Add a copy of rBoxFormat.
Definition: tblafmt.cxx:1180
SwCellStyleDescriptor operator[](size_t i) const
Definition: tblafmt.cxx:1175
std::vector< std::pair< OUString, std::unique_ptr< SwBoxAutoFormat > > > m_aCellStyles
Definition: tblafmt.hxx:306
SwBoxAutoFormat * GetBoxFormat(std::u16string_view sName) const
If found returns a ptr to a BoxFormat. If not found returns nullptr.
Definition: tblafmt.cxx:1209
void RemoveBoxFormat(const OUString &sName)
Definition: tblafmt.cxx:1185
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3051
Definition: doc.hxx:192
void SetRowSplit(const SwCursor &rCursor, const SwFormatRowSplit &rNew)
Definition: ndtbl1.cxx:324
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:330
static std::unique_ptr< SwFormatRowSplit > GetRowSplit(const SwCursor &rCursor)
Definition: ndtbl1.cxx:350
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1322
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:449
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
void AddAutoFormat(const SwTableAutoFormat &rFormat)
Append table style to the existing styles.
Definition: tblafmt.cxx:931
std::unique_ptr< Impl > m_pImpl
Definition: tblafmt.hxx:264
size_t size() const
Definition: tblafmt.cxx:917
std::unique_ptr< SwTableAutoFormat > ReleaseAutoFormat(size_t i)
Definition: tblafmt.cxx:962
SwTableAutoFormat const & operator[](size_t i) const
Definition: tblafmt.cxx:922
void EraseAutoFormat(size_t i)
Definition: tblafmt.cxx:945
void InsertAutoFormat(size_t i, std::unique_ptr< SwTableAutoFormat > pFormat)
Definition: tblafmt.cxx:940
SwTableAutoFormat * FindAutoFormat(std::u16string_view rName) const
Find table style with the provided name, return nullptr when not found.
Definition: tblafmt.cxx:983
void SetBoxFormat(const SwBoxAutoFormat &rNew, sal_uInt8 nPos)
Definition: tblafmt.cxx:438
static const SwBoxAutoFormat & GetDefaultBoxFormat()
Definition: tblafmt.cxx:480
bool IsJustify() const
Definition: tblafmt.hxx:214
bool m_bInclWidthHeight
Definition: tblafmt.hxx:169
const SwBoxAutoFormat & GetBoxFormat(sal_uInt8 nPos) const
Definition: tblafmt.cxx:449
static sal_uInt8 CountPos(sal_uInt32 nCol, sal_uInt32 nCols, sal_uInt32 nRow, sal_uInt32 nRows)
Calculates the relevant position in the table autoformat for a given cell in a given table.
Definition: tblafmt.cxx:902
void UpdateToSet(const sal_uInt8 nPos, const bool bSingleRowTable, const bool bSingleColTable, SfxItemSet &rSet, SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter *) const
Definition: tblafmt.cxx:552
void UpdateFromSet(sal_uInt8 nPos, const SfxItemSet &rSet, SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter const *)
Definition: tblafmt.cxx:488
bool FirstRowStartColumnIsRow()
Definition: tblafmt.cxx:722
bool m_bInclValueFormat
Definition: tblafmt.hxx:166
SwTableAutoFormat(OUString aName)
Definition: tblafmt.cxx:364
static const std::vector< sal_Int32 > & GetTableTemplateMap()
Returns a vector of indexes in aBoxAutoFormat array. Returned indexes points to cells which are mappe...
Definition: tblafmt.cxx:878
sal_uInt16 m_aRepeatHeading
Definition: tblafmt.hxx:175
SwBoxAutoFormat * m_aBoxAutoFormat[16]
Definition: tblafmt.hxx:171
bool m_bCollapsingBorders
Definition: tblafmt.hxx:178
std::shared_ptr< SvxShadowItem > m_aShadow
Definition: tblafmt.hxx:179
bool Save(SvStream &rStream, sal_uInt16 fileVersion) const
Definition: tblafmt.cxx:797
bool IsValueFormat() const
Definition: tblafmt.hxx:217
sal_uInt16 m_nStrResId
Definition: tblafmt.hxx:159
bool IsBackground() const
Definition: tblafmt.hxx:216
bool LastRowStartColumnIsRow()
Definition: tblafmt.cxx:730
SwTableAutoFormat & operator=(const SwTableAutoFormat &rNew)
Definition: tblafmt.cxx:392
bool IsFont() const
Definition: tblafmt.hxx:213
bool LastRowEndColumnIsRow()
Definition: tblafmt.cxx:726
void StoreTableProperties(const SwTable &table)
Definition: tblafmt.cxx:692
OUString m_aName
Definition: tblafmt.hxx:158
void RestoreTableProperties(SwTable &table) const
Definition: tblafmt.cxx:666
const OUString & GetName() const
Definition: tblafmt.hxx:202
bool m_bInclBackground
Definition: tblafmt.hxx:165
OUString GetTableTemplateCellSubName(const SwBoxAutoFormat &rBoxFormat) const
Returns the cell's name postfix. eg. ".1".
Definition: tblafmt.cxx:838
bool IsFrame() const
Definition: tblafmt.hxx:215
std::shared_ptr< SvxFormatKeepItem > m_aKeepWithNextPara
Definition: tblafmt.hxx:174
static SwBoxAutoFormat * s_pDefaultBoxAutoFormat
Definition: tblafmt.hxx:154
bool FirstRowEndColumnIsRow()
These methods returns what style (row or column) is applied first on given Cell.
Definition: tblafmt.cxx:718
bool Load(SvStream &rStream, const SwAfVersions &)
Definition: tblafmt.cxx:735
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
static bool IsFuzzing()
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
int nCount
Reference< XOutputStream > stream
float u
#define ERRCODE_NONE
#define SOFFICE_FILEFORMAT_40
#define SOFFICE_FILEFORMAT_50
LINESTYLE_NONE
STRIKEOUT_NONE
ITALIC_NONE
WEIGHT_NORMAL
SvxFrameDirection
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(107)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(124)
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< SvxFontItem > RES_CHRATR_CTL_FONT(27)
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< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxOverlineItem > RES_CHRATR_OVERLINE(38)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:157
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()
Definition: init.cxx:725
sal_Int32 nIndex
OUString aName
sal_Int64 n
#define LANGUAGE_SYSTEM
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
const char * sName
def text(shape, orig_st)
int i
constexpr OUStringLiteral first
void Create(SvxFormatBreakItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
SvStream & Store(const SvxFormatBreakItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
SvStream & Store(const SvxFormatKeepItem &rItem, SvStream &rStrm, sal_uInt16)
void Create(SvxFormatKeepItem &rItem, SvStream &rStrm, sal_uInt16)
sal_uInt16 GetVersion(sal_uInt16)
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)
SvStream & Store(const SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:67
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
Definition: legacyitem.cxx:32
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:27
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)
FRAME
OUString m_aName
@ RES_POOLTABLESTYLE_DEFAULT
Definition: poolfmt.hxx:206
@ RES_POOLTABLESTYLE_END
Definition: poolfmt.hxx:235
@ RES_POOLTABLESTYLE_3D
Definition: poolfmt.hxx:208
QPRO_FUNC_TYPE nType
SVX_ROTATE_MODE_STANDARD
static SfxItemSet & rSet
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 WriteBlockB(SvStream &rStream, sal_uInt16 fileVersion)
static void WriteBlockA(SvStream &rStream, sal_uInt16 fileVersion)
void LoadBlockB(SvStream &rStream, sal_uInt16 nVer)
void LoadBlockA(SvStream &rStream, sal_uInt16 nVer)
sal_uInt16 nNumFormatVersion
static void Write(SvStream &rStream, sal_uInt16 fileVersion)
Definition: tblafmt.cxx:202
sal_uInt16 m_nVerticalAlignmentVersion
Definition: tblafmt.cxx:178
void Load(SvStream &rStream, sal_uInt16 nVer)
Definition: tblafmt.cxx:191
sal_uInt16 m_nTextOrientationVersion
Definition: tblafmt.cxx:177
std::vector< std::unique_ptr< SwTableAutoFormat > > m_AutoFormats
Definition: tblafmt.cxx:914
const sal_uInt16 AUTOFORMAT_ID
Definition: tblafmt.cxx:97
const sal_uInt16 AUTOFORMAT_ID_680DR25
Definition: tblafmt.cxx:90
const sal_uInt16 AUTOFORMAT_DATA_ID_31005
Definition: tblafmt.cxx:94
const sal_uInt16 AUTOFORMAT_DATA_ID_504
Definition: tblafmt.cxx:85
const sal_uInt16 AUTOFORMAT_ID_358
Definition: tblafmt.cxx:79
constexpr OUStringLiteral AUTOTABLE_FORMAT_NAME
Definition: tblafmt.cxx:103
const sal_uInt16 AUTOFORMAT_ID_504
In follow-up versions these IDs' values need to increase.
Definition: tblafmt.cxx:84
const sal_uInt16 AUTOFORMAT_FILE_VERSION
Definition: tblafmt.cxx:99
const sal_uInt16 AUTOFORMAT_ID_X
Definition: tblafmt.cxx:78
const sal_uInt16 AUTOFORMAT_DATA_ID_552
Definition: tblafmt.cxx:87
const sal_uInt16 AUTOFORMAT_DATA_ID
Definition: tblafmt.cxx:98
const sal_uInt16 AUTOFORMAT_ID_31005
Definition: tblafmt.cxx:93
const sal_uInt16 AUTOFORMAT_DATA_ID_X
Definition: tblafmt.cxx:80
SwTableAutoFormatUpdateFlags
Definition: tblafmt.hxx:101
unsigned char sal_uInt8
SvNumFormatType