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