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#include <unostyle.hxx>
66
67#include <memory>
68#include <utility>
69#include <vector>
70
71/*
72 * XXX: BIG RED NOTICE! Changes MUST be binary file format compatible and MUST
73 * be synchronized with Calc's ScAutoFormat sc/source/core/tool/autoform.cxx
74 */
75
76using ::editeng::SvxBorderLine;
77
78// until SO5PF
79const sal_uInt16 AUTOFORMAT_ID_X = 9501;
80const sal_uInt16 AUTOFORMAT_ID_358 = 9601;
81const sal_uInt16 AUTOFORMAT_DATA_ID_X = 9502;
82
83// from SO5
85const sal_uInt16 AUTOFORMAT_ID_504 = 9801;
86const sal_uInt16 AUTOFORMAT_DATA_ID_504 = 9802;
87
88const sal_uInt16 AUTOFORMAT_DATA_ID_552 = 9902;
89
90// --- from 680/dr25 on: store strings as UTF-8
91const sal_uInt16 AUTOFORMAT_ID_680DR25 = 10021;
92
93// --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
94const sal_uInt16 AUTOFORMAT_ID_31005 = 10041;
95const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
96
97// current version
101
103
104constexpr OUStringLiteral AUTOTABLE_FORMAT_NAME = u"autotbl.fmt";
105
106namespace
107{
109 sal_uInt64 BeginSwBlock(SvStream& rStream)
110 {
111 // We need to write down the offset of the end of the writer-specific data, so that
112 // calc can skip it. We'll only have that value after writing the data, so we
113 // write a placeholder value first, write the data, then jump back and write the
114 // real offset.
115
116 // Note that we explicitly use sal_uInt64 instead of sal_Size (which can be 32
117 // or 64 depending on platform) to ensure 64-bit portability on this front. I don't
118 // actually know if autotbl.fmt as a whole is portable, since that requires all serialization
119 // logic to be written with portability in mind.
120 sal_uInt64 whereToWriteEndOfSwBlock = rStream.Tell();
121
122 rStream.WriteUInt64( 0 ); // endOfSwBlock
123
124 return whereToWriteEndOfSwBlock;
125 }
126
129 void EndSwBlock(SvStream& rStream, sal_uInt64 whereToWriteEndOfSwBlock)
130 {
131 sal_uInt64 endOfSwBlock = rStream.Tell();
132 rStream.Seek(whereToWriteEndOfSwBlock);
133 rStream.WriteUInt64( endOfSwBlock );
134 rStream.Seek(endOfSwBlock);
135 }
136
143 class WriterSpecificAutoFormatBlock
144 {
145 public:
146 explicit WriterSpecificAutoFormatBlock(SvStream& rStream)
147 : mrStream(rStream)
148 , mnWhereToWriteEndOfBlock(BeginSwBlock(rStream))
149 {
150 }
151
152 ~WriterSpecificAutoFormatBlock() { EndSwBlock(mrStream, mnWhereToWriteEndOfBlock); }
153
154 private:
155 WriterSpecificAutoFormatBlock(WriterSpecificAutoFormatBlock const&) = delete;
156 WriterSpecificAutoFormatBlock& operator=(WriterSpecificAutoFormatBlock const&) = delete;
157
158 SvStream& mrStream;
159 sal_uInt64 mnWhereToWriteEndOfBlock;
160 };
161
163 sal_Int64 WriterSpecificBlockExists(SvStream &stream)
164 {
165 sal_uInt64 endOfSwBlock = 0;
166 stream.ReadUInt64( endOfSwBlock );
167
168 // end-of-block pointing to itself indicates a zero-size block.
169 return endOfSwBlock - stream.Tell();
170 }
171}
172
173// Struct with version numbers of the Items
174
176{
177public:
180
181 SwAfVersions();
182 void Load( SvStream& rStream, sal_uInt16 nVer );
183 static void Write(SvStream& rStream, sal_uInt16 fileVersion);
184};
185
187: m_nTextOrientationVersion(0),
188 m_nVerticalAlignmentVersion(0)
189{
190}
191
192void SwAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
193{
194 LoadBlockA(rStream, nVer);
195 if (nVer >= AUTOFORMAT_ID_31005 && WriterSpecificBlockExists(rStream))
196 {
199 }
200 LoadBlockB(rStream, nVer);
201}
202
203void SwAfVersions::Write(SvStream& rStream, sal_uInt16 fileVersion)
204{
205 AutoFormatVersions::WriteBlockA(rStream, fileVersion);
206
207 if (fileVersion >= SOFFICE_FILEFORMAT_50)
208 {
209 WriterSpecificAutoFormatBlock block(rStream);
210
212 rStream.WriteUInt16(legacy::SwFormatVert::GetVersion(fileVersion));
213 }
214
215 AutoFormatVersions::WriteBlockB(rStream, fileVersion);
216}
217
218
219
221: m_aTextOrientation(std::make_unique<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR)),
222 m_aVerticalAlignment(std::make_unique<SwFormatVertOrient>(0, css::text::VertOrientation::NONE, css::text::RelOrientation::FRAME)),
223 m_eSysLanguage(::GetAppLanguage()),
224 m_eNumFormatLanguage(::GetAppLanguage())
225{
226 // need to set default instances for base class AutoFormatBase here
227 // due to resource defines (e.g. RES_CHRATR_FONT) which are not available
228 // in svx and different in the different usages of derivations
229 m_aFont = std::make_unique<SvxFontItem>(*GetDfltAttr( RES_CHRATR_FONT ) );
230 m_aHeight = std::make_unique<SvxFontHeightItem>(240, 100, RES_CHRATR_FONTSIZE );
231 m_aWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
232 m_aPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_POSTURE );
233 m_aCJKFont = std::make_unique<SvxFontItem>(*GetDfltAttr( RES_CHRATR_CJK_FONT ) );
234 m_aCJKHeight = std::make_unique<SvxFontHeightItem>(240, 100, RES_CHRATR_CJK_FONTSIZE );
235 m_aCJKWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_CJK_WEIGHT );
236 m_aCJKPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_CJK_POSTURE );
237 m_aCTLFont = std::make_unique<SvxFontItem>(*GetDfltAttr( RES_CHRATR_CTL_FONT ) );
238 m_aCTLHeight = std::make_unique<SvxFontHeightItem>(240, 100, RES_CHRATR_CTL_FONTSIZE );
239 m_aCTLWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_CTL_WEIGHT );
240 m_aCTLPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_CTL_POSTURE );
241 m_aUnderline = std::make_unique<SvxUnderlineItem>(LINESTYLE_NONE, RES_CHRATR_UNDERLINE );
242 m_aOverline = std::make_unique<SvxOverlineItem>(LINESTYLE_NONE, RES_CHRATR_OVERLINE );
243 m_aCrossedOut = std::make_unique<SvxCrossedOutItem>(STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT );
244 m_aContour = std::make_unique<SvxContourItem>(false, RES_CHRATR_CONTOUR );
245 m_aShadowed = std::make_unique<SvxShadowedItem>(false, RES_CHRATR_SHADOWED );
246 m_aColor = std::make_unique<SvxColorItem>(RES_CHRATR_COLOR );
247 m_aBox = std::make_unique<SvxBoxItem>(RES_BOX );
248 m_aTLBR = std::make_unique<SvxLineItem>(0 );
249 m_aBLTR = std::make_unique<SvxLineItem>(0 );
250 m_aBackground = std::make_unique<SvxBrushItem>(RES_BACKGROUND );
251 m_aAdjust = std::make_unique<SvxAdjustItem>(SvxAdjust::Left, RES_PARATR_ADJUST );
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>( TypedWhichId<SvxMarginItem>(0) );
256 m_aLinebreak = std::make_unique<SfxBoolItem>(0 );
257 m_aRotateAngle = std::make_unique<SfxInt32Item>(0 );
258 m_aRotateMode = std::make_unique<SvxRotateModeItem>(SVX_ROTATE_MODE_STANDARD, TypedWhichId<SvxRotateModeItem>(0) );
259
260// FIXME - add attribute IDs for the diagonal line items
261// aTLBR( RES_... ),
262// aBLTR( RES_... ),
263 m_aBox->SetAllDistances(55);
264}
265
267: AutoFormatBase(rNew),
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 )
273{
274}
275
277{
278}
279
281{
282 // check self-assignment
283 if(this == &rRef)
284 {
285 return *this;
286 }
287
288 // call baseclass implementation
290
291 // copy local members - this will use ::Clone() on all involved Items
297
298 // m_wXObject used to not be copied before 1e2682235cded9a7cd90e55f0bfc60a1285e9a46
299 // "WIP: Further preparations for deeper Item changes" by this operator, so do not do it now, too
300 // rRef.SetXObject(GetXObject());
301
302 return *this;
303}
304
306{
307 return GetBackground().GetColor() == rRight.GetBackground().GetColor();
308}
309
310bool SwBoxAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer )
311{
312 LoadBlockA( rStream, rVersions, nVer );
313
314 if (nVer >= AUTOFORMAT_DATA_ID_31005)
315 {
316 sal_Int64 const nSize(WriterSpecificBlockExists(rStream));
317 if (0 < nSize && nSize < std::numeric_limits<sal_uInt16>::max())
318 {
320 // HORRIBLE HACK to read both 32-bit and 64-bit "long": abuse nSize
321 legacy::SwFormatVert::Create(*m_aVerticalAlignment, rStream, /*rVersions.m_nVerticalAlignmentVersion*/ nSize);
322 }
323 }
324
325 LoadBlockB( rStream, rVersions, nVer );
326
327 if( 0 == rVersions.nNumFormatVersion )
328 {
329 sal_uInt16 eSys, eLge;
330 // --- from 680/dr25 on: store strings as UTF-8
331 rtl_TextEncoding eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
332 m_sNumFormatString = rStream.ReadUniOrByteString( eCharSet );
333 rStream.ReadUInt16( eSys ).ReadUInt16( eLge );
336 if ( m_eSysLanguage == LANGUAGE_SYSTEM ) // from old versions (Calc)
338 }
339
340 return ERRCODE_NONE == rStream.GetError();
341}
342
343bool SwBoxAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
344{
345 SaveBlockA( rStream, fileVersion );
346
347 if (fileVersion >= SOFFICE_FILEFORMAT_50)
348 {
349 WriterSpecificAutoFormatBlock block(rStream);
350
353 }
354
355 SaveBlockB( rStream, fileVersion );
356
357 // --- from 680/dr25 on: store strings as UTF-8
359 RTL_TEXTENCODING_UTF8);
360 rStream.WriteUInt16( static_cast<sal_uInt16>(m_eSysLanguage) ).WriteUInt16( static_cast<sal_uInt16>(m_eNumFormatLanguage) );
361
362 return ERRCODE_NONE == rStream.GetError();
363}
364
366{
367 m_xAutoFormatUnoObject = xObject.get();
368}
369
371 : m_aName( std::move(aName) )
372 , m_nStrResId( USHRT_MAX )
373 , m_aKeepWithNextPara(std::make_shared<SvxFormatKeepItem>(false, RES_KEEP))
374 , m_aRepeatHeading( 0 )
375 , m_bLayoutSplit( true )
376 , m_bRowSplit( true )
377 , m_bCollapsingBorders(true)
379 , m_bHidden( false )
380 , m_bUserDefined( true )
381{
382 m_bInclFont = true;
383 m_bInclJustify = true;
384 m_bInclFrame = true;
385 m_bInclBackground = true;
386 m_bInclValueFormat = true;
387 m_bInclWidthHeight = true;
388}
389
392{
394 rp = nullptr;
395 *this = rNew;
396}
397
399{
400 if (&rNew == this)
401 return *this;
402
403 for( sal_uInt8 n = 0; n < 16; ++n )
404 {
405 if( m_aBoxAutoFormat[ n ] )
406 delete m_aBoxAutoFormat[ n ];
407
408 SwBoxAutoFormat* pFormat = rNew.m_aBoxAutoFormat[ n ];
409 if( pFormat ) // if is set -> copy
410 m_aBoxAutoFormat[ n ] = new SwBoxAutoFormat( *pFormat );
411 else // else default
412 m_aBoxAutoFormat[ n ] = nullptr;
413 }
414
415 m_aName = rNew.m_aName;
423
424 m_aKeepWithNextPara.reset(rNew.m_aKeepWithNextPara->Clone());
429 m_aShadow.reset(rNew.m_aShadow->Clone());
430 m_bHidden = rNew.m_bHidden;
432
433 return *this;
434}
435
437{
439 for( sal_uInt8 n = 0; n < 16; ++n, ++ppFormat )
440 if( *ppFormat )
441 delete *ppFormat;
442}
443
445{
446 OSL_ENSURE( nPos < 16, "wrong area" );
447
449 if( pFormat ) // if is set -> copy
450 *m_aBoxAutoFormat[ nPos ] = rNew;
451 else // else set anew
452 m_aBoxAutoFormat[ nPos ] = new SwBoxAutoFormat( rNew );
453}
454
456{
457 OSL_ENSURE( nPos < 16, "wrong area" );
458
460 if( pFormat ) // if is set -> copy
461 return *pFormat;
462 else // else return the default
463 {
464 // If it doesn't exist yet:
468 }
469}
470
472{
473 SAL_WARN_IF(!(nPos < 16), "sw.core", "GetBoxFormat wrong area");
474
475 SwBoxAutoFormat** pFormat = &m_aBoxAutoFormat[ nPos ];
476 if( !*pFormat )
477 {
478 // If default doesn't exist yet:
482 }
483 return **pFormat;
484}
485
487{
490
492}
493
495 const SfxItemSet& rSet,
497 SvNumberFormatter const * pNFormatr)
498{
499 OSL_ENSURE( nPos < 16, "wrong area" );
500
502 if( !pFormat ) // if is set -> copy
503 {
504 pFormat = new SwBoxAutoFormat;
505 m_aBoxAutoFormat[ nPos ] = pFormat;
506 }
507
509 {
510 pFormat->SetFont( rSet.Get( RES_CHRATR_FONT ) );
511 pFormat->SetHeight( rSet.Get( RES_CHRATR_FONTSIZE ) );
512 pFormat->SetWeight( rSet.Get( RES_CHRATR_WEIGHT ) );
513 pFormat->SetPosture( rSet.Get( RES_CHRATR_POSTURE ) );
514 pFormat->SetCJKFont( rSet.Get( RES_CHRATR_CJK_FONT ) );
518 pFormat->SetCTLFont( rSet.Get( RES_CHRATR_CTL_FONT ) );
525 pFormat->SetContour( rSet.Get( RES_CHRATR_CONTOUR ) );
527 pFormat->SetColor( rSet.Get( RES_CHRATR_COLOR ) );
528 pFormat->SetAdjust( rSet.Get( RES_PARATR_ADJUST ) );
529 }
530 if( !(SwTableAutoFormatUpdateFlags::Box & eFlags) )
531 return;
532
533 pFormat->SetBox( rSet.Get( RES_BOX ) );
534// FIXME - add attribute IDs for the diagonal line items
535// pFormat->SetTLBR( (SvxLineItem&)rSet.Get( RES_... ) );
536// pFormat->SetBLTR( (SvxLineItem&)rSet.Get( RES_... ) );
537 pFormat->SetBackground( rSet.Get( RES_BACKGROUND ) );
540
541 const SwTableBoxNumFormat* pNumFormatItem;
542 const SvNumberformat* pNumFormat = nullptr;
543 if( pNFormatr && (pNumFormatItem = rSet.GetItemIfSet( RES_BOXATR_FORMAT )) &&
544 nullptr != (pNumFormat = pNFormatr->GetEntry( pNumFormatItem->GetValue() )) )
545 pFormat->SetValueFormat( pNumFormat->GetFormatstring(),
546 pNumFormat->GetLanguage(),
548 else
549 {
550 // default
551 pFormat->SetValueFormat( OUString(), LANGUAGE_SYSTEM,
553 }
554
555 // we cannot handle the rest, that's specific to StarCalc
556}
557
558void SwTableAutoFormat::UpdateToSet(const sal_uInt8 nPos, const bool bSingleRowTable, const bool bSingleColTable, SfxItemSet& rSet,
559 SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter* pNFormatr) const
560{
561 const SwBoxAutoFormat& rChg = GetBoxFormat( nPos );
562
564 {
565 if( IsFont() )
566 {
567 rSet.Put( rChg.GetFont() );
568 rSet.Put( rChg.GetHeight() );
569 rSet.Put( rChg.GetWeight() );
570 rSet.Put( rChg.GetPosture() );
571 // do not insert empty CJK font
572 const SvxFontItem& rCJKFont = rChg.GetCJKFont();
573 if (!rCJKFont.GetStyleName().isEmpty())
574 {
575 rSet.Put( rChg.GetCJKFont() );
576 rSet.Put( rChg.GetCJKHeight() );
577 rSet.Put( rChg.GetCJKWeight() );
578 rSet.Put( rChg.GetCJKPosture() );
579 }
580 else
581 {
582 rSet.Put( rChg.GetHeight().CloneSetWhich(RES_CHRATR_CJK_FONTSIZE) );
583 rSet.Put( rChg.GetWeight().CloneSetWhich(RES_CHRATR_CJK_WEIGHT) );
584 rSet.Put( rChg.GetPosture().CloneSetWhich(RES_CHRATR_CJK_POSTURE) );
585 }
586 // do not insert empty CTL font
587 const SvxFontItem& rCTLFont = rChg.GetCTLFont();
588 if (!rCTLFont.GetStyleName().isEmpty())
589 {
590 rSet.Put( rChg.GetCTLFont() );
591 rSet.Put( rChg.GetCTLHeight() );
592 rSet.Put( rChg.GetCTLWeight() );
593 rSet.Put( rChg.GetCTLPosture() );
594 }
595 else
596 {
597 rSet.Put( rChg.GetHeight().CloneSetWhich(RES_CHRATR_CTL_FONTSIZE) );
598 rSet.Put( rChg.GetWeight().CloneSetWhich(RES_CHRATR_CTL_WEIGHT) );
599 rSet.Put( rChg.GetPosture().CloneSetWhich(RES_CHRATR_CTL_POSTURE) );
600 }
601 rSet.Put( rChg.GetUnderline() );
602 rSet.Put( rChg.GetOverline() );
603 rSet.Put( rChg.GetCrossedOut() );
604 rSet.Put( rChg.GetContour() );
605 rSet.Put( rChg.GetShadowed() );
606 rSet.Put( rChg.GetColor() );
607 }
608 if( IsJustify() )
609 rSet.Put( rChg.GetAdjust() );
610 }
611
612 if( !(SwTableAutoFormatUpdateFlags::Box & eFlags) )
613 return;
614
615 if( IsFrame() )
616 {
617 SvxBoxItem aAutoFormatBox = rChg.GetBox();
618
619 // No format box is adequate to specify the borders of single column/row tables, so combine first/last.
620 if ( bSingleRowTable || bSingleColTable )
621 {
622 sal_uInt8 nSingleRowOrColumnId = 15; //LAST_ROW_END_COLUMN
623 if ( !bSingleRowTable )
624 nSingleRowOrColumnId = nPos + 3; //LAST COLUMN (3, 7, 11, 15)
625 else if ( !bSingleColTable )
626 nSingleRowOrColumnId = nPos + 12; //LAST ROW (12, 13, 14, 15)
627
628 assert( nSingleRowOrColumnId < 16 );
629 const SvxBoxItem aLastAutoFormatBox( GetBoxFormat(nSingleRowOrColumnId).GetBox() );
630 if ( bSingleRowTable )
631 aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM );
632 if ( bSingleColTable )
633 aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT );
634 }
635
636 rSet.Put( aAutoFormatBox );
637// FIXME - uncomment the lines to put the diagonal line items
638// rSet.Put( rChg.GetTLBR() );
639// rSet.Put( rChg.GetBLTR() );
640 }
641 if( IsBackground() )
642 rSet.Put( rChg.GetBackground() );
643
645
646 // Do not put a VertAlign when it has default value.
647 // It prevents the export of default value by automatic cell-styles export.
648 if (rChg.GetVerticalAlignment().GetVertOrient() != GetDefaultBoxFormat().GetVerticalAlignment().GetVertOrient())
650
651 if( !(IsValueFormat() && pNFormatr) )
652 return;
653
654 OUString sFormat;
655 LanguageType eLng, eSys;
656 rChg.GetValueFormat( sFormat, eLng, eSys );
657 if( !sFormat.isEmpty() )
658 {
660 bool bNew;
661 sal_Int32 nCheckPos;
662 sal_uInt32 nKey = pNFormatr->GetIndexPuttingAndConverting( sFormat, eLng,
663 eSys, nType, bNew, nCheckPos);
664 rSet.Put( SwTableBoxNumFormat( nKey ));
665 }
666 else
668
669 // we cannot handle the rest, that's specific to StarCalc
670}
671
673{
674 SwTableFormat* pFormat = table.GetFrameFormat();
675 if (!pFormat)
676 return;
677
678 SwDoc *pDoc = pFormat->GetDoc();
679 if (!pDoc)
680 return;
681
683
686 if ( m_aKeepWithNextPara->GetValue() )
689
690 pFormat->SetFormatAttr(rSet);
691
692 if (SwEditShell *pShell = pDoc->GetEditShell())
693 pDoc->SetRowSplit(*pShell->getShellCursor(false), SwFormatRowSplit(m_bRowSplit));
694
695 table.SetRowsToRepeat(m_aRepeatHeading);
696}
697
699{
700 SwTableFormat* pFormat = table.GetFrameFormat();
701 if (!pFormat)
702 return;
703
704 SwDoc *pDoc = pFormat->GetDoc();
705 if (!pDoc)
706 return;
707
708 SwEditShell *pShell = pDoc->GetEditShell();
709 std::unique_ptr<SwFormatRowSplit> pRowSplit(pShell ? SwDoc::GetRowSplit(*pShell->getShellCursor(false)) : nullptr);
710 m_bRowSplit = pRowSplit && pRowSplit->GetValue();
711 pRowSplit.reset();
712
713 const SfxItemSet &rSet = pFormat->GetAttrSet();
714
715 const SwFormatLayoutSplit &layoutSplit = rSet.Get(RES_LAYOUT_SPLIT);
716 m_bLayoutSplit = layoutSplit.GetValue();
718
720 m_aRepeatHeading = table.GetRowsToRepeat();
722}
723
725{
726 return GetBoxFormat(3) == GetBoxFormat(2);
727}
729{
730 return GetBoxFormat(0) == GetBoxFormat(1);
731}
733{
734 return GetBoxFormat(14) == GetBoxFormat(15);
735}
737{
738 return GetBoxFormat(12) == GetBoxFormat(13);
739}
741{ // Wild guessing for PDF export: is header different from odd or body?
742 // It would be vastly better to do like SdrTableObj and have flags that
743 // determine which "special" styles apply, instead of horrible guessing.
744 return !(GetBoxFormat(1) == GetBoxFormat(5))
745 || !(GetBoxFormat(1) == GetBoxFormat(10));
746}
747
748bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions )
749{
750 sal_uInt16 nVal = 0;
751 rStream.ReadUInt16( nVal );
752 bool bRet = ERRCODE_NONE == rStream.GetError();
753
754 if( bRet && (nVal == AUTOFORMAT_DATA_ID_X ||
755 (AUTOFORMAT_DATA_ID_504 <= nVal && nVal <= AUTOFORMAT_DATA_ID)) )
756 {
757 bool b;
758 // --- from 680/dr25 on: store strings as UTF-8
759 rtl_TextEncoding eCharSet = (nVal >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
760 m_aName = rStream.ReadUniOrByteString( eCharSet );
761 if( AUTOFORMAT_DATA_ID_552 <= nVal )
762 {
763 rStream.ReadUInt16( m_nStrResId );
764 // start from 3d because default is added via constructor
766 {
768 }
769 else
770 m_nStrResId = USHRT_MAX;
771 }
772 rStream.ReadCharAsBool( b ); m_bInclFont = b;
773 rStream.ReadCharAsBool( b ); m_bInclJustify = b;
774 rStream.ReadCharAsBool( b ); m_bInclFrame = b;
775 rStream.ReadCharAsBool( b ); m_bInclBackground = b;
776 rStream.ReadCharAsBool( b ); m_bInclValueFormat = b;
777 rStream.ReadCharAsBool( b ); m_bInclWidthHeight = b;
778
779 if (nVal >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream))
780 {
781 //this only exists for file format compat
782 SvxFormatBreakItem aBreak(SvxBreak::NONE, RES_BREAK);
785
787
789 }
790
791 bRet = ERRCODE_NONE== rStream.GetError();
792
793 for( sal_uInt8 i = 0; bRet && i < 16; ++i )
794 {
795 SwBoxAutoFormat* pFormat = new SwBoxAutoFormat;
796 bRet = pFormat->Load( rStream, rVersions, nVal );
797 if( bRet )
798 m_aBoxAutoFormat[ i ] = pFormat;
799 else
800 {
801 delete pFormat;
802 break;
803 }
804 }
805 }
806 m_bUserDefined = false;
807 return bRet;
808}
809
810bool SwTableAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
811{
813 // --- from 680/dr25 on: store strings as UTF-8
815 RTL_TEXTENCODING_UTF8 );
816 rStream.WriteUInt16( m_nStrResId );
817 rStream.WriteBool( m_bInclFont );
818 rStream.WriteBool( m_bInclJustify );
819 rStream.WriteBool( m_bInclFrame );
820 rStream.WriteBool( m_bInclBackground );
821 rStream.WriteBool( m_bInclValueFormat );
822 rStream.WriteBool( m_bInclWidthHeight );
823
824 {
825 WriterSpecificAutoFormatBlock block(rStream);
826 //this only exists for file format compat
827 SvxFormatBreakItem aBreak(SvxBreak::NONE, RES_BREAK);
832 }
833
834 bool bRet = ERRCODE_NONE == rStream.GetError();
835
836 for( int i = 0; bRet && i < 16; ++i )
837 {
838 SwBoxAutoFormat* pFormat = m_aBoxAutoFormat[ i ];
839 if( !pFormat ) // if not set -> write default
840 {
841 // If it doesn't exist yet:
844 pFormat = s_pDefaultBoxAutoFormat;
845 }
846 bRet = pFormat->Save( rStream, fileVersion );
847 }
848 return bRet;
849}
850
852{
853 sal_Int32 nIndex = 0;
854 for (; nIndex < 16; ++nIndex)
855 if (m_aBoxAutoFormat[nIndex] == &rBoxFormat) break;
856
857 // box format doesn't belong to this table format
858 if (16 <= nIndex)
859 return OUString();
860
861 const std::vector<sal_Int32> aTableTemplateMap = GetTableTemplateMap();
862 for (size_t i=0; i < aTableTemplateMap.size(); ++i)
863 {
864 if (aTableTemplateMap[i] == nIndex)
865 return "." + OUString::number(i + 1);
866 }
867
868 // box format doesn't belong to a table template
869 return OUString();
870}
871
872/*
873 * Mapping schema
874 * 0 1 2 3 4 5
875 * +-----------------------------------------------------------------------+
876 * 0 | FRSC | FR | FREC | | | FRENC |
877 * +-----------------------------------------------------------------------+
878 * 1 | FC | ER | EC | | | LC |
879 * +-----------------------------------------------------------------------+
880 * 2 | OR | OC | BODY | | | BCKG |
881 * +-----------------------------------------------------------------------+
882 * 3 | | | | | | |
883 * +-----------------------------------------------------------------------+
884 * 4 | | | | | | |
885 * +-----------------------------------------------------------------------+
886 * 5 | LRSC | LR | LREC | | | LRENC |
887 * +-----------+-----------+-----------+-----------+-----------+-----------+
888 * ODD = 1, 3, 5, ...
889 * EVEN = 2, 4, 6, ...
890 */
891const std::vector<sal_Int32> & SwTableAutoFormat::GetTableTemplateMap()
892{
893 static std::vector<sal_Int32> const aTableTemplateMap
894 {
895 1 , // FIRST_ROW // FR
896 13, // LAST_ROW // LR
897 4 , // FIRST_COLUMN // FC
898 7 , // LAST_COLUMN // LC
899 5 , // EVEN_ROWS // ER
900 8 , // ODD_ROWS // OR
901 6 , // EVEN_COLUMNS // EC
902 9 , // ODD_COLUMNS // OC
903 10, // BODY
904 11, // BACKGROUND // BCKG
905 0 , // FIRST_ROW_START_COLUMN // FRSC
906 3 , // FIRST_ROW_END_COLUMN // FRENC
907 12, // LAST_ROW_START_COLUMN // LRSC
908 15, // LAST_ROW_END_COLUMN // LRENC
909 2 , // FIRST_ROW_EVEN_COLUMN // FREC
910 14, // LAST_ROW_EVEN_COLUMN // LREC
911 };
912 return aTableTemplateMap;
913}
914
915sal_uInt8 SwTableAutoFormat::CountPos(sal_uInt32 nCol, sal_uInt32 nCols, sal_uInt32 nRow,
916 sal_uInt32 nRows)
917{
918 sal_uInt8 nRet = static_cast<sal_uInt8>(
919 !nRow ? 0 : ((nRow + 1 == nRows) ? 12 : (4 * (1 + ((nRow - 1) & 1)))));
920 nRet = nRet
921 + static_cast<sal_uInt8>(!nCol ? 0 : (nCol + 1 == nCols ? 3 : (1 + ((nCol - 1) & 1))));
922 return nRet;
923}
924
926{
927 m_xUnoTextTableStyle = xObject.get();
928}
929
931{
932 std::vector<std::unique_ptr<SwTableAutoFormat>> m_AutoFormats;
933};
934
936{
937 return m_pImpl->m_AutoFormats.size();
938}
939
941{
942 return *m_pImpl->m_AutoFormats[i];
943}
945{
946 return *m_pImpl->m_AutoFormats[i];
947}
948
950{
951 // don't insert when we already have style of this name
952 if (FindAutoFormat(rTableStyle.GetName()))
953 return;
954
955 InsertAutoFormat(size(), std::make_unique<SwTableAutoFormat>(rTableStyle));
956}
957
958void SwTableAutoFormatTable::InsertAutoFormat(size_t const i, std::unique_ptr<SwTableAutoFormat> pFormat)
959{
960 m_pImpl->m_AutoFormats.insert(m_pImpl->m_AutoFormats.begin() + i, std::move(pFormat));
961}
962
964{
965 m_pImpl->m_AutoFormats.erase(m_pImpl->m_AutoFormats.begin() + i);
966}
967
969{
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())
973 {
974 m_pImpl->m_AutoFormats.erase(iter);
975 return;
976 }
977 SAL_INFO("sw.core", "SwTableAutoFormatTable::EraseAutoFormat, SwTableAutoFormat with given name not found");
978}
979
980std::unique_ptr<SwTableAutoFormat> SwTableAutoFormatTable::ReleaseAutoFormat(size_t const i)
981{
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);
985 return pRet;
986}
987
988std::unique_ptr<SwTableAutoFormat> SwTableAutoFormatTable::ReleaseAutoFormat(const OUString& rName)
989{
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())
994 {
995 pRet = std::move(*iter);
996 m_pImpl->m_AutoFormats.erase(iter);
997 }
998 return pRet;
999}
1000
1002{
1003 for (const auto &rFormat : m_pImpl->m_AutoFormats)
1004 {
1005 if (rFormat->GetName() == rName)
1006 return rFormat.get();
1007 }
1008
1009 return nullptr;
1010}
1011
1013{
1014}
1015
1017 : m_pImpl(new Impl)
1018{
1019 std::unique_ptr<SwTableAutoFormat> pNew(new SwTableAutoFormat(
1021
1022 sal_uInt8 i;
1023
1024 Color aColor( COL_BLACK );
1025 SvxBoxItem aBox( RES_BOX );
1026
1027 aBox.SetAllDistances(55);
1028 SvxBorderLine aLn( &aColor, SvxBorderLineWidth::VeryThin );
1029 aBox.SetLine( &aLn, SvxBoxItemLine::LEFT );
1030 aBox.SetLine( &aLn, SvxBoxItemLine::BOTTOM );
1031
1032 for( i = 0; i <= 15; ++i )
1033 {
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 );
1037 }
1038
1039 pNew->SetUserDefined(false);
1040 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1041}
1042
1044{
1046 return;
1047 OUString sNm(AUTOTABLE_FORMAT_NAME);
1048 SvtPathOptions aOpt;
1049 if( aOpt.SearchFile( sNm ))
1050 {
1051 SfxMedium aStream( sNm, StreamMode::STD_READ );
1052 Load( *aStream.GetInStream() );
1053 }
1054}
1055
1057{
1059 return false;
1060 SvtPathOptions aPathOpt;
1061 const OUString sNm( aPathOpt.GetUserConfigPath() + "/" + AUTOTABLE_FORMAT_NAME );
1062 SfxMedium aStream(sNm, StreamMode::STD_WRITE );
1063 return Save( *aStream.GetOutStream() ) && aStream.Commit();
1064}
1065
1067{
1068 bool bRet = ERRCODE_NONE == rStream.GetError();
1069 if (bRet)
1070 {
1071 // Attention: We need to read a general Header here
1072 sal_uInt16 nVal = 0;
1073 rStream.ReadUInt16( nVal );
1074 bRet = ERRCODE_NONE == rStream.GetError();
1075
1076 if( bRet )
1077 {
1078 SwAfVersions aVersions;
1079
1080 // Default version is 5.0, unless we detect an old format ID.
1081 sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_50;
1082 if(nVal < AUTOFORMAT_ID_31005)
1083 nFileVers = SOFFICE_FILEFORMAT_40;
1084
1085 if( nVal == AUTOFORMAT_ID_358 ||
1086 (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
1087 {
1088 sal_uInt8 nChrSet, nCnt;
1089 sal_uInt64 nPos = rStream.Tell();
1090 rStream.ReadUChar( nCnt ).ReadUChar( nChrSet );
1091 if( rStream.Tell() != nPos + nCnt )
1092 {
1093 OSL_ENSURE( false, "The Header contains more or newer Data" );
1094 rStream.Seek( nPos + nCnt );
1095 }
1096 rStream.SetStreamCharSet( static_cast<rtl_TextEncoding>(nChrSet) );
1097 rStream.SetVersion( nFileVers );
1098 }
1099
1100 if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
1101 (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
1102 {
1103 aVersions.Load( rStream, nVal ); // Item versions
1104
1105 sal_uInt16 nCount = 0;
1106 rStream.ReadUInt16( nCount );
1107
1108 bRet = ERRCODE_NONE== rStream.GetError();
1109 if (bRet)
1110 {
1111 const size_t nMinRecordSize = sizeof(sal_uInt16);
1112 const size_t nMaxRecords = rStream.remainingSize() / nMinRecordSize;
1113 if (nCount > nMaxRecords)
1114 {
1115 SAL_WARN("sw.core", "Parsing error: " << nMaxRecords <<
1116 " max possible entries, but " << nCount << " claimed, truncating");
1117 nCount = nMaxRecords;
1118 }
1119 for (sal_uInt16 i = 0; i < nCount; ++i)
1120 {
1121 std::unique_ptr<SwTableAutoFormat> pNew(
1122 new SwTableAutoFormat( OUString() ));
1123 bRet = pNew->Load( rStream, aVersions );
1124 if( bRet )
1125 {
1126 m_pImpl->m_AutoFormats.push_back(std::move(pNew));
1127 }
1128 else
1129 {
1130 break;
1131 }
1132 }
1133 }
1134 }
1135 else
1136 {
1137 bRet = false;
1138 }
1139 }
1140 }
1141 return bRet;
1142}
1143
1145{
1146 bool bRet = ERRCODE_NONE == rStream.GetError();
1147 if (bRet)
1148 {
1150
1151 // Attention: We need to save a general Header here
1152 rStream.WriteUInt16( AUTOFORMAT_ID )
1153 .WriteUChar( 2 ) // Character count of the Header including this value
1154 .WriteUChar( GetStoreCharSet( ::osl_getThreadTextEncoding() ) );
1155
1156 bRet = ERRCODE_NONE == rStream.GetError();
1157 if (!bRet)
1158 return false;
1159
1160 // Write this version number for all attributes
1162
1163 rStream.WriteUInt16( m_pImpl->m_AutoFormats.size() - 1 );
1164 bRet = ERRCODE_NONE == rStream.GetError();
1165
1166 for (size_t i = 1; bRet && i < m_pImpl->m_AutoFormats.size(); ++i)
1167 {
1168 SwTableAutoFormat const& rFormat = *m_pImpl->m_AutoFormats[i];
1169 bRet = rFormat.Save(rStream, AUTOFORMAT_FILE_VERSION);
1170 }
1171 }
1172 rStream.FlushBuffer();
1173 return bRet;
1174}
1175
1177{ }
1178
1180{
1181}
1182
1184{
1185 return m_aCellStyles.size();
1186}
1187
1189{
1190 m_aCellStyles.clear();
1191}
1192
1194{
1196}
1197
1198void SwCellStyleTable::AddBoxFormat(const SwBoxAutoFormat& rBoxFormat, const OUString& sName)
1199{
1200 m_aCellStyles.emplace_back(sName, std::make_unique<SwBoxAutoFormat>(rBoxFormat));
1201}
1202
1203void SwCellStyleTable::RemoveBoxFormat(const OUString& sName)
1204{
1205 auto iter = std::find_if(m_aCellStyles.begin(), m_aCellStyles.end(),
1206 [&sName](const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rStyle) { return rStyle.first == sName; });
1207 if (iter != m_aCellStyles.end())
1208 {
1209 m_aCellStyles.erase(iter);
1210 return;
1211 }
1212 SAL_INFO("sw.core", "SwCellStyleTable::RemoveBoxFormat, format with given name doesn't exists");
1213}
1214
1216{
1217 for (size_t i=0; i < m_aCellStyles.size(); ++i)
1218 {
1219 if (m_aCellStyles[i].second.get() == &rBoxFormat)
1220 return m_aCellStyles[i].first;
1221 }
1222
1223 // box format not found
1224 return OUString();
1225}
1226
1227SwBoxAutoFormat* SwCellStyleTable::GetBoxFormat(std::u16string_view sName) const
1228{
1229 for (size_t i=0; i < m_aCellStyles.size(); ++i)
1230 {
1231 if (m_aCellStyles[i].first == sName)
1232 return m_aCellStyles[i].second.get();
1233 }
1234
1235 return nullptr;
1236}
1237
1238void SwCellStyleTable::ChangeBoxFormatName(std::u16string_view sFromName, const OUString& sToName)
1239{
1240 if (!GetBoxFormat(sToName))
1241 {
1242 SAL_INFO("sw.core", "SwCellStyleTable::ChangeBoxName, box with given name already exists");
1243 return;
1244 }
1245 for (size_t i=0; i < m_aCellStyles.size(); ++i)
1246 {
1247 if (m_aCellStyles[i].first == sFromName)
1248 {
1249 m_aCellStyles[i].first = sToName;
1250 // changed successfully
1251 return;
1252 }
1253 }
1254 SAL_INFO("sw.core", "SwCellStyleTable::ChangeBoxName, box with given name not found");
1255}
1256/* 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:82
void SetTextOrientation(const SvxFrameDirectionItem &rNew)
Definition: tblafmt.hxx:87
OUString m_sNumFormatString
Definition: tblafmt.hxx:57
const LanguageType & GetNumFormatLanguage() const
Definition: tblafmt.hxx:84
const LanguageType & GetSysLanguage() const
Definition: tblafmt.hxx:83
void GetValueFormat(OUString &rFormat, LanguageType &rLng, LanguageType &rSys) const
Definition: tblafmt.hxx:79
void SetSysLanguage(const LanguageType &rNew)
Definition: tblafmt.hxx:94
std::unique_ptr< SwFormatVertOrient > m_aVerticalAlignment
Definition: tblafmt.hxx:54
void SetNumFormatString(const OUString &rNew)
Definition: tblafmt.hxx:93
std::unique_ptr< SvxFrameDirectionItem > m_aTextOrientation
Definition: tblafmt.hxx:53
const SwFormatVertOrient & GetVerticalAlignment() const
Definition: tblafmt.hxx:77
unotools::WeakReference< SwXTextCellStyle > m_xAutoFormatUnoObject
Definition: tblafmt.hxx:62
LanguageType m_eNumFormatLanguage
Definition: tblafmt.hxx:59
void SetXObject(rtl::Reference< SwXTextCellStyle > const &xObject)
Definition: tblafmt.cxx:365
void SetVerticalAlignment(const SwFormatVertOrient &rNew)
Definition: tblafmt.hxx:88
bool Load(SvStream &rStream, const SwAfVersions &rVersions, sal_uInt16 nVer)
Definition: tblafmt.cxx:310
SwBoxAutoFormat & operator=(const SwBoxAutoFormat &rRef)
assignment-op (still used)
Definition: tblafmt.cxx:280
void SetNumFormatLanguage(const LanguageType &rNew)
Definition: tblafmt.hxx:95
LanguageType m_eSysLanguage
Definition: tblafmt.hxx:58
void SetValueFormat(const OUString &rFormat, LanguageType eLng, LanguageType eSys)
Definition: tblafmt.hxx:90
bool operator==(const SwBoxAutoFormat &rRight) const
Comparing based of boxes backgrounds.
Definition: tblafmt.cxx:305
bool Save(SvStream &rStream, sal_uInt16 fileVersion) const
Definition: tblafmt.cxx:343
const SvxFrameDirectionItem & GetTextOrientation() const
Definition: tblafmt.hxx:76
OUString GetBoxFormatName(const SwBoxAutoFormat &rBoxFormat) const
If found returns its name. If not found returns an empty OUString.
Definition: tblafmt.cxx:1215
void ChangeBoxFormatName(std::u16string_view sFromName, const OUString &sToName)
Definition: tblafmt.cxx:1238
size_t size() const
Definition: tblafmt.cxx:1183
void AddBoxFormat(const SwBoxAutoFormat &rBoxFormat, const OUString &sName)
Add a copy of rBoxFormat.
Definition: tblafmt.cxx:1198
SwCellStyleDescriptor operator[](size_t i) const
Definition: tblafmt.cxx:1193
std::vector< std::pair< OUString, std::unique_ptr< SwBoxAutoFormat > > > m_aCellStyles
Definition: tblafmt.hxx:310
SwBoxAutoFormat * GetBoxFormat(std::u16string_view sName) const
If found returns a ptr to a BoxFormat. If not found returns nullptr.
Definition: tblafmt.cxx:1227
void RemoveBoxFormat(const OUString &sName)
Definition: tblafmt.cxx:1203
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3356
Definition: doc.hxx:197
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:1337
Controls if a table row is allowed to split or not.
Definition: fmtrowsplt.hxx:32
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:57
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:447
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
void AddAutoFormat(const SwTableAutoFormat &rFormat)
Append table style to the existing styles.
Definition: tblafmt.cxx:949
std::unique_ptr< Impl > m_pImpl
Definition: tblafmt.hxx:268
size_t size() const
Definition: tblafmt.cxx:935
std::unique_ptr< SwTableAutoFormat > ReleaseAutoFormat(size_t i)
Definition: tblafmt.cxx:980
SwTableAutoFormat const & operator[](size_t i) const
Definition: tblafmt.cxx:940
void EraseAutoFormat(size_t i)
Definition: tblafmt.cxx:963
void InsertAutoFormat(size_t i, std::unique_ptr< SwTableAutoFormat > pFormat)
Definition: tblafmt.cxx:958
SwTableAutoFormat * FindAutoFormat(std::u16string_view rName) const
Find table style with the provided name, return nullptr when not found.
Definition: tblafmt.cxx:1001
void SetBoxFormat(const SwBoxAutoFormat &rNew, sal_uInt8 nPos)
Definition: tblafmt.cxx:444
static const SwBoxAutoFormat & GetDefaultBoxFormat()
Definition: tblafmt.cxx:486
bool IsJustify() const
Definition: tblafmt.hxx:218
bool m_bInclWidthHeight
Definition: tblafmt.hxx:173
const SwBoxAutoFormat & GetBoxFormat(sal_uInt8 nPos) const
Definition: tblafmt.cxx:455
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:915
bool HasHeaderRow() const
Definition: tblafmt.cxx:740
unotools::WeakReference< SwXTextTableStyle > m_xUnoTextTableStyle
Definition: tblafmt.hxx:160
void UpdateToSet(const sal_uInt8 nPos, const bool bSingleRowTable, const bool bSingleColTable, SfxItemSet &rSet, SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter *) const
Definition: tblafmt.cxx:558
void UpdateFromSet(sal_uInt8 nPos, const SfxItemSet &rSet, SwTableAutoFormatUpdateFlags eFlags, SvNumberFormatter const *)
Definition: tblafmt.cxx:494
bool FirstRowStartColumnIsRow()
Definition: tblafmt.cxx:728
bool m_bInclValueFormat
Definition: tblafmt.hxx:170
SwTableAutoFormat(OUString aName)
Definition: tblafmt.cxx:370
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:891
sal_uInt16 m_aRepeatHeading
Definition: tblafmt.hxx:179
SwBoxAutoFormat * m_aBoxAutoFormat[16]
Definition: tblafmt.hxx:175
bool m_bCollapsingBorders
Definition: tblafmt.hxx:182
std::shared_ptr< SvxShadowItem > m_aShadow
Definition: tblafmt.hxx:183
bool Save(SvStream &rStream, sal_uInt16 fileVersion) const
Definition: tblafmt.cxx:810
bool IsValueFormat() const
Definition: tblafmt.hxx:221
sal_uInt16 m_nStrResId
Definition: tblafmt.hxx:163
bool IsBackground() const
Definition: tblafmt.hxx:220
bool LastRowStartColumnIsRow()
Definition: tblafmt.cxx:736
SwTableAutoFormat & operator=(const SwTableAutoFormat &rNew)
Definition: tblafmt.cxx:398
bool IsFont() const
Definition: tblafmt.hxx:217
bool LastRowEndColumnIsRow()
Definition: tblafmt.cxx:732
void StoreTableProperties(const SwTable &table)
Definition: tblafmt.cxx:698
void SetXObject(rtl::Reference< SwXTextTableStyle > const &xObject)
Definition: tblafmt.cxx:925
OUString m_aName
Definition: tblafmt.hxx:162
void RestoreTableProperties(SwTable &table) const
Definition: tblafmt.cxx:672
const OUString & GetName() const
Definition: tblafmt.hxx:206
bool m_bInclBackground
Definition: tblafmt.hxx:169
OUString GetTableTemplateCellSubName(const SwBoxAutoFormat &rBoxFormat) const
Returns the cell's name postfix. eg. ".1".
Definition: tblafmt.cxx:851
bool IsFrame() const
Definition: tblafmt.hxx:219
std::shared_ptr< SvxFormatKeepItem > m_aKeepWithNextPara
Definition: tblafmt.hxx:178
static SwBoxAutoFormat * s_pDefaultBoxAutoFormat
Definition: tblafmt.hxx:158
bool FirstRowEndColumnIsRow()
These methods returns what style (row or column) is applied first on given Cell.
Definition: tblafmt.cxx:724
bool Load(SvStream &rStream, const SwAfVersions &)
Definition: tblafmt.cxx:748
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
OUString sName
SvxFrameDirection
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.
Definition: hints.cxx:147
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:741
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)
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:203
sal_uInt16 m_nVerticalAlignmentVersion
Definition: tblafmt.cxx:179
void Load(SvStream &rStream, sal_uInt16 nVer)
Definition: tblafmt.cxx:192
sal_uInt16 m_nTextOrientationVersion
Definition: tblafmt.cxx:178
std::vector< std::unique_ptr< SwTableAutoFormat > > m_AutoFormats
Definition: tblafmt.cxx:932
const sal_uInt16 AUTOFORMAT_ID
Definition: tblafmt.cxx:98
const sal_uInt16 AUTOFORMAT_ID_680DR25
Definition: tblafmt.cxx:91
const sal_uInt16 AUTOFORMAT_DATA_ID_31005
Definition: tblafmt.cxx:95
const sal_uInt16 AUTOFORMAT_DATA_ID_504
Definition: tblafmt.cxx:86
const sal_uInt16 AUTOFORMAT_ID_358
Definition: tblafmt.cxx:80
constexpr OUStringLiteral AUTOTABLE_FORMAT_NAME
Definition: tblafmt.cxx:104
const sal_uInt16 AUTOFORMAT_ID_504
In follow-up versions these IDs' values need to increase.
Definition: tblafmt.cxx:85
const sal_uInt16 AUTOFORMAT_FILE_VERSION
Definition: tblafmt.cxx:100
const sal_uInt16 AUTOFORMAT_ID_X
Definition: tblafmt.cxx:79
const sal_uInt16 AUTOFORMAT_DATA_ID_552
Definition: tblafmt.cxx:88
const sal_uInt16 AUTOFORMAT_DATA_ID
Definition: tblafmt.cxx:99
const sal_uInt16 AUTOFORMAT_ID_31005
Definition: tblafmt.cxx:94
const sal_uInt16 AUTOFORMAT_DATA_ID_X
Definition: tblafmt.cxx:81
SwTableAutoFormatUpdateFlags
Definition: tblafmt.hxx:105
unsigned char sal_uInt8
SvNumFormatType