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