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