LibreOffice Module sc (master)  1
autoform.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 <memory>
21 #include <autoform.hxx>
22 
23 #include <sfx2/docfile.hxx>
24 #include <unotools/pathoptions.hxx>
25 #include <svl/intitem.hxx>
26 #include <svl/itemset.hxx>
27 #include <vcl/outdev.hxx>
28 #include <svx/algitem.hxx>
29 #include <svx/dialmgr.hxx>
30 #include <svx/rotmodit.hxx>
31 #include <svx/strings.hrc>
32 #include <editeng/adjustitem.hxx>
33 #include <editeng/borderline.hxx>
34 #include <editeng/boxitem.hxx>
35 #include <editeng/brushitem.hxx>
36 #include <editeng/colritem.hxx>
37 #include <editeng/contouritem.hxx>
39 #include <editeng/fhgtitem.hxx>
40 #include <editeng/fontitem.hxx>
41 #include <editeng/justifyitem.hxx>
42 #include <editeng/langitem.hxx>
43 #include <editeng/lineitem.hxx>
44 #include <editeng/postitem.hxx>
45 #include <editeng/shdditem.hxx>
46 #include <editeng/udlnitem.hxx>
47 #include <editeng/wghtitem.hxx>
48 #include <tools/urlobj.hxx>
49 #include <comphelper/fileformat.h>
52 #include <tools/tenccvt.hxx>
53 #include <osl/diagnose.h>
54 #include <osl/thread.hxx>
55 
56 #include <attrib.hxx>
57 #include <globstr.hrc>
58 #include <scitems.hxx>
59 #include <scresid.hxx>
60 #include <document.hxx>
61 
62 /*
63  * XXX: BIG RED NOTICE! Changes MUST be binary file format compatible and MUST
64  * be synchronized with Writer's SwTableAutoFmtTbl sw/source/core/doc/tblafmt.cxx
65  */
66 
67 constexpr OUStringLiteral sAutoTblFmtName = u"autotbl.fmt";
68 
69 // till SO5PF
70 const sal_uInt16 AUTOFORMAT_ID_X = 9501;
71 const sal_uInt16 AUTOFORMAT_ID_358 = 9601;
72 const sal_uInt16 AUTOFORMAT_DATA_ID_X = 9502;
73 
74 // from SO5 on
75 // in following versions the value of the IDs must be higher
76 const sal_uInt16 AUTOFORMAT_ID_504 = 9801;
77 const sal_uInt16 AUTOFORMAT_DATA_ID_504 = 9802;
78 
79 const sal_uInt16 AUTOFORMAT_DATA_ID_552 = 9902;
80 
81 // --- from 680/dr25 on: store strings as UTF-8
82 const sal_uInt16 AUTOFORMAT_ID_680DR25 = 10021;
83 
84 // --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
85 const sal_uInt16 AUTOFORMAT_ID_31005 = 10041;
86 const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
87 
88 // current version
91 
92 namespace
93 {
96  {
97  blob.Reset();
98 
99  sal_uInt64 endOfBlob = 0;
100  stream.ReadUInt64( endOfBlob );
101 
102  const sal_uInt64 currentPosition = stream.Tell();
103  const sal_uInt64 blobSize = endOfBlob - currentPosition;
104  // A zero-size indicates an empty blob. This happens when Calc creates a new autoformat,
105  // since it (naturally) doesn't have any writer-specific data to write.
106  if (blobSize)
107  {
108  blob.pData.reset(new sal_uInt8[blobSize]);
109  blob.size = static_cast<std::size_t>(blobSize);
110  stream.ReadBytes(blob.pData.get(), blob.size);
111  }
112 
113  return stream;
114  }
115 
117  SvStream& WriteAutoFormatSwBlob(SvStream &stream, const AutoFormatSwBlob &blob)
118  {
119  const sal_uInt64 endOfBlob = stream.Tell() + sizeof(sal_uInt64) + blob.size;
120  stream.WriteUInt64( endOfBlob );
121  if (blob.size)
122  stream.WriteBytes(blob.pData.get(), blob.size);
123 
124  return stream;
125  }
126 }
127 
130  swVersions()
131 {
132 }
133 
134 void ScAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
135 {
136  LoadBlockA(rStream, nVer);
137  if (nVer >= AUTOFORMAT_ID_31005)
138  {
139  rStream >> swVersions;
140  }
141  LoadBlockB(rStream, nVer);
142 }
143 
144 void ScAfVersions::Write(SvStream& rStream, sal_uInt16 fileVersion)
145 {
146  AutoFormatVersions::WriteBlockA(rStream, fileVersion);
147 
148  if (fileVersion >= SOFFICE_FILEFORMAT_50)
149  {
150  WriteAutoFormatSwBlob( rStream, swVersions );
151  }
152 
153  AutoFormatVersions::WriteBlockB(rStream, fileVersion);
154 }
155 
157 : AutoFormatBase(),
158  m_swFields(),
159  aNumFormat()
160 {
161  // need to set default instances for base class AutoFormatBase here
162  // due to resource defines (e.g. ATTR_FONT) which are not available
163  // in svx and different in the different usages of derivations
164  m_aFont = std::make_unique<SvxFontItem>(ATTR_FONT);
165  m_aHeight = std::make_unique<SvxFontHeightItem>(240, 100, ATTR_FONT_HEIGHT);
166  m_aWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, ATTR_FONT_WEIGHT);
167  m_aPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, ATTR_FONT_POSTURE);
168  m_aCJKFont = std::make_unique<SvxFontItem>(ATTR_CJK_FONT);
169  m_aCJKHeight = std::make_unique<SvxFontHeightItem>(240, 100, ATTR_CJK_FONT_HEIGHT);
170  m_aCJKWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, ATTR_CJK_FONT_WEIGHT);
171  m_aCJKPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, ATTR_CJK_FONT_POSTURE);
172  m_aCTLFont = std::make_unique<SvxFontItem>(ATTR_CTL_FONT);
173  m_aCTLHeight = std::make_unique<SvxFontHeightItem>(240, 100, ATTR_CTL_FONT_HEIGHT);
174  m_aCTLWeight = std::make_unique<SvxWeightItem>(WEIGHT_NORMAL, ATTR_CTL_FONT_WEIGHT);
175  m_aCTLPosture = std::make_unique<SvxPostureItem>(ITALIC_NONE, ATTR_CTL_FONT_POSTURE);
176  m_aUnderline = std::make_unique<SvxUnderlineItem>(LINESTYLE_NONE,ATTR_FONT_UNDERLINE);
177  m_aOverline = std::make_unique<SvxOverlineItem>(LINESTYLE_NONE,ATTR_FONT_OVERLINE);
178  m_aCrossedOut = std::make_unique<SvxCrossedOutItem>(STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT);
179  m_aContour = std::make_unique<SvxContourItem>(false, ATTR_FONT_CONTOUR);
180  m_aShadowed = std::make_unique<SvxShadowedItem>(false, ATTR_FONT_SHADOWED);
181  m_aColor = std::make_unique<SvxColorItem>(ATTR_FONT_COLOR);
182  m_aBox = std::make_unique<SvxBoxItem>(ATTR_BORDER);
183  m_aTLBR = std::make_unique<SvxLineItem>(ATTR_BORDER_TLBR);
184  m_aBLTR = std::make_unique<SvxLineItem>(ATTR_BORDER_BLTR);
185  m_aBackground = std::make_unique<SvxBrushItem>(ATTR_BACKGROUND);
186  m_aAdjust = std::make_unique<SvxAdjustItem>(SvxAdjust::Left, 0);
187  m_aHorJustify = std::make_unique<SvxHorJustifyItem>(SvxCellHorJustify::Standard, ATTR_HOR_JUSTIFY);
188  m_aVerJustify = std::make_unique<SvxVerJustifyItem>(SvxCellVerJustify::Standard, ATTR_VER_JUSTIFY);
189  m_aStacked = std::make_unique<ScVerticalStackCell>();
190  m_aMargin = std::make_unique<SvxMarginItem>(ATTR_MARGIN);
191  m_aLinebreak = std::make_unique<ScLineBreakCell>();
192  m_aRotateAngle = std::make_unique<ScRotateValueItem>(0_deg100);
193  m_aRotateMode = std::make_unique<SvxRotateModeItem>(SVX_ROTATE_MODE_STANDARD, ATTR_ROTATE_MODE);
194 }
195 
197 : AutoFormatBase(rCopy),
198  m_swFields(), // was not copied in original, needed?
199  aNumFormat( rCopy.aNumFormat )
200 {
201 }
202 
204 {
205 }
206 
207 bool ScAutoFormatDataField::Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer )
208 {
209  LoadBlockA( rStream, rVersions, nVer );
210 
211  if (nVer >= AUTOFORMAT_DATA_ID_31005)
212  {
213  rStream >> m_swFields;
214  }
215 
216  LoadBlockB( rStream, rVersions, nVer );
217 
218  if( 0 == rVersions.nNumFormatVersion )
219  {
220  // --- from 680/dr25 on: store strings as UTF-8
221  rtl_TextEncoding eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
222  aNumFormat.Load( rStream, eCharSet );
223  }
224 
225  // adjust charset in font
226  rtl_TextEncoding eSysSet = osl_getThreadTextEncoding();
227  rtl_TextEncoding eSrcSet = rStream.GetStreamCharSet();
228  if( eSrcSet != eSysSet && m_aFont->GetCharSet() == eSrcSet )
229  m_aFont->SetCharSet(eSysSet);
230 
231  return (rStream.GetError() == ERRCODE_NONE);
232 }
233 
234 bool ScAutoFormatDataField::Save( SvStream& rStream, sal_uInt16 fileVersion )
235 {
236  SaveBlockA( rStream, fileVersion );
237 
238  if (fileVersion >= SOFFICE_FILEFORMAT_50)
239  {
240  WriteAutoFormatSwBlob( rStream, m_swFields );
241  }
242 
243  SaveBlockB( rStream, fileVersion );
244 
245  // --- from 680/dr25 on: store strings as UTF-8
246  aNumFormat.Save( rStream, RTL_TEXTENCODING_UTF8 );
247 
248  return (rStream.GetError() == ERRCODE_NONE);
249 }
250 
252 {
254 
256  bIncludeFont =
258  bIncludeFrame =
260  bIncludeWidthHeight = true;
261 
262  for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
263  ppDataField[ nIndex ].reset( new ScAutoFormatDataField );
264 }
265 
267  aName( rData.aName ),
268  nStrResId( rData.nStrResId ),
269  bIncludeFont( rData.bIncludeFont ),
270  bIncludeJustify( rData.bIncludeJustify ),
271  bIncludeFrame( rData.bIncludeFrame ),
272  bIncludeBackground( rData.bIncludeBackground ),
273  bIncludeValueFormat( rData.bIncludeValueFormat ),
274  bIncludeWidthHeight( rData.bIncludeWidthHeight )
275 {
276  for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
277  ppDataField[ nIndex ].reset( new ScAutoFormatDataField( rData.GetField( nIndex ) ) );
278 }
279 
281 {
282 }
283 
285 {
286  OSL_ENSURE( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
287  OSL_ENSURE( ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
288  return *ppDataField[ nIndex ];
289 }
290 
291 const ScAutoFormatDataField& ScAutoFormatData::GetField( sal_uInt16 nIndex ) const
292 {
293  OSL_ENSURE( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
294  OSL_ENSURE( ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
295  return *ppDataField[ nIndex ];
296 }
297 
298 const SfxPoolItem* ScAutoFormatData::GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const
299 {
300  const ScAutoFormatDataField& rField = GetField( nIndex );
301  switch( nWhich )
302  {
303  case ATTR_FONT: return &rField.GetFont();
304  case ATTR_FONT_HEIGHT: return &rField.GetHeight();
305  case ATTR_FONT_WEIGHT: return &rField.GetWeight();
306  case ATTR_FONT_POSTURE: return &rField.GetPosture();
307  case ATTR_CJK_FONT: return &rField.GetCJKFont();
308  case ATTR_CJK_FONT_HEIGHT: return &rField.GetCJKHeight();
309  case ATTR_CJK_FONT_WEIGHT: return &rField.GetCJKWeight();
310  case ATTR_CJK_FONT_POSTURE: return &rField.GetCJKPosture();
311  case ATTR_CTL_FONT: return &rField.GetCTLFont();
312  case ATTR_CTL_FONT_HEIGHT: return &rField.GetCTLHeight();
313  case ATTR_CTL_FONT_WEIGHT: return &rField.GetCTLWeight();
314  case ATTR_CTL_FONT_POSTURE: return &rField.GetCTLPosture();
315  case ATTR_FONT_UNDERLINE: return &rField.GetUnderline();
316  case ATTR_FONT_OVERLINE: return &rField.GetOverline();
317  case ATTR_FONT_CROSSEDOUT: return &rField.GetCrossedOut();
318  case ATTR_FONT_CONTOUR: return &rField.GetContour();
319  case ATTR_FONT_SHADOWED: return &rField.GetShadowed();
320  case ATTR_FONT_COLOR: return &rField.GetColor();
321  case ATTR_BORDER: return &rField.GetBox();
322  case ATTR_BORDER_TLBR: return &rField.GetTLBR();
323  case ATTR_BORDER_BLTR: return &rField.GetBLTR();
324  case ATTR_BACKGROUND: return &rField.GetBackground();
325  case ATTR_HOR_JUSTIFY: return &rField.GetHorJustify();
326  case ATTR_VER_JUSTIFY: return &rField.GetVerJustify();
327  case ATTR_STACKED: return &rField.GetStacked();
328  case ATTR_MARGIN: return &rField.GetMargin();
329  case ATTR_LINEBREAK: return &rField.GetLinebreak();
330  case ATTR_ROTATE_VALUE: return &rField.GetRotateAngle();
331  case ATTR_ROTATE_MODE: return &rField.GetRotateMode();
332  }
333  return nullptr;
334 }
335 
336 void ScAutoFormatData::PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem )
337 {
338  ScAutoFormatDataField& rField = GetField( nIndex );
339  switch( rItem.Which() )
340  {
341  case ATTR_FONT: rField.SetFont( rItem.StaticWhichCast(ATTR_FONT) ); break;
342  case ATTR_FONT_HEIGHT: rField.SetHeight( rItem.StaticWhichCast(ATTR_FONT_HEIGHT) ); break;
343  case ATTR_FONT_WEIGHT: rField.SetWeight( rItem.StaticWhichCast(ATTR_FONT_WEIGHT) ); break;
344  case ATTR_FONT_POSTURE: rField.SetPosture( rItem.StaticWhichCast(ATTR_FONT_POSTURE) ); break;
345  case ATTR_CJK_FONT: rField.SetCJKFont( rItem.StaticWhichCast(ATTR_CJK_FONT) ); break;
349  case ATTR_CTL_FONT: rField.SetCTLFont( rItem.StaticWhichCast(ATTR_CTL_FONT) ); break;
356  case ATTR_FONT_CONTOUR: rField.SetContour( rItem.StaticWhichCast(ATTR_FONT_CONTOUR) ); break;
358  case ATTR_FONT_COLOR: rField.SetColor( rItem.StaticWhichCast(ATTR_FONT_COLOR) ); break;
359  case ATTR_BORDER: rField.SetBox( rItem.StaticWhichCast(ATTR_BORDER) ); break;
360  case ATTR_BORDER_TLBR: rField.SetTLBR( rItem.StaticWhichCast(ATTR_BORDER_TLBR) ); break;
361  case ATTR_BORDER_BLTR: rField.SetBLTR( rItem.StaticWhichCast(ATTR_BORDER_BLTR) ); break;
362  case ATTR_BACKGROUND: rField.SetBackground( rItem.StaticWhichCast(ATTR_BACKGROUND) ); break;
363  case ATTR_HOR_JUSTIFY: rField.SetHorJustify( rItem.StaticWhichCast(ATTR_HOR_JUSTIFY) ); break;
364  case ATTR_VER_JUSTIFY: rField.SetVerJustify( rItem.StaticWhichCast(ATTR_VER_JUSTIFY) ); break;
365  case ATTR_STACKED: rField.SetStacked( rItem.StaticWhichCast(ATTR_STACKED) ); break;
366  case ATTR_MARGIN: rField.SetMargin( rItem.StaticWhichCast(ATTR_MARGIN) ); break;
367  case ATTR_LINEBREAK: rField.SetLinebreak( rItem.StaticWhichCast(ATTR_LINEBREAK) ); break;
369  case ATTR_ROTATE_MODE: rField.SetRotateMode( rItem.StaticWhichCast(ATTR_ROTATE_MODE) ); break;
370  }
371 }
372 
373 void ScAutoFormatData::CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich )
374 {
375  const SfxPoolItem* pItem = GetItem( nFromIndex, nWhich );
376  if( pItem )
377  PutItem( nToIndex, *pItem );
378 }
379 
380 const ScNumFormatAbbrev& ScAutoFormatData::GetNumFormat( sal_uInt16 nIndex ) const
381 {
382  return GetField( nIndex ).GetNumFormat();
383 }
384 
385 bool ScAutoFormatData::IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const
386 {
387  bool bEqual = true;
388  const ScAutoFormatDataField& rField1 = GetField( nIndex1 );
389  const ScAutoFormatDataField& rField2 = GetField( nIndex2 );
390 
391  if( bIncludeValueFormat )
392  {
393  bEqual = bEqual
394  && (rField1.GetNumFormat() == rField2.GetNumFormat());
395  }
396  if( bIncludeFont )
397  {
398  bEqual = bEqual
399  && (rField1.GetFont() == rField2.GetFont())
400  && (rField1.GetHeight() == rField2.GetHeight())
401  && (rField1.GetWeight() == rField2.GetWeight())
402  && (rField1.GetPosture() == rField2.GetPosture())
403  && (rField1.GetCJKFont() == rField2.GetCJKFont())
404  && (rField1.GetCJKHeight() == rField2.GetCJKHeight())
405  && (rField1.GetCJKWeight() == rField2.GetCJKWeight())
406  && (rField1.GetCJKPosture() == rField2.GetCJKPosture())
407  && (rField1.GetCTLFont() == rField2.GetCTLFont())
408  && (rField1.GetCTLHeight() == rField2.GetCTLHeight())
409  && (rField1.GetCTLWeight() == rField2.GetCTLWeight())
410  && (rField1.GetCTLPosture() == rField2.GetCTLPosture())
411  && (rField1.GetUnderline() == rField2.GetUnderline())
412  && (rField1.GetOverline() == rField2.GetOverline())
413  && (rField1.GetCrossedOut() == rField2.GetCrossedOut())
414  && (rField1.GetContour() == rField2.GetContour())
415  && (rField1.GetShadowed() == rField2.GetShadowed())
416  && (rField1.GetColor() == rField2.GetColor());
417  }
418  if( bIncludeJustify )
419  {
420  bEqual = bEqual
421  && (rField1.GetHorJustify() == rField2.GetHorJustify())
422  && (rField1.GetVerJustify() == rField2.GetVerJustify())
423  && (rField1.GetStacked() == rField2.GetStacked())
424  && (rField1.GetLinebreak() == rField2.GetLinebreak())
425  && (rField1.GetMargin() == rField2.GetMargin())
426  && (rField1.GetRotateAngle() == rField2.GetRotateAngle())
427  && (rField1.GetRotateMode() == rField2.GetRotateMode());
428  }
429  if( bIncludeFrame )
430  {
431  bEqual = bEqual
432  && (rField1.GetBox() == rField2.GetBox())
433  && (rField1.GetTLBR() == rField2.GetTLBR())
434  && (rField1.GetBLTR() == rField2.GetBLTR());
435  }
436  if( bIncludeBackground )
437  {
438  bEqual = bEqual
439  && (rField1.GetBackground() == rField2.GetBackground());
440  }
441  return bEqual;
442 }
443 
444 void ScAutoFormatData::FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, const ScDocument& rDoc ) const
445 {
446  const ScAutoFormatDataField& rField = GetField( nIndex );
447 
448  if( bIncludeValueFormat )
449  {
450  ScNumFormatAbbrev& rNumFormat = const_cast<ScNumFormatAbbrev&>(rField.GetNumFormat());
451  SfxUInt32Item aValueFormat( ATTR_VALUE_FORMAT, 0 );
452  aValueFormat.SetValue( rNumFormat.GetFormatIndex( *rDoc.GetFormatTable() ) );
453  rItemSet.Put( aValueFormat );
454  rItemSet.Put( SvxLanguageItem( rNumFormat.GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
455  }
456  if( bIncludeFont )
457  {
458  rItemSet.Put( rField.GetFont() );
459  rItemSet.Put( rField.GetHeight() );
460  rItemSet.Put( rField.GetWeight() );
461  rItemSet.Put( rField.GetPosture() );
462  // do not insert empty CJK font
463  const SvxFontItem& rCJKFont = rField.GetCJKFont();
464  if (!rCJKFont.GetStyleName().isEmpty())
465  {
466  rItemSet.Put( rCJKFont );
467  rItemSet.Put( rField.GetCJKHeight() );
468  rItemSet.Put( rField.GetCJKWeight() );
469  rItemSet.Put( rField.GetCJKPosture() );
470  }
471  else
472  {
473  SvxFontHeightItem aFontHeightItem(rField.GetHeight());
474  aFontHeightItem.SetWhich(ATTR_CJK_FONT_HEIGHT);
475  rItemSet.Put( aFontHeightItem );
476  SvxWeightItem aWeightItem(rField.GetWeight());
477  aWeightItem.SetWhich(ATTR_CJK_FONT_WEIGHT);
478  rItemSet.Put( aWeightItem );
479  SvxPostureItem aPostureItem(rField.GetPosture());
480  aPostureItem.SetWhich(ATTR_CJK_FONT_POSTURE);
481  rItemSet.Put( aPostureItem );
482  }
483  // do not insert empty CTL font
484  const SvxFontItem& rCTLFont = rField.GetCTLFont();
485  if (!rCTLFont.GetStyleName().isEmpty())
486  {
487  rItemSet.Put( rCTLFont );
488  rItemSet.Put( rField.GetCTLHeight() );
489  rItemSet.Put( rField.GetCTLWeight() );
490  rItemSet.Put( rField.GetCTLPosture() );
491  }
492  else
493  {
494  SvxFontHeightItem aFontHeightItem(rField.GetHeight());
495  aFontHeightItem.SetWhich(ATTR_CTL_FONT_HEIGHT);
496  rItemSet.Put( aFontHeightItem );
497  SvxWeightItem aWeightItem(rField.GetWeight());
498  aWeightItem.SetWhich(ATTR_CTL_FONT_WEIGHT);
499  rItemSet.Put( aWeightItem );
500  SvxPostureItem aPostureItem(rField.GetPosture());
501  aPostureItem.SetWhich(ATTR_CTL_FONT_POSTURE);
502  rItemSet.Put( aPostureItem );
503  }
504  rItemSet.Put( rField.GetUnderline() );
505  rItemSet.Put( rField.GetOverline() );
506  rItemSet.Put( rField.GetCrossedOut() );
507  rItemSet.Put( rField.GetContour() );
508  rItemSet.Put( rField.GetShadowed() );
509  rItemSet.Put( rField.GetColor() );
510  }
511  if( bIncludeJustify )
512  {
513  rItemSet.Put( rField.GetHorJustify() );
514  rItemSet.Put( rField.GetVerJustify() );
515  rItemSet.Put( rField.GetStacked() );
516  rItemSet.Put( rField.GetLinebreak() );
517  rItemSet.Put( rField.GetMargin() );
518  rItemSet.Put( rField.GetRotateAngle() );
519  rItemSet.Put( rField.GetRotateMode() );
520  }
521  if( bIncludeFrame )
522  {
523  rItemSet.Put( rField.GetBox() );
524  rItemSet.Put( rField.GetTLBR() );
525  rItemSet.Put( rField.GetBLTR() );
526  }
527  if( bIncludeBackground )
528  rItemSet.Put( rField.GetBackground() );
529 }
530 
531 void ScAutoFormatData::GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat )
532 {
533  ScAutoFormatDataField& rField = GetField( nIndex );
534 
535  rField.SetNumFormat ( rNumFormat);
536  rField.SetFont ( rItemSet.Get( ATTR_FONT ) );
537  rField.SetHeight ( rItemSet.Get( ATTR_FONT_HEIGHT ) );
538  rField.SetWeight ( rItemSet.Get( ATTR_FONT_WEIGHT ) );
539  rField.SetPosture ( rItemSet.Get( ATTR_FONT_POSTURE ) );
540  rField.SetCJKFont ( rItemSet.Get( ATTR_CJK_FONT ) );
541  rField.SetCJKHeight ( rItemSet.Get( ATTR_CJK_FONT_HEIGHT ) );
542  rField.SetCJKWeight ( rItemSet.Get( ATTR_CJK_FONT_WEIGHT ) );
543  rField.SetCJKPosture ( rItemSet.Get( ATTR_CJK_FONT_POSTURE ) );
544  rField.SetCTLFont ( rItemSet.Get( ATTR_CTL_FONT ) );
545  rField.SetCTLHeight ( rItemSet.Get( ATTR_CTL_FONT_HEIGHT ) );
546  rField.SetCTLWeight ( rItemSet.Get( ATTR_CTL_FONT_WEIGHT ) );
547  rField.SetCTLPosture ( rItemSet.Get( ATTR_CTL_FONT_POSTURE ) );
548  rField.SetUnderline ( rItemSet.Get( ATTR_FONT_UNDERLINE ) );
549  rField.SetOverline ( rItemSet.Get( ATTR_FONT_OVERLINE ) );
550  rField.SetCrossedOut ( rItemSet.Get( ATTR_FONT_CROSSEDOUT ) );
551  rField.SetContour ( rItemSet.Get( ATTR_FONT_CONTOUR ) );
552  rField.SetShadowed ( rItemSet.Get( ATTR_FONT_SHADOWED ) );
553  rField.SetColor ( rItemSet.Get( ATTR_FONT_COLOR ) );
554  rField.SetTLBR ( rItemSet.Get( ATTR_BORDER_TLBR ) );
555  rField.SetBLTR ( rItemSet.Get( ATTR_BORDER_BLTR ) );
556  rField.SetHorJustify ( rItemSet.Get( ATTR_HOR_JUSTIFY ) );
557  rField.SetVerJustify ( rItemSet.Get( ATTR_VER_JUSTIFY ) );
558  rField.SetStacked ( rItemSet.Get( ATTR_STACKED ) );
559  rField.SetLinebreak ( rItemSet.Get( ATTR_LINEBREAK ) );
560  rField.SetMargin ( rItemSet.Get( ATTR_MARGIN ) );
561  rField.SetBackground ( rItemSet.Get( ATTR_BACKGROUND ) );
562  rField.SetRotateAngle ( rItemSet.Get( ATTR_ROTATE_VALUE ) );
563  rField.SetRotateMode ( rItemSet.Get( ATTR_ROTATE_MODE ) );
564 }
565 
566 static const char* RID_SVXSTR_TBLAFMT[] =
567 {
568  RID_SVXSTR_TBLAFMT_3D,
569  RID_SVXSTR_TBLAFMT_BLACK1,
570  RID_SVXSTR_TBLAFMT_BLACK2,
571  RID_SVXSTR_TBLAFMT_BLUE,
572  RID_SVXSTR_TBLAFMT_BROWN,
573  RID_SVXSTR_TBLAFMT_CURRENCY,
574  RID_SVXSTR_TBLAFMT_CURRENCY_3D,
575  RID_SVXSTR_TBLAFMT_CURRENCY_GRAY,
576  RID_SVXSTR_TBLAFMT_CURRENCY_LAVENDER,
577  RID_SVXSTR_TBLAFMT_CURRENCY_TURQUOISE,
578  RID_SVXSTR_TBLAFMT_GRAY,
579  RID_SVXSTR_TBLAFMT_GREEN,
580  RID_SVXSTR_TBLAFMT_LAVENDER,
581  RID_SVXSTR_TBLAFMT_RED,
582  RID_SVXSTR_TBLAFMT_TURQUOISE,
583  RID_SVXSTR_TBLAFMT_YELLOW,
584  RID_SVXSTR_TBLAFMT_LO6_ACADEMIC,
585  RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_BLUE,
586  RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_GREEN,
587  RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_RED,
588  RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_YELLOW,
589  RID_SVXSTR_TBLAFMT_LO6_ELEGANT,
590  RID_SVXSTR_TBLAFMT_LO6_FINANCIAL,
591  RID_SVXSTR_TBLAFMT_LO6_SIMPLE_GRID_COLUMNS,
592  RID_SVXSTR_TBLAFMT_LO6_SIMPLE_GRID_ROWS,
593  RID_SVXSTR_TBLAFMT_LO6_SIMPLE_LIST_SHADED
594 };
595 
596 bool ScAutoFormatData::Load( SvStream& rStream, const ScAfVersions& rVersions )
597 {
598  sal_uInt16 nVer = 0;
599  rStream.ReadUInt16( nVer );
600  bool bRet = ERRCODE_NONE == rStream.GetError();
601  if( bRet && (nVer == AUTOFORMAT_DATA_ID_X ||
602  (AUTOFORMAT_DATA_ID_504 <= nVer && nVer <= AUTOFORMAT_DATA_ID)) )
603  {
604  // --- from 680/dr25 on: store strings as UTF-8
605  if (nVer >= AUTOFORMAT_ID_680DR25)
606  {
608  RTL_TEXTENCODING_UTF8);
609  }
610  else
611  aName = rStream.ReadUniOrByteString( rStream.GetStreamCharSet() );
612 
613  if( AUTOFORMAT_DATA_ID_552 <= nVer )
614  {
615  rStream.ReadUInt16( nStrResId );
618  else
619  nStrResId = USHRT_MAX;
620  }
621 
622  bool b;
623  rStream.ReadCharAsBool( b ); bIncludeFont = b;
624  rStream.ReadCharAsBool( b ); bIncludeJustify = b;
625  rStream.ReadCharAsBool( b ); bIncludeFrame = b;
626  rStream.ReadCharAsBool( b ); bIncludeBackground = b;
627  rStream.ReadCharAsBool( b ); bIncludeValueFormat = b;
628  rStream.ReadCharAsBool( b ); bIncludeWidthHeight = b;
629 
630  if (nVer >= AUTOFORMAT_DATA_ID_31005)
631  rStream >> m_swFields;
632 
633  bRet = ERRCODE_NONE == rStream.GetError();
634  for( sal_uInt16 i = 0; bRet && i < 16; ++i )
635  bRet = GetField( i ).Load( rStream, rVersions, nVer );
636  }
637  else
638  bRet = false;
639  return bRet;
640 }
641 
642 bool ScAutoFormatData::Save(SvStream& rStream, sal_uInt16 fileVersion)
643 {
644  rStream.WriteUInt16( AUTOFORMAT_DATA_ID );
645  // --- from 680/dr25 on: store strings as UTF-8
646  write_uInt16_lenPrefixed_uInt8s_FromOUString(rStream, aName, RTL_TEXTENCODING_UTF8);
647 
648  rStream.WriteUInt16( nStrResId );
649  rStream.WriteBool( bIncludeFont );
650  rStream.WriteBool( bIncludeJustify );
651  rStream.WriteBool( bIncludeFrame );
652  rStream.WriteBool( bIncludeBackground );
653  rStream.WriteBool( bIncludeValueFormat );
654  rStream.WriteBool( bIncludeWidthHeight );
655 
656  if (fileVersion >= SOFFICE_FILEFORMAT_50)
657  WriteAutoFormatSwBlob( rStream, m_swFields );
658 
659  bool bRet = ERRCODE_NONE == rStream.GetError();
660  for (sal_uInt16 i = 0; bRet && (i < 16); i++)
661  bRet = GetField( i ).Save( rStream, fileVersion );
662 
663  return bRet;
664 }
665 
667  mbSaveLater(false)
668 {
669  // create default autoformat
670  std::unique_ptr<ScAutoFormatData> pData(new ScAutoFormatData);
671  OUString aName(ScResId(STR_STYLENAME_STANDARD));
672  pData->SetName(aName);
673 
674  // default font, default height
676  DefaultFontType::LATIN_SPREADSHEET, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne );
677  SvxFontItem aFontItem(
678  aStdFont.GetFamilyType(), aStdFont.GetFamilyName(), aStdFont.GetStyleName(),
679  aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_FONT );
680 
681  aStdFont = OutputDevice::GetDefaultFont(
682  DefaultFontType::CJK_SPREADSHEET, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne );
683  SvxFontItem aCJKFontItem(
684  aStdFont.GetFamilyType(), aStdFont.GetFamilyName(), aStdFont.GetStyleName(),
685  aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_CJK_FONT );
686 
687  aStdFont = OutputDevice::GetDefaultFont(
688  DefaultFontType::CTL_SPREADSHEET, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne );
689  SvxFontItem aCTLFontItem(
690  aStdFont.GetFamilyType(), aStdFont.GetFamilyName(), aStdFont.GetStyleName(),
691  aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_CTL_FONT );
692 
693  SvxFontHeightItem aHeight( 200, 100, ATTR_FONT_HEIGHT ); // 10 pt;
694 
695  // black thin border
696  Color aBlack( COL_BLACK );
697  ::editeng::SvxBorderLine aLine( &aBlack, DEF_LINE_WIDTH_0 );
698  SvxBoxItem aBox( ATTR_BORDER );
699  aBox.SetLine(&aLine, SvxBoxItemLine::LEFT);
700  aBox.SetLine(&aLine, SvxBoxItemLine::TOP);
701  aBox.SetLine(&aLine, SvxBoxItemLine::RIGHT);
702  aBox.SetLine(&aLine, SvxBoxItemLine::BOTTOM);
703 
704  Color aWhite(COL_WHITE);
705  SvxColorItem aWhiteText( aWhite, ATTR_FONT_COLOR );
706  SvxColorItem aBlackText( aBlack, ATTR_FONT_COLOR );
707  SvxBrushItem aBlueBack( COL_BLUE, ATTR_BACKGROUND );
708  SvxBrushItem aWhiteBack( aWhite, ATTR_BACKGROUND );
709  SvxBrushItem aGray70Back( Color(0x4d, 0x4d, 0x4d), ATTR_BACKGROUND );
710  SvxBrushItem aGray20Back( Color(0xcc, 0xcc, 0xcc), ATTR_BACKGROUND );
711 
712  for (sal_uInt16 i=0; i<16; i++)
713  {
714  pData->PutItem( i, aBox );
715  pData->PutItem( i, aFontItem );
716  pData->PutItem( i, aCJKFontItem );
717  pData->PutItem( i, aCTLFontItem );
718  aHeight.SetWhich( ATTR_FONT_HEIGHT );
719  pData->PutItem( i, aHeight );
720  aHeight.SetWhich( ATTR_CJK_FONT_HEIGHT );
721  pData->PutItem( i, aHeight );
722  aHeight.SetWhich( ATTR_CTL_FONT_HEIGHT );
723  pData->PutItem( i, aHeight );
724  if (i<4) // top: white on blue
725  {
726  pData->PutItem( i, aWhiteText );
727  pData->PutItem( i, aBlueBack );
728  }
729  else if ( i%4 == 0 ) // left: white on gray70
730  {
731  pData->PutItem( i, aWhiteText );
732  pData->PutItem( i, aGray70Back );
733  }
734  else if ( i%4 == 3 || i >= 12 ) // right and bottom: black on gray20
735  {
736  pData->PutItem( i, aBlackText );
737  pData->PutItem( i, aGray20Back );
738  }
739  else // center: black on white
740  {
741  pData->PutItem( i, aBlackText );
742  pData->PutItem( i, aWhiteBack );
743  }
744  }
745 
746  insert(std::move(pData));
747 }
748 
749 bool DefaultFirstEntry::operator() (const OUString& left, const OUString& right) const
750 {
751  OUString aStrStandard(ScResId(STR_STYLENAME_STANDARD));
752  if (ScGlobal::GetpTransliteration()->isEqual( left, right ) )
753  return false;
754  if ( ScGlobal::GetpTransliteration()->isEqual( left, aStrStandard ) )
755  return true;
756  if ( ScGlobal::GetpTransliteration()->isEqual( right, aStrStandard ) )
757  return false;
758  return ScGlobal::GetCollator()->compareString( left, right) < 0;
759 }
760 
761 void ScAutoFormat::SetSaveLater( bool bSet )
762 {
763  mbSaveLater = bSet;
764 }
765 
766 const ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex) const
767 {
768  if (nIndex >= m_Data.size())
769  return nullptr;
770 
771  MapType::const_iterator it = m_Data.begin();
772  std::advance(it, nIndex);
773  return it->second.get();
774 }
775 
777 {
778  if (nIndex >= m_Data.size())
779  return nullptr;
780 
781  MapType::iterator it = m_Data.begin();
782  std::advance(it, nIndex);
783  return it->second.get();
784 }
785 
787 {
788  return m_Data.find(rName);
789 }
790 
791 ScAutoFormat::iterator ScAutoFormat::insert(std::unique_ptr<ScAutoFormatData> pNew)
792 {
793  OUString aName = pNew->GetName();
794  return m_Data.insert(std::make_pair(aName, std::move(pNew))).first;
795 }
796 
798 {
799  m_Data.erase(it);
800 }
801 
802 size_t ScAutoFormat::size() const
803 {
804  return m_Data.size();
805 }
806 
808 {
809  return m_Data.begin();
810 }
811 
813 {
814  return m_Data.end();
815 }
816 
818 {
819  return m_Data.begin();
820 }
821 
823 {
824  return m_Data.end();
825 }
826 
828 {
830  SvtPathOptions aPathOpt;
831  aURL.SetSmartURL( aPathOpt.GetUserConfigPath() );
832  aURL.setFinalSlash();
833  aURL.Append( sAutoTblFmtName );
834 
835  SfxMedium aMedium( aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ );
836  SvStream* pStream = aMedium.GetInStream();
837  bool bRet = (pStream && pStream->GetError() == ERRCODE_NONE);
838  if (bRet)
839  {
840  SvStream& rStream = *pStream;
841  // Attention: A common header has to be read
842  sal_uInt16 nVal = 0;
843  rStream.ReadUInt16( nVal );
844  bRet = ERRCODE_NONE == rStream.GetError();
845 
846  if (bRet)
847  {
848  if( nVal == AUTOFORMAT_ID_358 ||
849  (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
850  {
851  sal_uInt8 nChrSet, nCnt;
852  tools::Long nPos = rStream.Tell();
853  rStream.ReadUChar( nCnt ).ReadUChar( nChrSet );
854  if( rStream.Tell() != sal_uLong(nPos + nCnt) )
855  {
856  OSL_FAIL( "header contains more/newer data" );
857  rStream.Seek( nPos + nCnt );
858  }
859  rStream.SetStreamCharSet( GetSOLoadTextEncoding( nChrSet ) );
861  }
862 
863  if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
864  (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
865  {
866  m_aVersions.Load( rStream, nVal ); // item versions
867 
868  sal_uInt16 nCnt = 0;
869  rStream.ReadUInt16( nCnt );
870  bRet = (rStream.GetError() == ERRCODE_NONE);
871 
872  // there has to at least be a sal_uInt16 header
873  const size_t nMaxRecords = rStream.remainingSize() / sizeof(sal_uInt16);
874  if (nCnt > nMaxRecords)
875  {
876  SAL_WARN("sc", "Parsing error: " << nMaxRecords <<
877  " max possible entries, but " << nCnt << " claimed, truncating");
878  nCnt = nMaxRecords;
879  }
880 
881  for (sal_uInt16 i=0; bRet && (i < nCnt); i++)
882  {
883  std::unique_ptr<ScAutoFormatData> pData(new ScAutoFormatData());
884  bRet = pData->Load(rStream, m_aVersions);
885  insert(std::move(pData));
886  }
887  }
888  }
889  }
890  mbSaveLater = false;
891 }
892 
894 {
896  SvtPathOptions aPathOpt;
897  aURL.SetSmartURL( aPathOpt.GetUserConfigPath() );
898  aURL.setFinalSlash();
899  aURL.Append(sAutoTblFmtName);
900 
901  SfxMedium aMedium( aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE );
902  SvStream* pStream = aMedium.GetOutStream();
903  bool bRet = (pStream && pStream->GetError() == ERRCODE_NONE);
904  if (bRet)
905  {
906  const sal_uInt16 fileVersion = SOFFICE_FILEFORMAT_50;
907  SvStream& rStream = *pStream;
908  rStream.SetVersion( fileVersion );
909 
910  // Attention: A common header has to be saved
911  rStream.WriteUInt16( AUTOFORMAT_ID )
912  .WriteUChar( 2 ) // Number of chars of the header including this
914  osl_getThreadTextEncoding() ) );
915  m_aVersions.Write(rStream, fileVersion);
916 
917  bRet &= (rStream.GetError() == ERRCODE_NONE);
918 
919  rStream.WriteUInt16( m_Data.size() - 1 );
920  bRet &= (rStream.GetError() == ERRCODE_NONE);
921  MapType::iterator it = m_Data.begin(), itEnd = m_Data.end();
922  if (it != itEnd)
923  {
924  for (++it; bRet && it != itEnd; ++it) // Skip the first item.
925  {
926  bRet &= it->second->Save(rStream, fileVersion);
927  }
928  }
929 
930  rStream.Flush();
931 
932  aMedium.Commit();
933  }
934  mbSaveLater = false;
935  return bRet;
936 }
937 
938 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvStream & WriteBool(bool b)
constexpr TypedWhichId< SvxWeightItem > ATTR_CTL_FONT_WEIGHT(118)
std::unique_ptr< SvxBrushItem > m_aBackground
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
URL aURL
std::unique_ptr< SfxBoolItem > m_aStacked
const SvxRotateModeItem & GetRotateMode() const
SvStream & WriteUInt64(sal_uInt64 nuInt64)
sal_Int32 nIndex
SAL_DLLPRIVATE ScAutoFormatDataField & GetField(sal_uInt16 nIndex)
Definition: autoform.cxx:284
void SetBackground(const SvxBrushItem &rNew)
void Load(SvStream &rStream, rtl_TextEncoding eByteStrSet)
Definition: zforauto.cxx:42
void erase(const iterator &it)
Definition: autoform.cxx:797
std::unique_ptr< SvxPostureItem > m_aCTLPosture
const SfxBoolItem & GetLinebreak() const
void SetOverline(const SvxOverlineItem &rNew)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
const OUString & GetFamilyName() const
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
std::unique_ptr< SvxFontHeightItem > m_aHeight
static const char * RID_SVXSTR_TBLAFMT[]
Definition: autoform.cxx:566
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
void CopyItem(sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich)
Definition: autoform.cxx:373
void SetCJKPosture(const SvxPostureItem &rNew)
void SetCJKFont(const SvxFontItem &rNew)
sal_uInt16 nStrResId
Definition: autoform.hxx:115
void SetMargin(const SvxMarginItem &rNew)
bool LoadBlockB(SvStream &rStream, const AutoFormatVersions &rVersions, sal_uInt16 nVer)
#define LANGUAGE_ENGLISH_US
size_t size() const
Definition: autoform.cxx:802
static SC_DLLPUBLIC::utl::TransliterationWrapper * GetpTransliteration()
Definition: global.cxx:975
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
bool Save(SvStream &rStream, sal_uInt16 fileVersion)
Definition: autoform.cxx:642
std::unique_ptr< ContentProperties > pData
std::unique_ptr< SfxInt32Item > m_aRotateAngle
const OUString & GetStyleName() const
void LoadBlockB(SvStream &rStream, sal_uInt16 nVer)
bool Save(SvStream &rStream, sal_uInt16 fileVersion)
Definition: autoform.cxx:234
std::unique_ptr< SvxFontItem > m_aFont
iterator insert(std::unique_ptr< ScAutoFormatData > pNew)
Definition: autoform.cxx:791
std::size_t size
Definition: autoform.hxx:57
std::unique_ptr< SvxContourItem > m_aContour
const SvxFontHeightItem & GetCTLHeight() const
const SvxShadowedItem & GetShadowed() const
constexpr TypedWhichId< SvxCrossedOutItem > ATTR_FONT_CROSSEDOUT(106)
void Save(SvStream &rStream, rtl_TextEncoding eByteStrSet) const
Definition: zforauto.cxx:53
sal_uIntPtr sal_uLong
long Long
constexpr TypedWhichId< SvxRotateModeItem > ATTR_ROTATE_MODE(136)
const sal_uInt16 AUTOFORMAT_ID_358
Definition: autoform.cxx:71
SvStream & ReadCharAsBool(bool &rBool)
static SC_DLLPUBLIC CollatorWrapper * GetCollator()
Definition: global.cxx:1028
SVX_ROTATE_MODE_STANDARD
void SetSaveLater(bool bSet)
Definition: autoform.cxx:761
const SvxWeightItem & GetCTLWeight() const
const SvxFontItem & GetCTLFont() const
sal_uInt64 Seek(sal_uInt64 nPos)
std::unique_ptr< SvxFontHeightItem > m_aCJKHeight
bool SaveBlockB(SvStream &rStream, sal_uInt16 fileVersion) const
static void WriteBlockB(SvStream &rStream, sal_uInt16 fileVersion)
void Flush()
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
void SetContour(const SvxContourItem &rNew)
ScAfVersions m_aVersions
Definition: autoform.hxx:184
const SvxBrushItem & GetBackground() const
void SetCTLPosture(const SvxPostureItem &rNew)
rtl_TextEncoding GetSOStoreTextEncoding(rtl_TextEncoding eEncoding)
SvStream & ReadUInt64(sal_uInt64 &rUInt64)
const SvxPostureItem & GetCTLPosture() const
void SetCTLWeight(const SvxWeightItem &rNew)
bool Load(SvStream &rStream, const ScAfVersions &rVersions)
Definition: autoform.cxx:596
const SfxBoolItem & GetStacked() const
const SvxWeightItem & GetCJKWeight() const
static void WriteBlockA(SvStream &rStream, sal_uInt16 fileVersion)
FontFamily GetFamilyType()
bool IsEqualData(sal_uInt16 nIndex1, sal_uInt16 nIndex2) const
Definition: autoform.cxx:385
bool mbSaveLater
Definition: autoform.hxx:183
std::unique_ptr< SvxUnderlineItem > m_aUnderline
std::unique_ptr< SvxShadowedItem > m_aShadowed
constexpr TypedWhichId< ScRotateValueItem > ATTR_ROTATE_VALUE(135)
const SvxFontItem & GetFont() const
AutoFormatSwBlob m_swFields
Definition: autoform.hxx:88
std::unique_ptr< SvxOverlineItem > m_aOverline
void FillToItemSet(sal_uInt16 nIndex, SfxItemSet &rItemSet, const ScDocument &rDoc) const
Definition: autoform.cxx:444
void SetHeight(const SvxFontHeightItem &rNew)
bool setFinalSlash()
ErrCode GetError() const
LINESTYLE_NONE
void SetUnderline(const SvxUnderlineItem &rNew)
bool LoadBlockA(SvStream &rStream, const AutoFormatVersions &rVersions, sal_uInt16 nVer)
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)
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
ScNumFormatAbbrev aNumFormat
Definition: autoform.hxx:91
const SvxUnderlineItem & GetUnderline() const
MapType::iterator iterator
Definition: autoform.hxx:191
std::array< std::unique_ptr< ScAutoFormatDataField >, 16 > ppDataField
Definition: autoform.hxx:129
AutoFormatSwBlob swVersions
Definition: autoform.hxx:76
void SetLinebreak(const SfxBoolItem &rNew)
void SetTLBR(const SvxLineItem &rNew)
sal_uInt16 nNumFormatVersion
const SvxWeightItem & GetWeight() const
std::unique_ptr< SfxBoolItem > m_aLinebreak
sal_uInt64 remainingSize()
const_iterator begin() const
Definition: autoform.cxx:807
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
const OUString & GetStyleName() const
void SetVerJustify(const SvxVerJustifyItem &rNew)
bool bIncludeValueFormat
Definition: autoform.hxx:123
const sal_uInt16 AUTOFORMAT_DATA_ID_552
Definition: autoform.cxx:79
#define SAL_N_ELEMENTS(arr)
void SetShadowed(const SvxShadowedItem &rNew)
AutoFormatSwBlob m_swFields
Definition: autoform.hxx:127
const SvxContourItem & GetContour() const
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_TLBR(141)
std::unique_ptr< sal_uInt8[]> pData
Definition: autoform.hxx:56
void SetCrossedOut(const SvxCrossedOutItem &rNew)
bool bIncludeBackground
Definition: autoform.hxx:120
bool bIncludeWidthHeight
Definition: autoform.hxx:124
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
OUString SvxResId(std::string_view aId)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:440
const ScNumFormatAbbrev & GetNumFormat(sal_uInt16 nIndex) const
Definition: autoform.cxx:380
const sal_uInt16 AUTOFORMAT_DATA_ID_504
Definition: autoform.cxx:77
Contains all items for one cell of a table autoformat.
Definition: autoform.hxx:85
constexpr TypedWhichId< SvxShadowedItem > ATTR_FONT_SHADOWED(108)
#define SOFFICE_FILEFORMAT_50
LanguageType GetLanguage() const
Definition: zforauto.hxx:46
const OUString & GetUserConfigPath() const
OUString read_uInt16_lenPrefixed_uInt8s_ToOUString(SvStream &rStrm, rtl_TextEncoding eEnc)
FontPitch GetPitch()
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CJK_FONT_HEIGHT(112)
void SetWeight(const SvxWeightItem &rNew)
int i
T & StaticWhichCast(TypedWhichId< T > nId)
const SvxFontHeightItem & GetCJKHeight() const
void SetBox(const SvxBoxItem &rNew)
constexpr OUStringLiteral sAutoTblFmtName
Definition: autoform.cxx:67
void LoadBlockA(SvStream &rStream, sal_uInt16 nVer)
void SetBLTR(const SvxLineItem &rNew)
const ScNumFormatAbbrev & GetNumFormat() const
Definition: autoform.hxx:102
std::unique_ptr< SvxLineItem > m_aTLBR
std::unique_ptr< SvxBoxItem > m_aBox
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
void SetRotateMode(const SvxRotateModeItem &rNew)
std::unique_ptr< SvxVerJustifyItem > m_aVerJustify
std::unique_ptr< SvxWeightItem > m_aCTLWeight
const sal_uInt16 AUTOFORMAT_ID_680DR25
Definition: autoform.cxx:82
void SetCTLHeight(const SvxFontHeightItem &rNew)
A binary blob of writer-specific data.
Definition: autoform.hxx:54
void SetCJKHeight(const SvxFontHeightItem &rNew)
const sal_uInt16 AUTOFORMAT_DATA_ID_31005
Definition: autoform.cxx:86
const sal_uInt16 AUTOFORMAT_ID_X
Definition: autoform.cxx:70
std::size_t WriteBytes(const void *pData, std::size_t nSize)
WEIGHT_NORMAL
float u
std::unique_ptr< SvxAdjustItem > m_aAdjust
OUString aName
Definition: autoform.hxx:114
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
void PutItem(sal_uInt16 nIndex, const SfxPoolItem &rItem)
Definition: autoform.cxx:336
XclImpStream & operator>>(XclImpStream &rStrm, XclImpDffPropSet &rPropSet)
Definition: xiescher.cxx:4433
void SetNumFormat(const ScNumFormatAbbrev &rNumFormat)
Definition: autoform.hxx:105
bool SaveBlockA(SvStream &rStream, sal_uInt16 fileVersion) const
const ScAutoFormatData * findByIndex(size_t nIndex) const
Definition: autoform.cxx:766
void SetHorJustify(const SvxHorJustifyItem &rNew)
constexpr TypedWhichId< ScVerticalStackCell > ATTR_STACKED(134)
SvStream & ReadUChar(unsigned char &rChar)
std::unique_ptr< SvxFontItem > m_aCTLFont
ITALIC_NONE
void SetVersion(sal_Int32 n)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CTL_FONT_HEIGHT(117)
constexpr TypedWhichId< SvxFontItem > ATTR_CTL_FONT(116)
rtl_TextEncoding GetSOLoadTextEncoding(rtl_TextEncoding eEncoding)
const SvxPostureItem & GetCJKPosture() const
bool Save()
Definition: autoform.cxx:893
std::unique_ptr< SvxPostureItem > m_aPosture
void SetFont(const SvxFontItem &rNew)
Reference< XOutputStream > stream
const SvxVerJustifyItem & GetVerJustify() const
std::size_t ReadBytes(void *pData, std::size_t nSize)
constexpr TypedWhichId< SvxFontItem > ATTR_CJK_FONT(111)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
const sal_uInt16 AUTOFORMAT_ID
Definition: autoform.cxx:89
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
MapType m_Data
Definition: autoform.hxx:182
iterator find(const OUString &rName)
Definition: autoform.cxx:786
void SetStacked(const SfxBoolItem &rNew)
void Load()
Definition: autoform.cxx:827
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SvxHorJustifyItem & GetHorJustify() const
const_iterator end() const
Definition: autoform.cxx:812
const SvxCrossedOutItem & GetCrossedOut() const
void GetFromItemSet(sal_uInt16 nIndex, const SfxItemSet &rItemSet, const ScNumFormatAbbrev &rNumFormat)
Definition: autoform.cxx:531
const SfxPoolItem * GetItem(sal_uInt16 nIndex, sal_uInt16 nWhich) const
Definition: autoform.cxx:298
OUString ScResId(std::string_view aId)
Definition: scdll.cxx:89
void SetRotateAngle(const SfxInt32Item &rNew)
constexpr TypedWhichId< SvxPostureItem > ATTR_CTL_FONT_POSTURE(119)
sal_uInt32 GetFormatIndex(SvNumberFormatter &rFormatter)
Definition: zforauto.cxx:78
const sal_uInt16 AUTOFORMAT_ID_504
Definition: autoform.cxx:76
const SvxLineItem & GetBLTR() const
#define SOFFICE_FILEFORMAT_40
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void Load(SvStream &rStream, sal_uInt16 nVer)
Definition: autoform.cxx:134
#define ERRCODE_NONE
const SvxOverlineItem & GetOverline() const
constexpr TypedWhichId< SvxOverlineItem > ATTR_FONT_OVERLINE(105)
const SvxLineItem & GetTLBR() const
unsigned char sal_uInt8
std::unique_ptr< SvxRotateModeItem > m_aRotateMode
std::unique_ptr< SvxLineItem > m_aBLTR
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
std::unique_ptr< SvxFontItem > m_aCJKFont
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
OUString aName
SvStream & WriteUChar(unsigned char nChar)
constexpr TypedWhichId< SvxPostureItem > ATTR_CJK_FONT_POSTURE(114)
MapType::const_iterator const_iterator
Definition: autoform.hxx:190
void SetStreamCharSet(rtl_TextEncoding eCharSet)
rtl_TextEncoding GetStreamCharSet() const
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
const SvxFontItem & GetCJKFont() const
sal_uInt64 Tell() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
std::unique_ptr< SvxColorItem > m_aColor
bool operator()(const OUString &left, const OUString &right) const
Definition: autoform.cxx:749
Struct with version numbers of the Items.
Definition: autoform.hxx:73
void SetValue(sal_uInt32 nTheValue)
std::unique_ptr< SvxWeightItem > m_aCJKWeight
const sal_uInt16 AUTOFORMAT_DATA_ID_X
Definition: autoform.cxx:72
std::unique_ptr< SvxWeightItem > m_aWeight
void SetPosture(const SvxPostureItem &rNew)
#define SAL_WARN(area, stream)
constexpr::Color COL_BLUE(0x00, 0x00, 0x80)
#define DEF_LINE_WIDTH_0
const SvxMarginItem & GetMargin() const
STRIKEOUT_NONE
const SvxPostureItem & GetPosture() const
const SvxColorItem & GetColor() const
const sal_uInt16 AUTOFORMAT_DATA_ID
Definition: autoform.cxx:90
void SetCTLFont(const SvxFontItem &rNew)
std::unique_ptr< SvxFontHeightItem > m_aCTLHeight
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxWeightItem > ATTR_CJK_FONT_WEIGHT(113)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_BLTR(142)
constexpr TypedWhichId< SvxContourItem > ATTR_FONT_CONTOUR(107)
sal_uInt16 Which() const
void Write(SvStream &rStream, sal_uInt16 fileVersion)
Definition: autoform.cxx:144
const SvxBoxItem & GetBox() const
const SvxFontHeightItem & GetHeight() const
bool Load(SvStream &rStream, const ScAfVersions &rVersions, sal_uInt16 nVer)
Definition: autoform.cxx:207
rtl_TextEncoding GetCharSet() const
const sal_uInt16 AUTOFORMAT_ID_31005
Definition: autoform.cxx:85
sal_uInt16 nPos
constexpr TypedWhichId< SvxMarginItem > ATTR_MARGIN(143)
bool SetSmartURL(OUString const &rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
const SfxInt32Item & GetRotateAngle() const
void SetColor(const SvxColorItem &rNew)
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)