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