LibreOffice Module sc (master)  1
xistyle.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 <xistyle.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <svtools/ctrltool.hxx>
24 #include <editeng/editobj.hxx>
25 #include <scitems.hxx>
26 #include <editeng/fontitem.hxx>
27 #include <editeng/fhgtitem.hxx>
28 #include <editeng/wghtitem.hxx>
29 #include <editeng/udlnitem.hxx>
30 #include <editeng/postitem.hxx>
32 #include <editeng/contouritem.hxx>
33 #include <editeng/shdditem.hxx>
35 #include <svx/algitem.hxx>
36 #include <editeng/borderline.hxx>
37 #include <editeng/boxitem.hxx>
38 #include <editeng/lineitem.hxx>
39 #include <svx/rotmodit.hxx>
40 #include <editeng/colritem.hxx>
41 #include <editeng/brushitem.hxx>
42 #include <editeng/frmdiritem.hxx>
43 #include <editeng/eeitem.hxx>
44 #include <editeng/flstitem.hxx>
45 #include <editeng/justifyitem.hxx>
46 #include <editeng/editids.hrc>
47 #include <sal/macros.h>
48 #include <sal/log.hxx>
49 #include <tools/UnitConversion.hxx>
50 #include <vcl/fontcharmap.hxx>
51 #include <vcl/outdev.hxx>
52 #include <document.hxx>
53 #include <documentimport.hxx>
54 #include <docpool.hxx>
55 #include <attrib.hxx>
56 #include <patattr.hxx>
57 #include <stlpool.hxx>
58 #include <stlsheet.hxx>
59 #include <globstr.hrc>
60 #include <scresid.hxx>
61 #include <attarray.hxx>
62 #include <xladdress.hxx>
63 #include <xlcontent.hxx>
64 #include <xltracer.hxx>
65 #include <xltools.hxx>
66 #include <xistream.hxx>
67 #include <xicontent.hxx>
68 
69 #include <root.hxx>
70 #include <colrowst.hxx>
71 
72 #include <string_view>
73 #include <vector>
74 
75 #include <cppuhelper/implbase.hxx>
76 #include <com/sun/star/container/XIndexAccess.hpp>
77 #include <com/sun/star/beans/XPropertySet.hpp>
78 #include <com/sun/star/frame/XModel.hpp>
79 #include <svl/numformat.hxx>
80 
81 using ::std::vector;
82 using namespace ::com::sun::star;
83 
84 typedef ::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE;
85 typedef ::std::vector< Color > ColorVec;
86 
87 namespace {
88 
89 class PaletteIndex : public XIndexAccess_BASE
90 {
91 public:
92  explicit PaletteIndex( ColorVec&& rColorTable ) : maColor( std::move(rColorTable) ) {}
93 
94  // Methods XIndexAccess
95  virtual ::sal_Int32 SAL_CALL getCount() override
96  {
97  return maColor.size();
98  }
99 
100  virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
101  {
102  //--Index; // apparently the palette is already 1 based
103  return uno::makeAny( sal_Int32( maColor[ Index ] ) );
104  }
105 
106  // Methods XElementAccess
107  virtual uno::Type SAL_CALL getElementType() override
108  {
109  return ::cppu::UnoType<sal_Int32>::get();
110  }
111  virtual sal_Bool SAL_CALL hasElements() override
112  {
113  return (!maColor.empty());
114  }
115 
116 private:
118 };
119 
120 }
121 
122 void
124 {
125  SfxObjectShell* pDocShell = mrRoot.GetDocShell();
126  if(!pDocShell)
127  return;
128 
129  // copy values in color palette
130  sal_Int16 nColors = maColorTable.size();
131  ColorVec aColors;
132  aColors.resize( nColors );
133  for( sal_uInt16 nIndex = 0; nIndex < nColors; ++nIndex )
134  aColors[ nIndex ] = GetColor( nIndex );
135 
136  uno::Reference< beans::XPropertySet > xProps( pDocShell->GetModel(), uno::UNO_QUERY );
137  if ( xProps.is() )
138  {
139  uno::Reference< container::XIndexAccess > xIndex( new PaletteIndex( std::move(aColors) ) );
140  xProps->setPropertyValue( "ColorPalette", uno::makeAny( xIndex ) );
141  }
142 
143 }
144 // PALETTE record - color information =========================================
145 
147  XclDefaultPalette( rRoot ), mrRoot( rRoot )
148 {
149 }
150 
152 {
153  maColorTable.clear();
154 }
155 
156 Color XclImpPalette::GetColor( sal_uInt16 nXclIndex ) const
157 {
158  if( nXclIndex >= EXC_COLOR_USEROFFSET )
159  {
160  sal_uInt32 nIx = nXclIndex - EXC_COLOR_USEROFFSET;
161  if( nIx < maColorTable.size() )
162  return maColorTable[ nIx ];
163  }
164  return GetDefColor( nXclIndex );
165 }
166 
168 {
169  sal_uInt16 nCount;
170  nCount = rStrm.ReaduInt16();
171 
172  const size_t nMinRecordSize = 4;
173  const size_t nMaxRecords = rStrm.GetRecLeft() / nMinRecordSize;
174  if (nCount > nMaxRecords)
175  {
176  SAL_WARN("sc", "Parsing error: " << nMaxRecords <<
177  " max possible entries, but " << nCount << " claimed, truncating");
178  nCount = nMaxRecords;
179  }
180 
181  maColorTable.resize( nCount );
182  Color aColor;
183  for( sal_uInt16 nIndex = 0; nIndex < nCount; ++nIndex )
184  {
185  rStrm >> aColor;
186  maColorTable[ nIndex ] = aColor;
187  }
188  ExportPalette();
189 }
190 
191 // FONT record - font information =============================================
193  XclImpRoot( rRoot ),
194  mbHasCharSet( false ),
195  mbHasWstrn( true ),
196  mbHasAsian( false ),
197  mbHasCmplx( false )
198 {
199  SetAllUsedFlags( false );
200 }
201 
202 XclImpFont::XclImpFont( const XclImpRoot& rRoot, const XclFontData& rFontData ) :
203  XclImpRoot( rRoot )
204 {
205  SetFontData( rFontData, false );
206 }
207 
208 void XclImpFont::SetAllUsedFlags( bool bUsed )
209 {
212 }
213 
214 void XclImpFont::SetFontData( const XclFontData& rFontData, bool bHasCharSet )
215 {
216  maData = rFontData;
217  mbHasCharSet = bHasCharSet;
218  if( !maData.maStyle.isEmpty() )
219  {
220  if( SfxObjectShell* pDocShell = GetDocShell() )
221  {
222  if( const SvxFontListItem* pInfoItem = static_cast< const SvxFontListItem* >(
223  pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) ) )
224  {
225  if( const FontList* pFontList = pInfoItem->GetFontList() )
226  {
227  FontMetric aFontMetric( pFontList->Get( maData.maName, maData.maStyle ) );
228  maData.SetScWeight( aFontMetric.GetWeight() );
229  maData.SetScPosture( aFontMetric.GetItalic() );
230  }
231  }
232  }
233  maData.maStyle.clear();
234  }
235  GuessScriptType();
236  SetAllUsedFlags( true );
237 }
238 
239 rtl_TextEncoding XclImpFont::GetFontEncoding() const
240 {
241  // #i63105# use text encoding from FONT record
242  // #i67768# BIFF2-BIFF4 FONT records do not contain character set
243  rtl_TextEncoding eFontEnc = mbHasCharSet ? maData.GetFontEncoding() : GetTextEncoding();
244  return (eFontEnc == RTL_TEXTENCODING_DONTKNOW) ? GetTextEncoding() : eFontEnc;
245 }
246 
248 {
249  switch( GetBiff() )
250  {
251  case EXC_BIFF2:
252  ReadFontData2( rStrm );
253  ReadFontName2( rStrm );
254  break;
255  case EXC_BIFF3:
256  case EXC_BIFF4:
257  ReadFontData2( rStrm );
258  ReadFontColor( rStrm );
259  ReadFontName2( rStrm );
260  break;
261  case EXC_BIFF5:
262  ReadFontData5( rStrm );
263  ReadFontName2( rStrm );
264  break;
265  case EXC_BIFF8:
266  ReadFontData5( rStrm );
267  ReadFontName8( rStrm );
268  break;
269  default:
270  DBG_ERROR_BIFF();
271  return;
272  }
273  GuessScriptType();
274  SetAllUsedFlags( true );
275 }
276 
278 {
279  ReadFontColor( rStrm );
280 }
281 
283 {
285  if( GetBiff() != EXC_BIFF8 )
286  return;
287 
288  rStrm.Ignore( 64 );
289  sal_uInt32 nHeight = rStrm.ReaduInt32();
290  sal_uInt32 nStyle = rStrm.ReaduInt32();
291  sal_uInt16 nWeight = rStrm.ReaduInt16();
292  rStrm.Ignore( 2 ); //nEscapem
293  sal_uInt8 nUnderl = rStrm.ReaduInt8();
294  rStrm.Ignore( 3 );
295  sal_uInt32 nColor = rStrm.ReaduInt32();
296  rStrm.Ignore( 4 );
297  sal_uInt32 nFontFlags1 = rStrm.ReaduInt32();
298  rStrm.Ignore( 4 ); //nFontFlags2
299  sal_uInt32 nFontFlags3 = rStrm.ReaduInt32();
300  rStrm.Ignore( 18 );
301 
302  if( (mbHeightUsed = (nHeight <= 0x7FFF)) )
303  maData.mnHeight = static_cast< sal_uInt16 >( nHeight );
304  if( (mbWeightUsed = !::get_flag( nFontFlags1, EXC_CF_FONT_STYLE ) && (nWeight < 0x7FFF)) )
305  maData.mnWeight = nWeight;
306  if( (mbItalicUsed = !::get_flag( nFontFlags1, EXC_CF_FONT_STYLE )) )
307  maData.mbItalic = ::get_flag( nStyle, EXC_CF_FONT_STYLE );
308  if( (mbUnderlUsed = !::get_flag( nFontFlags3, EXC_CF_FONT_UNDERL ) && (nUnderl <= 0x7F)) )
309  maData.mnUnderline = nUnderl;
310  if( (mbColorUsed = (nColor <= 0x7FFF)) )
311  maData.maColor = GetPalette().GetColor( static_cast< sal_uInt16 >( nColor ) );
312  if( (mbStrikeUsed = !::get_flag( nFontFlags1, EXC_CF_FONT_STRIKEOUT )) )
314 }
315 
316 void XclImpFont::FillToItemSet( SfxItemSet& rItemSet, XclFontItemType eType, bool bSkipPoolDefs ) const
317 {
318  // true = edit engine Which-IDs (EE_CHAR_*); false = Calc Which-IDs (ATTR_*)
319  bool bEE = eType != XclFontItemType::Cell;
320 
321 // item = the item to put into the item set
322 // sc_which = the Calc Which-ID of the item
323 // ee_which = the edit engine Which-ID of the item
324 #define PUTITEM( item, sc_which, ee_which ) \
325  ScfTools::PutItem( rItemSet, item, (bEE ? (static_cast<sal_uInt16>(ee_which)) : (sc_which)), bSkipPoolDefs )
326 
327 // Font item
328  if( mbFontNameUsed )
329  {
330  rtl_TextEncoding eFontEnc = maData.GetFontEncoding();
331  rtl_TextEncoding eTempTextEnc = (bEE && (eFontEnc == GetTextEncoding())) ?
332  ScfTools::GetSystemTextEncoding() : eFontEnc;
333 
334  //add corresponding pitch for FontFamily
335  FontPitch ePitch = PITCH_DONTKNOW;
336  FontFamily eFtFamily = maData.GetScFamily( GetTextEncoding() );
337  switch( eFtFamily ) //refer http://msdn.microsoft.com/en-us/library/aa246306(v=VS.60).aspx
338  {
339  case FAMILY_ROMAN: ePitch = PITCH_VARIABLE; break;
340  case FAMILY_SWISS: ePitch = PITCH_VARIABLE; break;
341  case FAMILY_MODERN: ePitch = PITCH_FIXED; break;
342  default: break;
343  }
344  SvxFontItem aFontItem( eFtFamily , maData.maName, EMPTY_OUSTRING, ePitch, eTempTextEnc, ATTR_FONT );
345 
346  // set only for valid script types
347  if( mbHasWstrn )
348  PUTITEM( aFontItem, ATTR_FONT, EE_CHAR_FONTINFO );
349  if( mbHasAsian )
351  if( mbHasCmplx )
353  }
354 
355 // Font height (for all script types)
356  if( mbHeightUsed )
357  {
358  sal_Int32 nHeight = maData.mnHeight;
359  if( bEE && (eType != XclFontItemType::HeaderFooter) ) // do not convert header/footer height
360  nHeight = convertTwipToMm100(nHeight);
361 
362  SvxFontHeightItem aHeightItem( nHeight, 100, ATTR_FONT_HEIGHT );
366  }
367 
368 // Font color - pass AUTO_COL to item
369  if( mbColorUsed )
371 
372 // Font weight (for all script types)
373  if( mbWeightUsed )
374  {
376  PUTITEM( aWeightItem, ATTR_FONT_WEIGHT, EE_CHAR_WEIGHT );
379  }
380 
381 // Font underline
382  if( mbUnderlUsed )
383  {
386  }
387 
388 // Font posture (for all script types)
389  if( mbItalicUsed )
390  {
395  }
396 
397 // Boolean attributes crossed out, contoured, shadowed
398  if( mbStrikeUsed )
400  if( mbOutlineUsed )
402  if( mbShadowUsed )
404 
405 // Super-/subscript: only on edit engine objects
406  if( mbEscapemUsed && bEE )
408 
409 #undef PUTITEM
410 }
411 
413  XclFontPropSetType eType, const Color* pFontColor ) const
414 {
416  rPropSet, eType, maData, mbHasWstrn, mbHasAsian, mbHasCmplx, pFontColor );
417 }
418 
420 {
421  sal_uInt16 nFlags;
422  maData.mnHeight = rStrm.ReaduInt16();
423  nFlags = rStrm.ReaduInt16();
424 
431  mbHasCharSet = false;
432 }
433 
435 {
436  sal_uInt16 nFlags;
437 
438  maData.mnHeight = rStrm.ReaduInt16();
439  nFlags = rStrm.ReaduInt16();
440  ReadFontColor( rStrm );
441  maData.mnWeight = rStrm.ReaduInt16();
442  maData.mnEscapem = rStrm.ReaduInt16();
443  maData.mnUnderline = rStrm.ReaduInt8();
444  maData.mnFamily = rStrm.ReaduInt8();
445  maData.mnCharSet = rStrm.ReaduInt8();
446  rStrm.Ignore( 1 );
447 
453 }
454 
456 {
458 }
459 
461 {
462  maData.maName = rStrm.ReadByteString( false );
463 }
464 
466 {
467  maData.maName = rStrm.ReadUniString( rStrm.ReaduInt8() );
468 }
469 
471 {
472  mbHasWstrn = true;
473  mbHasAsian = mbHasCmplx = false;
474 
475  // find the script types for which the font contains characters
476  OutputDevice* pPrinter = GetPrinter();
477  if(!pPrinter)
478  return;
479 
480  vcl::Font aFont( maData.maName, Size( 0, 10 ) );
481  FontCharMapRef xFontCharMap;
482 
483  pPrinter->SetFont( aFont );
484  if( !pPrinter->GetFontCharMap( xFontCharMap ) )
485  return;
486 
487  // CJK fonts
488  mbHasAsian =
489  xFontCharMap->HasChar( 0x3041 ) || // 3040-309F: Hiragana
490  xFontCharMap->HasChar( 0x30A1 ) || // 30A0-30FF: Katakana
491  xFontCharMap->HasChar( 0x3111 ) || // 3100-312F: Bopomofo
492  xFontCharMap->HasChar( 0x3131 ) || // 3130-318F: Hangul Compatibility Jamo
493  xFontCharMap->HasChar( 0x3301 ) || // 3300-33FF: CJK Compatibility
494  xFontCharMap->HasChar( 0x3401 ) || // 3400-4DBF: CJK Unified Ideographs Extension A
495  xFontCharMap->HasChar( 0x4E01 ) || // 4E00-9FFF: CJK Unified Ideographs
496  xFontCharMap->HasChar( 0x7E01 ) || // 4E00-9FFF: CJK Unified Ideographs
497  xFontCharMap->HasChar( 0xA001 ) || // A001-A48F: Yi Syllables
498  xFontCharMap->HasChar( 0xAC01 ) || // AC00-D7AF: Hangul Syllables
499  xFontCharMap->HasChar( 0xCC01 ) || // AC00-D7AF: Hangul Syllables
500  xFontCharMap->HasChar( 0xF901 ) || // F900-FAFF: CJK Compatibility Ideographs
501  xFontCharMap->HasChar( 0xFF71 ); // FF00-FFEF: Halfwidth/Fullwidth Forms
502  // CTL fonts
503  mbHasCmplx =
504  xFontCharMap->HasChar( 0x05D1 ) || // 0590-05FF: Hebrew
505  xFontCharMap->HasChar( 0x0631 ) || // 0600-06FF: Arabic
506  xFontCharMap->HasChar( 0x0721 ) || // 0700-074F: Syriac
507  xFontCharMap->HasChar( 0x0911 ) || // 0900-0DFF: Indic scripts
508  xFontCharMap->HasChar( 0x0E01 ) || // 0E00-0E7F: Thai
509  xFontCharMap->HasChar( 0xFB21 ) || // FB1D-FB4F: Hebrew Presentation Forms
510  xFontCharMap->HasChar( 0xFB51 ) || // FB50-FDFF: Arabic Presentation Forms-A
511  xFontCharMap->HasChar( 0xFE71 ); // FE70-FEFF: Arabic Presentation Forms-B
512  // Western fonts
513  mbHasWstrn = (!mbHasAsian && !mbHasCmplx) || xFontCharMap->HasChar( 'A' );
514 }
515 
517  XclImpRoot( rRoot ),
518  maFont4( rRoot ),
519  maCtrlFont( rRoot )
520 {
521  Initialize();
522 
523  // default font for form controls without own font information
524  XclFontData aCtrlFontData;
525  switch( GetBiff() )
526  {
527  case EXC_BIFF2:
528  case EXC_BIFF3:
529  case EXC_BIFF4:
530  case EXC_BIFF5:
531  aCtrlFontData.maName = "Helv";
532  aCtrlFontData.mnHeight = 160;
533  aCtrlFontData.mnWeight = EXC_FONTWGHT_BOLD;
534  break;
535  case EXC_BIFF8:
536  aCtrlFontData.maName = "Tahoma";
537  aCtrlFontData.mnHeight = 160;
538  aCtrlFontData.mnWeight = EXC_FONTWGHT_NORMAL;
539  break;
540  default:
541  DBG_ERROR_BIFF();
542  }
543  maCtrlFont.SetFontData( aCtrlFontData, false );
544 }
545 
547 {
548  maFontList.clear();
549 
550  // application font for column width calculation, later filled with first font from font list
551  XclFontData aAppFontData;
552  aAppFontData.maName = "Arial";
553  aAppFontData.mnHeight = 200;
554  aAppFontData.mnWeight = EXC_FONTWGHT_NORMAL;
555  UpdateAppFont( aAppFontData, false );
556 }
557 
558 const XclImpFont* XclImpFontBuffer::GetFont( sal_uInt16 nFontIndex ) const
559 {
560  /* Font with index 4 is not stored in an Excel file, but used e.g. by
561  BIFF5 form pushbutton objects. It is the bold default font.
562  This also means that entries above 4 are out by one in the list. */
563 
564  if (nFontIndex == 4)
565  return &maFont4;
566 
567  if (nFontIndex < 4)
568  {
569  // Font ID is zero-based when it's less than 4.
570  return nFontIndex >= maFontList.size() ? nullptr : &maFontList[nFontIndex];
571  }
572 
573  // Font ID is greater than 4. It is now 1-based.
574  return nFontIndex > maFontList.size() ? nullptr : &maFontList[nFontIndex-1];
575 }
576 
578 {
579  maFontList.emplace_back( GetRoot() );
580  XclImpFont& rFont = maFontList.back();
581  rFont.ReadFont( rStrm );
582 
583  if( maFontList.size() == 1 )
584  {
585  UpdateAppFont( rFont.GetFontData(), rFont.HasCharSet() );
586  }
587 }
588 
590 {
591  if( !maFontList.empty() )
592  maFontList.back().ReadEfont( rStrm );
593 }
594 
596  SfxItemSet& rItemSet, XclFontItemType eType,
597  sal_uInt16 nFontIdx, bool bSkipPoolDefs ) const
598 {
599  if( const XclImpFont* pFont = GetFont( nFontIdx ) )
600  pFont->FillToItemSet( rItemSet, eType, bSkipPoolDefs );
601 }
602 
604  XclFontPropSetType eType, sal_uInt16 nFontIdx, const Color* pFontColor ) const
605 {
606  if( const XclImpFont* pFont = GetFont( nFontIdx ) )
607  pFont->WriteFontProperties( rPropSet, eType, pFontColor );
608 }
609 
611 {
613 }
614 
615 void XclImpFontBuffer::UpdateAppFont( const XclFontData& rFontData, bool bHasCharSet )
616 {
617  maAppFont = rFontData;
618  // #i3006# Calculate the width of '0' from first font and current printer.
620 
621  // font 4 is bold font 0
622  XclFontData aFont4Data( maAppFont );
623  aFont4Data.mnWeight = EXC_FONTWGHT_BOLD;
624  maFont4.SetFontData( aFont4Data, bHasCharSet );
625 }
626 
627 // FORMAT record - number formats =============================================
628 
630  XclNumFmtBuffer( rRoot ),
631  XclImpRoot( rRoot ),
632  mnNextXclIdx( 0 )
633 {
634 }
635 
637 {
638  maIndexMap.clear();
639  mnNextXclIdx = 0;
640  InitializeImport(); // base class
641 }
642 
644 {
645  OUString aFormat;
646  switch( GetBiff() )
647  {
648  case EXC_BIFF2:
649  case EXC_BIFF3:
650  aFormat = rStrm.ReadByteString( false );
651  break;
652 
653  case EXC_BIFF4:
654  rStrm.Ignore( 2 ); // in BIFF4 the index field exists, but is undefined
655  aFormat = rStrm.ReadByteString( false );
656  break;
657 
658  case EXC_BIFF5:
659  mnNextXclIdx = rStrm.ReaduInt16();
660  aFormat = rStrm.ReadByteString( false );
661  break;
662 
663  case EXC_BIFF8:
664  mnNextXclIdx = rStrm.ReaduInt16();
665  aFormat = rStrm.ReadUniString();
666  break;
667 
668  default:
669  DBG_ERROR_BIFF();
670  return;
671  }
672 
673  if( mnNextXclIdx < 0xFFFF )
674  {
675  InsertFormat( mnNextXclIdx, aFormat );
676  ++mnNextXclIdx;
677  }
678 }
679 
680 sal_uInt16 XclImpNumFmtBuffer::ReadCFFormat( XclImpStream& rStrm, bool bIFmt )
681 {
682  // internal number format ?
683  if(bIFmt)
684  {
685  rStrm.Ignore(1);
687  nIndex = rStrm.ReaduInt8();
688  return nIndex;
689  }
690  else
691  {
692  OUString aFormat = rStrm.ReadUniString();
693  InsertFormat( mnNextXclIdx, aFormat );
694  ++mnNextXclIdx;
695  return mnNextXclIdx - 1;
696  }
697 }
698 
700 {
701  OSL_ENSURE( maIndexMap.empty(), "XclImpNumFmtBuffer::CreateScFormats - already created" );
702 
703  SvNumberFormatter& rFormatter = GetFormatter();
704  for( const auto& [rXclNumFmt, rNumFmt] : GetFormatMap() )
705  {
706  // insert/convert the Excel number format
707  sal_uInt32 nKey;
708  if( !rNumFmt.maFormat.isEmpty() )
709  {
710  OUString aFormat( rNumFmt.maFormat );
711  sal_Int32 nCheckPos;
712  SvNumFormatType nType = SvNumFormatType::DEFINED;
713  rFormatter.PutandConvertEntry( aFormat, nCheckPos,
714  nType, nKey, LANGUAGE_ENGLISH_US, rNumFmt.meLanguage, false);
715  }
716  else
717  nKey = rFormatter.GetFormatIndex( rNumFmt.meOffset, rNumFmt.meLanguage );
718 
719  // insert the resulting format key into the Excel->Calc index map
720  maIndexMap[ rXclNumFmt ] = nKey;
721  }
722 }
723 
724 sal_uInt32 XclImpNumFmtBuffer::GetScFormat( sal_uInt16 nXclNumFmt ) const
725 {
726  XclImpIndexMap::const_iterator aIt = maIndexMap.find( nXclNumFmt );
727  return (aIt != maIndexMap.end()) ? aIt->second : NUMBERFORMAT_ENTRY_NOT_FOUND;
728 }
729 
730 void XclImpNumFmtBuffer::FillToItemSet( SfxItemSet& rItemSet, sal_uInt16 nXclNumFmt, bool bSkipPoolDefs ) const
731 {
732  sal_uInt32 nScNumFmt = GetScFormat( nXclNumFmt );
733  if( nScNumFmt == NUMBERFORMAT_ENTRY_NOT_FOUND )
734  nScNumFmt = GetStdScNumFmt();
735  FillScFmtToItemSet( rItemSet, nScNumFmt, bSkipPoolDefs );
736 }
737 
738 void XclImpNumFmtBuffer::FillScFmtToItemSet( SfxItemSet& rItemSet, sal_uInt32 nScNumFmt, bool bSkipPoolDefs ) const
739 {
740  OSL_ENSURE( nScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND, "XclImpNumFmtBuffer::FillScFmtToItemSet - invalid number format" );
741  ScfTools::PutItem( rItemSet, SfxUInt32Item( ATTR_VALUE_FORMAT, nScNumFmt ), bSkipPoolDefs );
742  if( rItemSet.GetItemState( ATTR_VALUE_FORMAT, false ) == SfxItemState::SET )
743  ScGlobal::AddLanguage( rItemSet, GetFormatter() );
744 }
745 
746 // XF, STYLE record - Cell formatting =========================================
747 
749 {
750  mbLocked = ::get_flag( nNumFmt, EXC_XF2_LOCKED );
751  mbHidden = ::get_flag( nNumFmt, EXC_XF2_HIDDEN );
752 }
753 
754 void XclImpCellProt::FillFromXF3( sal_uInt16 nProt )
755 {
756  mbLocked = ::get_flag( nProt, EXC_XF_LOCKED );
757  mbHidden = ::get_flag( nProt, EXC_XF_HIDDEN );
758 }
759 
760 void XclImpCellProt::FillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
761 {
762  ScfTools::PutItem( rItemSet, ScProtectionAttr( mbLocked, mbHidden ), bSkipPoolDefs );
763 }
764 
766 {
767  mnHorAlign = ::extract_value< sal_uInt8 >( nFlags, 0, 3 );
768 }
769 
770 void XclImpCellAlign::FillFromXF3( sal_uInt16 nAlign )
771 {
772  mnHorAlign = ::extract_value< sal_uInt8 >( nAlign, 0, 3 );
773  mbLineBreak = ::get_flag( nAlign, EXC_XF_LINEBREAK ); // new in BIFF3
774 }
775 
776 void XclImpCellAlign::FillFromXF4( sal_uInt16 nAlign )
777 {
778  FillFromXF3( nAlign );
779  mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 2 ); // new in BIFF4
780  mnOrient = ::extract_value< sal_uInt8 >( nAlign, 6, 2 ); // new in BIFF4
781 }
782 
783 void XclImpCellAlign::FillFromXF5( sal_uInt16 nAlign )
784 {
785  mnHorAlign = ::extract_value< sal_uInt8 >( nAlign, 0, 3 );
786  mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 3 );
788  mnOrient = ::extract_value< sal_uInt8 >( nAlign, 8, 2 );
789 }
790 
791 void XclImpCellAlign::FillFromXF8( sal_uInt16 nAlign, sal_uInt16 nMiscAttrib )
792 {
793  mnHorAlign = ::extract_value< sal_uInt8 >( nAlign, 0, 3 );
794  mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 3 );
796  mnRotation = ::extract_value< sal_uInt8 >( nAlign, 8, 8 ); // new in BIFF8
797  mnIndent = ::extract_value< sal_uInt8 >( nMiscAttrib, 0, 4 ); // new in BIFF8
798  mbShrink = ::get_flag( nMiscAttrib, EXC_XF8_SHRINK ); // new in BIFF8
799  mnTextDir = ::extract_value< sal_uInt8 >( nMiscAttrib, 6, 2 ); // new in BIFF8
800 }
801 
802 void XclImpCellAlign::FillFromCF( sal_uInt16 nAlign, sal_uInt16 nMiscAttrib )
803 {
804  mnHorAlign = extract_value< sal_uInt8 >( nAlign, 0, 3 );
805  mbLineBreak = get_flag< sal_uInt8 >( nAlign, EXC_XF_LINEBREAK );
806  mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 3 );
807  mnRotation = ::extract_value< sal_uInt8 >( nAlign, 8, 8 );
808  mnIndent = ::extract_value< sal_uInt8 >( nMiscAttrib, 0, 4 );
809  mbShrink = ::get_flag( nMiscAttrib, EXC_XF8_SHRINK );
810  mnTextDir = ::extract_value< sal_uInt8 >( nMiscAttrib, 6, 2 );
811 }
812 
813 void XclImpCellAlign::FillToItemSet( SfxItemSet& rItemSet, const XclImpFont* pFont, bool bSkipPoolDefs ) const
814 {
815  // horizontal alignment
816  ScfTools::PutItem( rItemSet, SvxHorJustifyItem( GetScHorAlign(), ATTR_HOR_JUSTIFY ), bSkipPoolDefs );
818 
819  // text wrap (#i74508# always if vertical alignment is justified or distributed)
820  bool bLineBreak = mbLineBreak || (mnVerAlign == EXC_XF_VER_JUSTIFY) || (mnVerAlign == EXC_XF_VER_DISTRIB);
821  ScfTools::PutItem( rItemSet, ScLineBreakCell( bLineBreak ), bSkipPoolDefs );
822 
823  // vertical alignment
824  ScfTools::PutItem( rItemSet, SvxVerJustifyItem( GetScVerAlign(), ATTR_VER_JUSTIFY ), bSkipPoolDefs );
826 
827  // indent
828  sal_uInt16 nScIndent = mnIndent * 200; // 1 Excel unit == 10 pt == 200 twips
829  ScfTools::PutItem( rItemSet, ScIndentItem( nScIndent ), bSkipPoolDefs );
830 
831  // shrink to fit
832  ScfTools::PutItem( rItemSet, ScShrinkToFitCell( mbShrink ), bSkipPoolDefs );
833 
834  // text orientation/rotation (BIFF2-BIFF7 sets mnOrient)
836  bool bStacked = (nXclRot == EXC_ROT_STACKED);
837  ScfTools::PutItem( rItemSet, ScVerticalStackCell( bStacked ), bSkipPoolDefs );
838  // set an angle in the range from -90 to 90 degrees
839  Degree100 nAngle = XclTools::GetScRotation( nXclRot, 0_deg100 );
840  ScfTools::PutItem( rItemSet, ScRotateValueItem( nAngle ), bSkipPoolDefs );
841  // set "Use asian vertical layout", if cell is stacked and font contains CKJ characters
842  bool bAsianVert = bStacked && pFont && pFont->HasAsianChars();
843  ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_VERTICAL_ASIAN, bAsianVert ), bSkipPoolDefs );
844 
845  // CTL text direction
846  ScfTools::PutItem( rItemSet, SvxFrameDirectionItem( GetScFrameDir(), ATTR_WRITINGDIR ), bSkipPoolDefs );
847 }
848 
850 {
851  SetUsedFlags( false, false );
852 }
853 
854 void XclImpCellBorder::SetUsedFlags( bool bOuterUsed, bool bDiagUsed )
855 {
856  mbLeftUsed = mbRightUsed = mbTopUsed = mbBottomUsed = bOuterUsed;
857  mbDiagUsed = bDiagUsed;
858 }
859 
861 {
867  SetUsedFlags( true, false );
868 }
869 
870 void XclImpCellBorder::FillFromXF3( sal_uInt32 nBorder )
871 {
872  mnTopLine = ::extract_value< sal_uInt8 >( nBorder, 0, 3 );
873  mnLeftLine = ::extract_value< sal_uInt8 >( nBorder, 8, 3 );
874  mnBottomLine = ::extract_value< sal_uInt8 >( nBorder, 16, 3 );
875  mnRightLine = ::extract_value< sal_uInt8 >( nBorder, 24, 3 );
876  mnTopColor = ::extract_value< sal_uInt16 >( nBorder, 3, 5 );
877  mnLeftColor = ::extract_value< sal_uInt16 >( nBorder, 11, 5 );
878  mnBottomColor = ::extract_value< sal_uInt16 >( nBorder, 19, 5 );
879  mnRightColor = ::extract_value< sal_uInt16 >( nBorder, 27, 5 );
880  SetUsedFlags( true, false );
881 }
882 
883 void XclImpCellBorder::FillFromXF5( sal_uInt32 nBorder, sal_uInt32 nArea )
884 {
885  mnTopLine = ::extract_value< sal_uInt8 >( nBorder, 0, 3 );
886  mnLeftLine = ::extract_value< sal_uInt8 >( nBorder, 3, 3 );
887  mnBottomLine = ::extract_value< sal_uInt8 >( nArea, 22, 3 );
888  mnRightLine = ::extract_value< sal_uInt8 >( nBorder, 6, 3 );
889  mnTopColor = ::extract_value< sal_uInt16 >( nBorder, 9, 7 );
890  mnLeftColor = ::extract_value< sal_uInt16 >( nBorder, 16, 7 );
891  mnBottomColor = ::extract_value< sal_uInt16 >( nArea, 25, 7 );
892  mnRightColor = ::extract_value< sal_uInt16 >( nBorder, 23, 7 );
893  SetUsedFlags( true, false );
894 }
895 
896 void XclImpCellBorder::FillFromXF8( sal_uInt32 nBorder1, sal_uInt32 nBorder2 )
897 {
898  mnLeftLine = ::extract_value< sal_uInt8 >( nBorder1, 0, 4 );
899  mnRightLine = ::extract_value< sal_uInt8 >( nBorder1, 4, 4 );
900  mnTopLine = ::extract_value< sal_uInt8 >( nBorder1, 8, 4 );
901  mnBottomLine = ::extract_value< sal_uInt8 >( nBorder1, 12, 4 );
902  mnLeftColor = ::extract_value< sal_uInt16 >( nBorder1, 16, 7 );
903  mnRightColor = ::extract_value< sal_uInt16 >( nBorder1, 23, 7 );
904  mnTopColor = ::extract_value< sal_uInt16 >( nBorder2, 0, 7 );
905  mnBottomColor = ::extract_value< sal_uInt16 >( nBorder2, 7, 7 );
908  if( mbDiagTLtoBR || mbDiagBLtoTR )
909  {
910  mnDiagLine = ::extract_value< sal_uInt8 >( nBorder2, 21, 4 );
911  mnDiagColor = ::extract_value< sal_uInt16 >( nBorder2, 14, 7 );
912  }
913  SetUsedFlags( true, true );
914 }
915 
916 void XclImpCellBorder::FillFromCF8( sal_uInt16 nLineStyle, sal_uInt32 nLineColor, sal_uInt32 nFlags )
917 {
918  mnLeftLine = ::extract_value< sal_uInt8 >( nLineStyle, 0, 4 );
919  mnRightLine = ::extract_value< sal_uInt8 >( nLineStyle, 4, 4 );
920  mnTopLine = ::extract_value< sal_uInt8 >( nLineStyle, 8, 4 );
921  mnBottomLine = ::extract_value< sal_uInt8 >( nLineStyle, 12, 4 );
922  mnLeftColor = ::extract_value< sal_uInt16 >( nLineColor, 0, 7 );
923  mnRightColor = ::extract_value< sal_uInt16 >( nLineColor, 7, 7 );
924  mnTopColor = ::extract_value< sal_uInt16 >( nLineColor, 16, 7 );
925  mnBottomColor = ::extract_value< sal_uInt16 >( nLineColor, 23, 7 );
928  mbTopUsed = !::get_flag( nFlags, EXC_CF_BORDER_TOP );
930  mbDiagUsed = false;
931 }
932 
934 {
935  return
936  (mbLeftUsed && (mnLeftLine != EXC_LINE_NONE)) ||
938  (mbTopUsed && (mnTopLine != EXC_LINE_NONE)) ||
940 }
941 
942 namespace {
943 
945 bool lclConvertBorderLine( ::editeng::SvxBorderLine& rLine, const XclImpPalette& rPalette, sal_uInt8 nXclLine, sal_uInt16 nXclColor )
946 {
947  static const sal_uInt16 ppnLineParam[][ 4 ] =
948  {
949  // outer width, type
950  { 0, table::BorderLineStyle::SOLID }, // 0 = none
951  { EXC_BORDER_THIN, table::BorderLineStyle::SOLID }, // 1 = thin
952  { EXC_BORDER_MEDIUM, table::BorderLineStyle::SOLID }, // 2 = medium
953  { EXC_BORDER_THIN, table::BorderLineStyle::FINE_DASHED }, // 3 = dashed
954  { EXC_BORDER_THIN, table::BorderLineStyle::DOTTED }, // 4 = dotted
955  { EXC_BORDER_THICK, table::BorderLineStyle::SOLID }, // 5 = thick
956  { EXC_BORDER_THICK, table::BorderLineStyle::DOUBLE_THIN }, // 6 = double
957  { EXC_BORDER_HAIR, table::BorderLineStyle::SOLID }, // 7 = hair
958  { EXC_BORDER_MEDIUM, table::BorderLineStyle::DASHED }, // 8 = med dash
959  { EXC_BORDER_THIN, table::BorderLineStyle::DASH_DOT }, // 9 = thin dashdot
960  { EXC_BORDER_MEDIUM, table::BorderLineStyle::DASH_DOT }, // A = med dashdot
961  { EXC_BORDER_THIN, table::BorderLineStyle::DASH_DOT_DOT }, // B = thin dashdotdot
962  { EXC_BORDER_MEDIUM, table::BorderLineStyle::DASH_DOT_DOT }, // C = med dashdotdot
963  { EXC_BORDER_MEDIUM, table::BorderLineStyle::DASH_DOT } // D = med slant dashdot
964  };
965 
966  if( nXclLine == EXC_LINE_NONE )
967  return false;
968  if( nXclLine >= SAL_N_ELEMENTS( ppnLineParam ) )
969  nXclLine = EXC_LINE_THIN;
970 
971  rLine.SetColor( rPalette.GetColor( nXclColor ) );
972  rLine.SetWidth( ppnLineParam[ nXclLine ][ 0 ] );
973  rLine.SetBorderLineStyle( static_cast< SvxBorderLineStyle>(
974  ppnLineParam[ nXclLine ][ 1 ]) );
975  return true;
976 }
977 
978 } // namespace
979 
980 void XclImpCellBorder::FillToItemSet( SfxItemSet& rItemSet, const XclImpPalette& rPalette, bool bSkipPoolDefs ) const
981 {
983  {
984  SvxBoxItem aBoxItem( ATTR_BORDER );
986  if( mbLeftUsed && lclConvertBorderLine( aLine, rPalette, mnLeftLine, mnLeftColor ) )
987  aBoxItem.SetLine( &aLine, SvxBoxItemLine::LEFT );
988  if( mbRightUsed && lclConvertBorderLine( aLine, rPalette, mnRightLine, mnRightColor ) )
989  aBoxItem.SetLine( &aLine, SvxBoxItemLine::RIGHT );
990  if( mbTopUsed && lclConvertBorderLine( aLine, rPalette, mnTopLine, mnTopColor ) )
991  aBoxItem.SetLine( &aLine, SvxBoxItemLine::TOP );
992  if( mbBottomUsed && lclConvertBorderLine( aLine, rPalette, mnBottomLine, mnBottomColor ) )
993  aBoxItem.SetLine( &aLine, SvxBoxItemLine::BOTTOM );
994  ScfTools::PutItem( rItemSet, aBoxItem, bSkipPoolDefs );
995  }
996  if( !mbDiagUsed )
997  return;
998 
999  SvxLineItem aTLBRItem( ATTR_BORDER_TLBR );
1000  SvxLineItem aBLTRItem( ATTR_BORDER_BLTR );
1002  if( lclConvertBorderLine( aLine, rPalette, mnDiagLine, mnDiagColor ) )
1003  {
1004  if( mbDiagTLtoBR )
1005  aTLBRItem.SetLine( &aLine );
1006  if( mbDiagBLtoTR )
1007  aBLTRItem.SetLine( &aLine );
1008  }
1009  ScfTools::PutItem( rItemSet, aTLBRItem, bSkipPoolDefs );
1010  ScfTools::PutItem( rItemSet, aBLTRItem, bSkipPoolDefs );
1011 }
1012 
1014 {
1015  SetUsedFlags( false );
1016 }
1017 
1019 {
1020  mbForeUsed = mbBackUsed = mbPattUsed = bUsed;
1021 }
1022 
1024 {
1028  SetUsedFlags( true );
1029 }
1030 
1031 void XclImpCellArea::FillFromXF3( sal_uInt16 nArea )
1032 {
1033  mnPattern = ::extract_value< sal_uInt8 >( nArea, 0, 6 );
1034  mnForeColor = ::extract_value< sal_uInt16 >( nArea, 6, 5 );
1035  mnBackColor = ::extract_value< sal_uInt16 >( nArea, 11, 5 );
1036  SetUsedFlags( true );
1037 }
1038 
1039 void XclImpCellArea::FillFromXF5( sal_uInt32 nArea )
1040 {
1041  mnPattern = ::extract_value< sal_uInt8 >( nArea, 16, 6 );
1042  mnForeColor = ::extract_value< sal_uInt16 >( nArea, 0, 7 );
1043  mnBackColor = ::extract_value< sal_uInt16 >( nArea, 7, 7 );
1044  SetUsedFlags( true );
1045 }
1046 
1047 void XclImpCellArea::FillFromXF8( sal_uInt32 nBorder2, sal_uInt16 nArea )
1048 {
1049  mnPattern = ::extract_value< sal_uInt8 >( nBorder2, 26, 6 );
1050  mnForeColor = ::extract_value< sal_uInt16 >( nArea, 0, 7 );
1051  mnBackColor = ::extract_value< sal_uInt16 >( nArea, 7, 7 );
1052  SetUsedFlags( true );
1053 }
1054 
1055 void XclImpCellArea::FillFromCF8( sal_uInt16 nPattern, sal_uInt16 nColor, sal_uInt32 nFlags )
1056 {
1057  mnForeColor = ::extract_value< sal_uInt16 >( nColor, 0, 7 );
1058  mnBackColor = ::extract_value< sal_uInt16 >( nColor, 7, 7 );
1059  mnPattern = ::extract_value< sal_uInt8 >( nPattern, 10, 6 );
1063 
1064  if( mbBackUsed && (!mbPattUsed || (mnPattern == EXC_PATT_SOLID)) )
1065  {
1067  mnPattern = EXC_PATT_SOLID;
1068  mbForeUsed = mbPattUsed = true;
1069  }
1070  else if( !mbBackUsed && mbPattUsed && (mnPattern == EXC_PATT_SOLID) )
1071  {
1072  mbPattUsed = false;
1073  }
1074 }
1075 
1076 void XclImpCellArea::FillToItemSet( SfxItemSet& rItemSet, const XclImpPalette& rPalette, bool bSkipPoolDefs ) const
1077 {
1078  if( !mbPattUsed ) // colors may be both unused in cond. formats
1079  return;
1080 
1081  SvxBrushItem aBrushItem( ATTR_BACKGROUND );
1082 
1083  // do not use IsTransparent() - old Calc filter writes transparency with different color indexes
1084  if( mnPattern == EXC_PATT_NONE )
1085  {
1086  aBrushItem.SetColor( COL_TRANSPARENT );
1087  }
1088  else
1089  {
1090  Color aFore( rPalette.GetColor( mbForeUsed ? mnForeColor : EXC_COLOR_WINDOWTEXT ) );
1091  Color aBack( rPalette.GetColor( mbBackUsed ? mnBackColor : EXC_COLOR_WINDOWBACK ) );
1092  aBrushItem.SetColor( XclTools::GetPatternColor( aFore, aBack, mnPattern ) );
1093  }
1094 
1095  ScfTools::PutItem( rItemSet, aBrushItem, bSkipPoolDefs );
1096 }
1097 
1099  XclXFBase( true ), // default is cell XF
1100  XclImpRoot( rRoot ),
1101  mpStyleSheet( nullptr ),
1102  mnXclNumFmt( 0 ),
1103  mnXclFont( 0 )
1104 {
1105 }
1106 
1108 {
1109 }
1110 
1112 {
1113  sal_uInt8 nReadFont, nReadNumFmt, nFlags;
1114  nReadFont = rStrm.ReaduInt8();
1115  rStrm.Ignore( 1 );
1116  nReadNumFmt = rStrm.ReaduInt8();
1117  nFlags = rStrm.ReaduInt8();
1118 
1119  // XF type always cell, no parent, used flags always true
1120  SetAllUsedFlags( true );
1121 
1122  // attributes
1123  maProtection.FillFromXF2( nReadNumFmt );
1124  mnXclFont = nReadFont;
1125  mnXclNumFmt = nReadNumFmt & EXC_XF2_VALFMT_MASK;
1126  maAlignment.FillFromXF2( nFlags );
1127  maBorder.FillFromXF2( nFlags );
1128  maArea.FillFromXF2( nFlags );
1129 }
1130 
1132 {
1133  sal_uInt32 nBorder;
1134  sal_uInt16 nTypeProt, nAlign, nArea;
1135  sal_uInt8 nReadFont, nReadNumFmt;
1136  nReadFont = rStrm.ReaduInt8();
1137  nReadNumFmt = rStrm.ReaduInt8();
1138  nTypeProt = rStrm.ReaduInt16();
1139  nAlign = rStrm.ReaduInt16();
1140  nArea = rStrm.ReaduInt16();
1141  nBorder = rStrm.ReaduInt32();
1142 
1143  // XF type/parent, attribute used flags
1144  mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE ); // new in BIFF3
1145  mnParent = ::extract_value< sal_uInt16 >( nAlign, 4, 12 ); // new in BIFF3
1146  SetUsedFlags( ::extract_value< sal_uInt8 >( nTypeProt, 10, 6 ) );
1147 
1148  // attributes
1149  maProtection.FillFromXF3( nTypeProt );
1150  mnXclFont = nReadFont;
1151  mnXclNumFmt = nReadNumFmt;
1152  maAlignment.FillFromXF3( nAlign );
1153  maBorder.FillFromXF3( nBorder );
1154  maArea.FillFromXF3( nArea ); // new in BIFF3
1155 }
1156 
1158 {
1159  sal_uInt32 nBorder;
1160  sal_uInt16 nTypeProt, nAlign, nArea;
1161  sal_uInt8 nReadFont, nReadNumFmt;
1162  nReadFont = rStrm.ReaduInt8();
1163  nReadNumFmt = rStrm.ReaduInt8();
1164  nTypeProt = rStrm.ReaduInt16();
1165  nAlign = rStrm.ReaduInt16();
1166  nArea = rStrm.ReaduInt16();
1167  nBorder = rStrm.ReaduInt32();
1168 
1169  // XF type/parent, attribute used flags
1170  mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE );
1171  mnParent = ::extract_value< sal_uInt16 >( nTypeProt, 4, 12 );
1172  SetUsedFlags( ::extract_value< sal_uInt8 >( nAlign, 10, 6 ) );
1173 
1174  // attributes
1175  maProtection.FillFromXF3( nTypeProt );
1176  mnXclFont = nReadFont;
1177  mnXclNumFmt = nReadNumFmt;
1178  maAlignment.FillFromXF4( nAlign );
1179  maBorder.FillFromXF3( nBorder );
1180  maArea.FillFromXF3( nArea );
1181 }
1182 
1184 {
1185  sal_uInt32 nArea, nBorder;
1186  sal_uInt16 nTypeProt, nAlign;
1187  mnXclFont = rStrm.ReaduInt16();
1188  mnXclNumFmt = rStrm.ReaduInt16();
1189  nTypeProt = rStrm.ReaduInt16();
1190  nAlign = rStrm.ReaduInt16();
1191  nArea = rStrm.ReaduInt32();
1192  nBorder = rStrm.ReaduInt32();
1193 
1194  // XF type/parent, attribute used flags
1195  mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE );
1196  mnParent = ::extract_value< sal_uInt16 >( nTypeProt, 4, 12 );
1197  SetUsedFlags( ::extract_value< sal_uInt8 >( nAlign, 10, 6 ) );
1198 
1199  // attributes
1200  maProtection.FillFromXF3( nTypeProt );
1201  maAlignment.FillFromXF5( nAlign );
1202  maBorder.FillFromXF5( nBorder, nArea );
1203  maArea.FillFromXF5( nArea );
1204 }
1205 
1207 {
1208  sal_uInt32 nBorder1, nBorder2;
1209  sal_uInt16 nTypeProt, nAlign, nMiscAttrib, nArea;
1210  mnXclFont = rStrm.ReaduInt16();
1211  mnXclNumFmt = rStrm.ReaduInt16();
1212  nTypeProt = rStrm.ReaduInt16();
1213  nAlign = rStrm.ReaduInt16();
1214  nMiscAttrib = rStrm.ReaduInt16();
1215  nBorder1 = rStrm.ReaduInt32();
1216  nBorder2 = rStrm.ReaduInt32( );
1217  nArea = rStrm.ReaduInt16();
1218 
1219  // XF type/parent, attribute used flags
1220  mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE );
1221  mnParent = ::extract_value< sal_uInt16 >( nTypeProt, 4, 12 );
1222  SetUsedFlags( ::extract_value< sal_uInt8 >( nMiscAttrib, 10, 6 ) );
1223 
1224  // attributes
1225  maProtection.FillFromXF3( nTypeProt );
1226  maAlignment.FillFromXF8( nAlign, nMiscAttrib );
1227  maBorder.FillFromXF8( nBorder1, nBorder2 );
1228  maArea.FillFromXF8( nBorder2, nArea );
1229 }
1230 
1232 {
1233  switch( GetBiff() )
1234  {
1235  case EXC_BIFF2: ReadXF2( rStrm ); break;
1236  case EXC_BIFF3: ReadXF3( rStrm ); break;
1237  case EXC_BIFF4: ReadXF4( rStrm ); break;
1238  case EXC_BIFF5: ReadXF5( rStrm ); break;
1239  case EXC_BIFF8: ReadXF8( rStrm ); break;
1240  default: DBG_ERROR_BIFF();
1241  }
1242 }
1243 
1244 const ScPatternAttr& XclImpXF::CreatePattern( bool bSkipPoolDefs )
1245 {
1246  if( mpPattern )
1247  return *mpPattern;
1248 
1249  // create new pattern attribute set
1250  mpPattern.reset( new ScPatternAttr( GetDoc().GetPool() ) );
1251  SfxItemSet& rItemSet = mpPattern->GetItemSet();
1252  XclImpXF* pParentXF = IsCellXF() ? GetXFBuffer().GetXF( mnParent ) : nullptr;
1253 
1254  // parent cell style
1255  if( IsCellXF() && !mpStyleSheet )
1256  {
1258 
1259  /* Enables mb***Used flags, if the formatting attributes differ from
1260  the passed XF record. In cell XFs Excel uses the cell attributes,
1261  if they differ from the parent style XF.
1262  ...or if the respective flag is not set in parent style XF. */
1263  if( pParentXF )
1264  {
1265  if( !mbProtUsed )
1266  mbProtUsed = !pParentXF->mbProtUsed || !(maProtection == pParentXF->maProtection);
1267  if( !mbFontUsed )
1268  mbFontUsed = !pParentXF->mbFontUsed || (mnXclFont != pParentXF->mnXclFont);
1269  if( !mbFmtUsed )
1270  mbFmtUsed = !pParentXF->mbFmtUsed || (mnXclNumFmt != pParentXF->mnXclNumFmt);
1271  if( !mbAlignUsed )
1272  mbAlignUsed = !pParentXF->mbAlignUsed || !(maAlignment == pParentXF->maAlignment);
1273  if( !mbBorderUsed )
1274  mbBorderUsed = !pParentXF->mbBorderUsed || !(maBorder == pParentXF->maBorder);
1275  if( !mbAreaUsed )
1276  mbAreaUsed = !pParentXF->mbAreaUsed || !(maArea == pParentXF->maArea);
1277  }
1278  }
1279 
1280  // cell protection
1281  if( mbProtUsed )
1282  maProtection.FillToItemSet( rItemSet, bSkipPoolDefs );
1283 
1284  // font
1285  if( mbFontUsed )
1286  GetFontBuffer().FillToItemSet( rItemSet, XclFontItemType::Cell, mnXclFont, bSkipPoolDefs );
1287 
1288  // value format
1289  if( mbFmtUsed )
1290  {
1291  GetNumFmtBuffer().FillToItemSet( rItemSet, mnXclNumFmt, bSkipPoolDefs );
1292  // Trace occurrences of Windows date formats
1294  }
1295 
1296  // alignment
1297  if( mbAlignUsed )
1298  maAlignment.FillToItemSet( rItemSet, GetFontBuffer().GetFont( mnXclFont ), bSkipPoolDefs );
1299 
1300  // border
1301  if( mbBorderUsed )
1302  {
1303  maBorder.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
1307  }
1308 
1309  // area
1310  if( mbAreaUsed )
1311  {
1312  maArea.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
1315  }
1316 
1317  /* #i38709# Decide which rotation reference mode to use. If any outer
1318  border line of the cell is set (either explicitly or via cell style),
1319  and the cell contents are rotated, set rotation reference to bottom of
1320  cell. This causes the borders to be painted rotated with the text. */
1321  if( mbAlignUsed || mbBorderUsed )
1322  {
1324  const XclImpCellAlign* pAlign = mbAlignUsed ? &maAlignment : (pParentXF ? &pParentXF->maAlignment : nullptr);
1325  const XclImpCellBorder* pBorder = mbBorderUsed ? &maBorder : (pParentXF ? &pParentXF->maBorder : nullptr);
1326  if( pAlign && pBorder && (0 < pAlign->mnRotation) && (pAlign->mnRotation <= 180) && pBorder->HasAnyOuterBorder() )
1327  eRotateMode = SVX_ROTATE_MODE_BOTTOM;
1328  ScfTools::PutItem( rItemSet, SvxRotateModeItem( eRotateMode, ATTR_ROTATE_MODE ), bSkipPoolDefs );
1329  }
1330 
1331  // Excel's cell margins are different from Calc's default margins.
1332  SvxMarginItem aItem(40, 40, 40, 40, ATTR_MARGIN);
1333  ScfTools::PutItem(rItemSet, aItem, bSkipPoolDefs);
1334 
1335  return *mpPattern;
1336 }
1337 
1339  std::vector<ScAttrEntry>& rAttrs, SCROW nRow1, SCROW nRow2, sal_uInt32 nForceScNumFmt)
1340 {
1341  // force creation of cell style and hard formatting, do it here to have mpStyleSheet
1342  CreatePattern();
1343  ScPatternAttr& rPat = *mpPattern;
1344 
1345  // insert into document
1346  ScDocument& rDoc = GetDoc();
1347 
1348  if (IsCellXF())
1349  {
1350  if (mpStyleSheet)
1351  {
1352  // Apply style sheet. Don't clear the direct formats.
1353  rPat.SetStyleSheet(mpStyleSheet, false);
1354  }
1355  else
1356  {
1357  // When the cell format is not associated with any style, use the
1358  // 'Default' style. Some buggy XLS docs generated by apps other
1359  // than Excel (such as 1C) may not have any built-in styles at
1360  // all.
1361  ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
1362  if (pStylePool)
1363  {
1364  ScStyleSheet* pStyleSheet = static_cast<ScStyleSheet*>(
1365  pStylePool->Find(
1366  ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para));
1367 
1368  if (pStyleSheet)
1369  rPat.SetStyleSheet(pStyleSheet, false);
1370  }
1371 
1372  }
1373  }
1374 
1375  if (nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND)
1376  {
1377  ScPatternAttr aNumPat(rDoc.GetPool());
1378  GetNumFmtBuffer().FillScFmtToItemSet(aNumPat.GetItemSet(), nForceScNumFmt);
1379  rPat.GetItemSet().Put(aNumPat.GetItemSet());
1380  }
1381 
1382  // Make sure we skip unnamed styles.
1383  if (!rPat.GetStyleName())
1384  return;
1385 
1386  // Check for a gap between the last entry and this one.
1387  bool bHasGap = false;
1388  if (rAttrs.empty() && nRow1 > 0)
1389  // First attribute range doesn't start at row 0.
1390  bHasGap = true;
1391 
1392  if (!rAttrs.empty() && rAttrs.back().nEndRow + 1 < nRow1)
1393  bHasGap = true;
1394 
1395  if (bHasGap)
1396  {
1397  // Fill this gap with the default pattern.
1398  ScAttrEntry aEntry;
1399  aEntry.nEndRow = nRow1 - 1;
1400  aEntry.pPattern = rDoc.GetDefPattern();
1401  rAttrs.push_back(aEntry);
1402  }
1403 
1404  ScAttrEntry aEntry;
1405  aEntry.nEndRow = nRow2;
1406  aEntry.pPattern = &rDoc.GetPool()->Put(rPat);
1407  rAttrs.push_back(aEntry);
1408 }
1409 
1411  SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2, SCROW nScRow2,
1412  SCTAB nScTab )
1413 {
1414  // force creation of cell style and hard formatting, do it here to have mpStyleSheet
1415  const ScPatternAttr& rPattern = CreatePattern();
1416 
1417  // insert into document
1418  ScDocument& rDoc = GetDoc();
1419  if( IsCellXF() && mpStyleSheet )
1420  rDoc.ApplyStyleAreaTab( nScCol1, nScRow1, nScCol2, nScRow2, nScTab, *mpStyleSheet );
1421  if( HasUsedFlags() )
1422  rDoc.ApplyPatternAreaTab( nScCol1, nScRow1, nScCol2, nScRow2, nScTab, rPattern );
1423 
1424 }
1425 
1427  const ScAddress& rScPos, sal_uInt8 nFlags1, sal_uInt8 nFlags2, sal_uInt8 nFlags3 )
1428 {
1429  /* Create an XF object and let it do the work. We will have access to its
1430  private members here. */
1431  XclImpXF aXF( rRoot );
1432 
1433  // no used flags available in BIFF2 (always true)
1434  aXF.SetAllUsedFlags( true );
1435 
1436  // set the attributes
1437  aXF.maProtection.FillFromXF2( nFlags1 );
1438  aXF.maAlignment.FillFromXF2( nFlags3 );
1439  aXF.maBorder.FillFromXF2( nFlags3 );
1440  aXF.maArea.FillFromXF2( nFlags3 );
1441  aXF.mnXclNumFmt = ::extract_value< sal_uInt16 >( nFlags2, 0, 6 );
1442  aXF.mnXclFont = ::extract_value< sal_uInt16 >( nFlags2, 6, 2 );
1443 
1444  // write the attributes to the cell
1445  aXF.ApplyPattern( rScPos.Col(), rScPos.Row(), rScPos.Col(), rScPos.Row(), rScPos.Tab() );
1446 }
1447 
1449 {
1450  /* Notes about finding the mb***Used flags:
1451  - In cell XFs a *set* bit means a used attribute.
1452  - In style XFs a *cleared* bit means a used attribute.
1453  The mb***Used members always store true, if the attribute is used.
1454  The "mbCellXF == ::get_flag(...)" construct evaluates to true in
1455  both mentioned cases: cell XF and set bit; or style XF and cleared bit.
1456  */
1457  mbProtUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_PROT ));
1458  mbFontUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_FONT ));
1459  mbFmtUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_VALFMT ));
1460  mbAlignUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_ALIGN ));
1461  mbBorderUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_BORDER ));
1462  mbAreaUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_AREA ));
1463 }
1464 
1466  XclImpRoot( rRoot ),
1467  mnXfId( EXC_XF_NOTFOUND ),
1468  mnBuiltinId( EXC_STYLE_USERDEF ),
1470  mbBuiltin( false ),
1471  mbCustom( false ),
1472  mbHidden( false ),
1473  mpStyleSheet( nullptr )
1474 {
1475 }
1476 
1478 {
1480 
1481  sal_uInt16 nXFIndex;
1482  nXFIndex = rStrm.ReaduInt16();
1483  mnXfId = nXFIndex & EXC_STYLE_XFMASK;
1484  mbBuiltin = ::get_flag( nXFIndex, EXC_STYLE_BUILTIN );
1485 
1486  if( mbBuiltin )
1487  {
1488  mnBuiltinId = rStrm.ReaduInt8();
1489  mnLevel = rStrm.ReaduInt8();
1490  }
1491  else
1492  {
1493  maName = (GetBiff() <= EXC_BIFF5) ? rStrm.ReadByteString( false ) : rStrm.ReadUniString();
1494  // #i103281# check if this is a new built-in style introduced in XL2007
1495  if( (GetBiff() == EXC_BIFF8) && (rStrm.GetNextRecId() == EXC_ID_STYLEEXT) && rStrm.StartNextRecord() )
1496  {
1497  sal_uInt8 nExtFlags;
1498  rStrm.Ignore( 12 );
1499  nExtFlags = rStrm.ReaduInt8();
1500  mbBuiltin = ::get_flag( nExtFlags, EXC_STYLEEXT_BUILTIN );
1501  mbCustom = ::get_flag( nExtFlags, EXC_STYLEEXT_CUSTOM );
1502  mbHidden = ::get_flag( nExtFlags, EXC_STYLEEXT_HIDDEN );
1503  if( mbBuiltin )
1504  {
1505  rStrm.Ignore( 1 ); // category
1506  mnBuiltinId = rStrm.ReaduInt8();
1507  mnLevel = rStrm.ReaduInt8();
1508  }
1509  }
1510  }
1511 }
1512 
1514 {
1515  // #i1624# #i1768# ignore unnamed user styles
1516  if( !mpStyleSheet && (!maFinalName.isEmpty()) )
1517  {
1518  bool bCreatePattern = false;
1519  XclImpXF* pXF = GetXFBuffer().GetXF( mnXfId );
1520 
1521  bool bDefStyle = mbBuiltin && (mnBuiltinId == EXC_STYLE_NORMAL);
1522  if( bDefStyle )
1523  {
1524  // set all flags to true to get all items in XclImpXF::CreatePattern()
1525  if( pXF ) pXF->SetAllUsedFlags( true );
1526  // use existing "Default" style sheet
1527  mpStyleSheet = static_cast< ScStyleSheet* >( GetStyleSheetPool().Find(
1528  ScResId( STR_STYLENAME_STANDARD ), SfxStyleFamily::Para ) );
1529  OSL_ENSURE( mpStyleSheet, "XclImpStyle::CreateStyleSheet - Default style not found" );
1530  bCreatePattern = true;
1531  }
1532  else
1533  {
1534  /* #i103281# do not create another style sheet of the same name,
1535  if it exists already. This is needed to prevent that styles
1536  pasted from clipboard get duplicated over and over. */
1537  mpStyleSheet = static_cast< ScStyleSheet* >( GetStyleSheetPool().Find( maFinalName, SfxStyleFamily::Para ) );
1538  if( !mpStyleSheet )
1539  {
1540  mpStyleSheet = &static_cast< ScStyleSheet& >( GetStyleSheetPool().Make( maFinalName, SfxStyleFamily::Para, SfxStyleSearchBits::UserDefined ) );
1541  bCreatePattern = true;
1542  }
1543  }
1544 
1545  // bDefStyle==true omits default pool items in CreatePattern()
1546  if( bCreatePattern && mpStyleSheet && pXF )
1547  mpStyleSheet->GetItemSet().Put( pXF->CreatePattern( bDefStyle ).GetItemSet() );
1548  }
1549  return mpStyleSheet;
1550 }
1551 
1552 void XclImpStyle::CreateUserStyle( const OUString& rFinalName )
1553 {
1554  maFinalName = rFinalName;
1555  if( !IsBuiltin() || mbCustom )
1556  CreateStyleSheet();
1557 }
1558 
1560  XclImpRoot( rRoot )
1561 {
1562 }
1563 
1565 {
1566  maXFList.clear();
1567  maBuiltinStyles.clear();
1568  maUserStyles.clear();
1569  maStylesByXf.clear();
1570 }
1571 
1573 {
1574  std::unique_ptr<XclImpXF> xXF = std::make_unique<XclImpXF>(GetRoot());
1575  xXF->ReadXF(rStrm);
1576  maXFList.emplace_back(std::move(xXF));
1577 }
1578 
1580 {
1581  std::unique_ptr<XclImpStyle> xStyle(std::make_unique<XclImpStyle>(GetRoot()));
1582  xStyle->ReadStyle(rStrm);
1583  XclImpStyleList& rStyleList = (xStyle->IsBuiltin() ? maBuiltinStyles : maUserStyles);
1584  rStyleList.emplace_back(std::move(xStyle));
1585  XclImpStyle* pStyle = rStyleList.back().get();
1586  OSL_ENSURE( maStylesByXf.count( pStyle->GetXfId() ) == 0, "XclImpXFBuffer::ReadStyle - multiple styles with equal XF identifier" );
1587  maStylesByXf[ pStyle->GetXfId() ] = pStyle;
1588 }
1589 
1590 sal_uInt16 XclImpXFBuffer::GetFontIndex( sal_uInt16 nXFIndex ) const
1591 {
1592  const XclImpXF* pXF = GetXF( nXFIndex );
1593  return pXF ? pXF->GetFontIndex() : EXC_FONT_NOTFOUND;
1594 }
1595 
1596 const XclImpFont* XclImpXFBuffer::GetFont( sal_uInt16 nXFIndex ) const
1597 {
1598  return GetFontBuffer().GetFont( GetFontIndex( nXFIndex ) );
1599 }
1600 
1601 namespace {
1602 
1604 struct IgnoreCaseCompare
1605 {
1606  bool operator()( const OUString& rName1, std::u16string_view rName2 ) const
1607  { return rName1.compareToIgnoreAsciiCase( rName2 ) < 0; }
1608 };
1609 
1610 } // namespace
1611 
1613 {
1614  // calculate final names of all styles
1615  std::map< OUString, XclImpStyle*, IgnoreCaseCompare > aCellStyles;
1616  std::vector< XclImpStyle* > aConflictNameStyles;
1617 
1618  /* First, reserve style names that are built-in in Calc. This causes that
1619  imported cell styles get different unused names and thus do not try to
1620  overwrite these built-in styles. For BIFF4 workbooks (which contain a
1621  separate list of cell styles per sheet), reserve all existing styles if
1622  current sheet is not the first sheet (this styles buffer will be
1623  initialized again for every new sheet). This will create unique names
1624  for styles in different sheets with the same name. Assuming that the
1625  BIFF4W import filter is never used to import from clipboard... */
1626  bool bReserveAll = (GetBiff() == EXC_BIFF4) && (GetCurrScTab() > 0);
1627  SfxStyleSheetIterator aStyleIter( GetDoc().GetStyleSheetPool(), SfxStyleFamily::Para );
1628  OUString aStandardName = ScResId( STR_STYLENAME_STANDARD );
1629  for( SfxStyleSheetBase* pStyleSheet = aStyleIter.First(); pStyleSheet; pStyleSheet = aStyleIter.Next() )
1630  if( (pStyleSheet->GetName() != aStandardName) && (bReserveAll || !pStyleSheet->IsUserDefined()) )
1631  if( aCellStyles.count( pStyleSheet->GetName() ) == 0 )
1632  aCellStyles[ pStyleSheet->GetName() ] = nullptr;
1633 
1634  /* Calculate names of built-in styles. Store styles with reserved names
1635  in the aConflictNameStyles list. */
1636  for( const auto& rxStyle : maBuiltinStyles )
1637  {
1638  OUString aStyleName = XclTools::GetBuiltInStyleName( rxStyle->GetBuiltinId(), rxStyle->GetName(), rxStyle->GetLevel() );
1639  OSL_ENSURE( bReserveAll || (aCellStyles.count( aStyleName ) == 0),
1640  "XclImpXFBuffer::CreateUserStyles - multiple styles with equal built-in identifier" );
1641  if( aCellStyles.count( aStyleName ) > 0 )
1642  aConflictNameStyles.push_back( rxStyle.get() );
1643  else
1644  aCellStyles[ aStyleName ] = rxStyle.get();
1645  }
1646 
1647  /* Calculate names of user defined styles. Store styles with reserved
1648  names in the aConflictNameStyles list. */
1649  for( const auto& rxStyle : maUserStyles )
1650  {
1651  // #i1624# #i1768# ignore unnamed user styles
1652  if( !rxStyle->GetName().isEmpty() )
1653  {
1654  if( aCellStyles.count( rxStyle->GetName() ) > 0 )
1655  aConflictNameStyles.push_back( rxStyle.get() );
1656  else
1657  aCellStyles[ rxStyle->GetName() ] = rxStyle.get();
1658  }
1659  }
1660 
1661  // find unused names for all styles with conflicting names
1662  for( XclImpStyle* pStyle : aConflictNameStyles )
1663  {
1664  OUString aUnusedName;
1665  sal_Int32 nIndex = 0;
1666  do
1667  {
1668  aUnusedName = pStyle->GetName() + " " + OUString::number( ++nIndex );
1669  }
1670  while( aCellStyles.count( aUnusedName ) > 0 );
1671  aCellStyles[ aUnusedName ] = pStyle;
1672  }
1673 
1674  // set final names and create user-defined and modified built-in cell styles
1675  for( auto& [rStyleName, rpStyle] : aCellStyles )
1676  if( rpStyle )
1677  rpStyle->CreateUserStyle( rStyleName );
1678 }
1679 
1681 {
1682  XclImpStyleMap::iterator aIt = maStylesByXf.find( nXFIndex );
1683  return (aIt == maStylesByXf.end()) ? nullptr : aIt->second->CreateStyleSheet();
1684 }
1685 
1686 // Buffer for XF indexes in cells =============================================
1687 
1688 bool XclImpXFRange::Expand( SCROW nScRow, const XclImpXFIndex& rXFIndex )
1689 {
1690  if( maXFIndex != rXFIndex )
1691  return false;
1692 
1693  if( mnScRow2 + 1 == nScRow )
1694  {
1695  ++mnScRow2;
1696  return true;
1697  }
1698  if( mnScRow1 > 0 && (mnScRow1 - 1 == nScRow) )
1699  {
1700  --mnScRow1;
1701  return true;
1702  }
1703 
1704  return false;
1705 }
1706 
1707 bool XclImpXFRange::Expand( const XclImpXFRange& rNextRange )
1708 {
1709  OSL_ENSURE( mnScRow2 < rNextRange.mnScRow1, "XclImpXFRange::Expand - rows out of order" );
1710  if( (maXFIndex == rNextRange.maXFIndex) && (mnScRow2 + 1 == rNextRange.mnScRow1) )
1711  {
1712  mnScRow2 = rNextRange.mnScRow2;
1713  return true;
1714  }
1715  return false;
1716 }
1717 
1719 {
1720  // List should be empty when inserting the default column format.
1721  // Later explicit SetXF() calls will break up this range.
1722  OSL_ENSURE( maIndexList.empty(), "XclImpXFRangeColumn::SetDefaultXF - Setting Default Column XF is not empty" );
1723 
1724  // insert a complete row range with one insert.
1725  maIndexList.push_back( std::make_unique<XclImpXFRange>( 0, MAXROW, rXFIndex ) );
1726 }
1727 
1728 void XclImpXFRangeColumn::SetXF( SCROW nScRow, const XclImpXFIndex& rXFIndex )
1729 {
1730  XclImpXFRange* pPrevRange;
1731  XclImpXFRange* pNextRange;
1732  sal_uLong nNextIndex;
1733 
1734  Find( pPrevRange, pNextRange, nNextIndex, nScRow );
1735 
1736  // previous range:
1737  // try to overwrite XF (if row is contained in) or try to expand range
1738  if( pPrevRange )
1739  {
1740  if( pPrevRange->Contains( nScRow ) ) // overwrite old XF
1741  {
1742  if( rXFIndex == pPrevRange->maXFIndex )
1743  return;
1744 
1745  SCROW nFirstScRow = pPrevRange->mnScRow1;
1746  SCROW nLastScRow = pPrevRange->mnScRow2;
1747  sal_uLong nIndex = nNextIndex - 1;
1748  XclImpXFRange* pThisRange = pPrevRange;
1749  pPrevRange = (nIndex > 0 && nIndex <= maIndexList.size()) ? maIndexList[ nIndex - 1 ].get() : nullptr;
1750 
1751  if( nFirstScRow == nLastScRow ) // replace solely XF
1752  {
1753  pThisRange->maXFIndex = rXFIndex;
1754  TryConcatPrev( nNextIndex ); // try to concat. next with this
1755  TryConcatPrev( nIndex ); // try to concat. this with previous
1756  }
1757  else if( nFirstScRow == nScRow ) // replace first XF
1758  {
1759  ++(pThisRange->mnScRow1);
1760  // try to concatenate with previous of this
1761  if( !pPrevRange || !pPrevRange->Expand( nScRow, rXFIndex ) )
1762  Insert( new XclImpXFRange( nScRow, rXFIndex ), nIndex );
1763  }
1764  else if( nLastScRow == nScRow ) // replace last XF
1765  {
1766  --(pThisRange->mnScRow2);
1767  if( !pNextRange || !pNextRange->Expand( nScRow, rXFIndex ) )
1768  Insert( new XclImpXFRange( nScRow, rXFIndex ), nNextIndex );
1769  }
1770  else // insert in the middle of the range
1771  {
1772  pThisRange->mnScRow1 = nScRow + 1;
1773  // List::Insert() moves entries towards end of list, so insert twice at nIndex
1774  Insert( new XclImpXFRange( nScRow, rXFIndex ), nIndex );
1775  Insert( new XclImpXFRange( nFirstScRow, nScRow - 1, pThisRange->maXFIndex ), nIndex );
1776  }
1777  return;
1778  }
1779  else if( pPrevRange->Expand( nScRow, rXFIndex ) ) // try to expand
1780  {
1781  TryConcatPrev( nNextIndex ); // try to concatenate next with expanded
1782  return;
1783  }
1784  }
1785 
1786  // try to expand next range
1787  if( pNextRange && pNextRange->Expand( nScRow, rXFIndex ) )
1788  return;
1789 
1790  // create new range
1791  Insert( new XclImpXFRange( nScRow, rXFIndex ), nNextIndex );
1792 }
1793 
1795 {
1796  maIndexList.insert( maIndexList.begin() + nIndex, std::unique_ptr<XclImpXFRange>(pXFRange) );
1797 }
1798 
1800  XclImpXFRange*& rpPrevRange, XclImpXFRange*& rpNextRange,
1801  sal_uLong& rnNextIndex, SCROW nScRow )
1802 {
1803 
1804  // test whether list is empty
1805  if( maIndexList.empty() )
1806  {
1807  rpPrevRange = rpNextRange = nullptr;
1808  rnNextIndex = 0;
1809  return;
1810  }
1811 
1812  rpPrevRange = maIndexList.front().get();
1813  rpNextRange = maIndexList.back().get();
1814 
1815  // test whether row is at end of list (contained in or behind last range)
1816  // rpPrevRange will contain a possible existing row
1817  if( rpNextRange->mnScRow1 <= nScRow )
1818  {
1819  rpPrevRange = rpNextRange;
1820  rpNextRange = nullptr;
1821  rnNextIndex = maIndexList.size();
1822  return;
1823  }
1824 
1825  // test whether row is at beginning of list (really before first range)
1826  if( nScRow < rpPrevRange->mnScRow1 )
1827  {
1828  rpNextRange = rpPrevRange;
1829  rpPrevRange = nullptr;
1830  rnNextIndex = 0;
1831  return;
1832  }
1833 
1834  // loop: find range entries before and after new row
1835  // break the loop if there is no more range between first and last -or-
1836  // if rpPrevRange contains nScRow (rpNextRange will never contain nScRow)
1837  sal_uLong nPrevIndex = 0;
1838  sal_uLong nMidIndex;
1839  rnNextIndex = maIndexList.size() - 1;
1840  XclImpXFRange* pMidRange;
1841  while( ((rnNextIndex - nPrevIndex) > 1) && (rpPrevRange->mnScRow2 < nScRow) )
1842  {
1843  nMidIndex = (nPrevIndex + rnNextIndex) / 2;
1844  pMidRange = maIndexList[nMidIndex].get();
1845  OSL_ENSURE( pMidRange, "XclImpXFRangeColumn::Find - missing XF index range" );
1846  if( nScRow < pMidRange->mnScRow1 ) // row is really before pMidRange
1847  {
1848  rpNextRange = pMidRange;
1849  rnNextIndex = nMidIndex;
1850  }
1851  else // row is in or after pMidRange
1852  {
1853  rpPrevRange = pMidRange;
1854  nPrevIndex = nMidIndex;
1855  }
1856  }
1857 
1858  // find next rpNextRange if rpPrevRange contains nScRow
1859  if( nScRow <= rpPrevRange->mnScRow2 )
1860  {
1861  rnNextIndex = nPrevIndex + 1;
1862  rpNextRange = maIndexList[rnNextIndex].get();
1863  }
1864 }
1865 
1867 {
1868  if( !nIndex || nIndex >= maIndexList.size() )
1869  return;
1870 
1871  XclImpXFRange& prevRange = *maIndexList[ nIndex - 1 ];
1872  XclImpXFRange& nextRange = *maIndexList[ nIndex ];
1873 
1874  if( prevRange.Expand( nextRange ) )
1875  maIndexList.erase( maIndexList.begin() + nIndex );
1876 }
1877 
1879  XclImpRoot( rRoot )
1880 {
1881 }
1882 
1884 {
1885 }
1886 
1888 {
1889  maColumns.clear();
1890  maHyperlinks.clear();
1892 }
1893 
1894 void XclImpXFRangeBuffer::SetXF( const ScAddress& rScPos, sal_uInt16 nXFIndex, XclImpXFInsertMode eMode )
1895 {
1896  SCCOL nScCol = rScPos.Col();
1897  SCROW nScRow = rScPos.Row();
1898 
1899  // set cell XF's
1900  size_t nIndex = static_cast< size_t >( nScCol );
1901  if( maColumns.size() <= nIndex )
1902  maColumns.resize( nIndex + 1 );
1903  if( !maColumns[ nIndex ] )
1904  maColumns[ nIndex ] = std::make_shared<XclImpXFRangeColumn>();
1905  // remember all Boolean cells, they will get 'Standard' number format
1906  maColumns[ nIndex ]->SetXF( nScRow, XclImpXFIndex( nXFIndex, eMode == xlXFModeBoolCell ) );
1907 
1908  // set "center across selection" and "fill" attribute for all following empty cells
1909  // ignore it on row default XFs
1910  if( eMode == xlXFModeRow )
1911  return;
1912 
1913  const XclImpXF* pXF = GetXFBuffer().GetXF( nXFIndex );
1914  if( pXF && ((pXF->GetHorAlign() == EXC_XF_HOR_CENTER_AS) || (pXF->GetHorAlign() == EXC_XF_HOR_FILL)) )
1915  {
1916  // expand last merged range if this attribute is set repeatedly
1917  ScRange* pRange = maMergeList.empty() ? nullptr : &maMergeList.back();
1918  if (pRange && (pRange->aEnd.Row() == nScRow) && (pRange->aEnd.Col() + 1 == nScCol) && (eMode == xlXFModeBlank))
1919  pRange->aEnd.IncCol();
1920  else if( eMode != xlXFModeBlank ) // do not merge empty cells
1921  maMergeList.push_back( ScRange( nScCol, nScRow, 0 ) );
1922  }
1923 }
1924 
1925 void XclImpXFRangeBuffer::SetXF( const ScAddress& rScPos, sal_uInt16 nXFIndex )
1926 {
1927  SetXF( rScPos, nXFIndex, xlXFModeCell );
1928 }
1929 
1930 void XclImpXFRangeBuffer::SetBlankXF( const ScAddress& rScPos, sal_uInt16 nXFIndex )
1931 {
1932  SetXF( rScPos, nXFIndex, xlXFModeBlank );
1933 }
1934 
1935 void XclImpXFRangeBuffer::SetBoolXF( const ScAddress& rScPos, sal_uInt16 nXFIndex )
1936 {
1937  SetXF( rScPos, nXFIndex, xlXFModeBoolCell );
1938 }
1939 
1940 void XclImpXFRangeBuffer::SetRowDefXF( SCROW nScRow, sal_uInt16 nXFIndex )
1941 {
1942  for( SCCOL nScCol = 0; nScCol <= MAXCOL; ++nScCol )
1943  SetXF( ScAddress( nScCol, nScRow, 0 ), nXFIndex, xlXFModeRow );
1944 }
1945 
1946 void XclImpXFRangeBuffer::SetColumnDefXF( SCCOL nScCol, sal_uInt16 nXFIndex )
1947 {
1948  // our array should not have values when creating the default column format.
1949  size_t nIndex = static_cast< size_t >( nScCol );
1950  if( maColumns.size() <= nIndex )
1951  maColumns.resize( nIndex + 1 );
1952  OSL_ENSURE( !maColumns[ nIndex ], "XclImpXFRangeBuffer::SetColumnDefXF - default column of XFs already has values" );
1953  maColumns[ nIndex ] = std::make_shared<XclImpXFRangeColumn>();
1954  maColumns[ nIndex ]->SetDefaultXF( XclImpXFIndex( nXFIndex ) );
1955 }
1956 
1958 {
1959  SCCOL nFromScCol = (nLine == SvxBoxItemLine::RIGHT) ? rRange.aEnd.Col() : rRange.aStart.Col();
1960  SCROW nFromScRow = (nLine == SvxBoxItemLine::BOTTOM) ? rRange.aEnd.Row() : rRange.aStart.Row();
1961  ScDocument& rDoc = GetDoc();
1962 
1963  const SvxBoxItem* pFromItem =
1964  rDoc.GetAttr( nFromScCol, nFromScRow, nScTab, ATTR_BORDER );
1965  const SvxBoxItem* pToItem =
1966  rDoc.GetAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, ATTR_BORDER );
1967 
1968  SvxBoxItem aNewItem( *pToItem );
1969  aNewItem.SetLine( pFromItem->GetLine( nLine ), nLine );
1970  rDoc.ApplyAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, aNewItem );
1971 }
1972 
1973 void XclImpXFRangeBuffer::SetHyperlink( const XclRange& rXclRange, const OUString& rUrl )
1974 {
1975  maHyperlinks.emplace_back( rXclRange, rUrl );
1976 }
1977 
1978 void XclImpXFRangeBuffer::SetMerge( SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2, SCROW nScRow2 )
1979 {
1980  if( (nScCol1 < nScCol2) || (nScRow1 < nScRow2) )
1981  maMergeList.push_back( ScRange( nScCol1, nScRow1, 0, nScCol2, nScRow2, 0 ) );
1982 }
1983 
1985 {
1986  ScDocumentImport& rDocImport = GetDocImport();
1987  ScDocument& rDoc = rDocImport.getDoc();
1988  SCTAB nScTab = GetCurrScTab();
1989 
1990  // apply patterns
1991  XclImpXFBuffer& rXFBuffer = GetXFBuffer();
1992  SCCOL nScCol = 0;
1993  for( const auto& rxColumn : maColumns )
1994  {
1995  // apply all cell styles of an existing column
1996  if( rxColumn )
1997  {
1998  XclImpXFRangeColumn& rColumn = *rxColumn;
1999  std::vector<ScAttrEntry> aAttrs;
2000  aAttrs.reserve(rColumn.end() - rColumn.begin());
2001 
2002  for (const auto& rxStyle : rColumn)
2003  {
2004  XclImpXFRange& rStyle = *rxStyle;
2005  const XclImpXFIndex& rXFIndex = rStyle.maXFIndex;
2006  XclImpXF* pXF = rXFBuffer.GetXF( rXFIndex.GetXFIndex() );
2007  if (!pXF)
2008  continue;
2009 
2010  sal_uInt32 nForceScNumFmt = rXFIndex.IsBoolCell() ?
2012 
2013  pXF->ApplyPatternToAttrVector(aAttrs, rStyle.mnScRow1, rStyle.mnScRow2, nForceScNumFmt);
2014  }
2015 
2016  if (aAttrs.empty() || aAttrs.back().nEndRow != rDoc.MaxRow())
2017  {
2018  ScAttrEntry aEntry;
2019  aEntry.nEndRow = rDoc.MaxRow();
2020  aEntry.pPattern = rDoc.GetDefPattern();
2021  aAttrs.push_back(aEntry);
2022  }
2023 
2024  aAttrs.shrink_to_fit();
2025  assert(aAttrs.size() > 0);
2026  ScDocumentImport::Attrs aAttrParam;
2027  aAttrParam.mvData.swap(aAttrs);
2028  aAttrParam.mbLatinNumFmtOnly = false; // when unsure, set it to false.
2029  rDocImport.setAttrEntries(nScTab, nScCol, std::move(aAttrParam));
2030  }
2031  ++nScCol;
2032  }
2033 
2034  // insert hyperlink cells
2035  for( const auto& [rXclRange, rUrl] : maHyperlinks )
2036  XclImpHyperlink::InsertUrl( GetRoot(), rXclRange, rUrl );
2037 
2038  // apply cell merging
2039  for ( size_t i = 0, nRange = maMergeList.size(); i < nRange; ++i )
2040  {
2041  const ScRange & rRange = maMergeList[ i ];
2042  const ScAddress& rStart = rRange.aStart;
2043  const ScAddress& rEnd = rRange.aEnd;
2044  bool bMultiCol = rStart.Col() != rEnd.Col();
2045  bool bMultiRow = rStart.Row() != rEnd.Row();
2046  // set correct right border
2047  if( bMultiCol )
2048  SetBorderLine( rRange, nScTab, SvxBoxItemLine::RIGHT );
2049  // set correct lower border
2050  if( bMultiRow )
2051  SetBorderLine( rRange, nScTab, SvxBoxItemLine::BOTTOM );
2052  // do merge
2053  if( bMultiCol || bMultiRow )
2054  rDoc.DoMerge( nScTab, rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() );
2055  // #i93609# merged range in a single row: test if manual row height is needed
2056  if( !bMultiRow )
2057  {
2058  bool bTextWrap = rDoc.GetAttr( rStart, ATTR_LINEBREAK )->GetValue();
2059  if( !bTextWrap && (rDoc.GetCellType( rStart ) == CELLTYPE_EDIT) )
2060  if (const EditTextObject* pEditObj = rDoc.GetEditText(rStart))
2061  bTextWrap = pEditObj->GetParagraphCount() > 1;
2062  if( bTextWrap )
2064  }
2065  }
2066 }
2067 
2068 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbCustom
True = builtin style.
Definition: xistyle.hxx:468
void FillFromXF2(sal_uInt8 nFlags)
Fills this struct with BIFF2 XF record data.
Definition: xistyle.cxx:860
XclFontPropSetType
Enumerates different types for objects with font settings (using different property names)...
Definition: xlstyle.hxx:395
sal_uInt16 mnBottomColor
Palette index for top line.
Definition: xlstyle.hxx:527
XclFontPropSetHelper & GetFontPropSetHelper() const
Returns the property set helper for fonts.
Definition: xlroot.cxx:418
sal_uInt8 mnTopLine
Style of right line.
Definition: xlstyle.hxx:531
Use edit engine Which-IDs (EE_CHAR_*).
bool mbShrink
true = Multi-line text.
Definition: xlstyle.hxx:496
constexpr TypedWhichId< SvxWeightItem > ATTR_CTL_FONT_WEIGHT(118)
const sal_uInt8 EXC_ORIENT_NONE
Definition: xlconst.hxx:133
bool HasChar(sal_UCS4) const
ScStyleSheet * CreateStyleSheet(sal_uInt16 nXFIndex)
Creates a cell style sheet of the passed XF and inserts it into the Calc document.
Definition: xistyle.cxx:1680
bool Expand(SCROW nScRow, const XclImpXFIndex &rXFIndex)
Returns true, if the range has been expanded.
Definition: xistyle.cxx:1688
void GuessScriptType()
Tests whether the font contains CJK or CTL characters.
Definition: xistyle.cxx:470
void ReadXF(XclImpStream &rStrm)
Reads an XF record.
Definition: xistyle.cxx:1572
bool mbAreaUsed
true = border data used.
Definition: xlstyle.hxx:595
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:33
bool mbDiagUsed
true = Bottom line style used.
Definition: xistyle.hxx:292
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
Represents an XF record index with additional information.
Definition: xistyle.hxx:356
void SetBorderLineStyle(SvxBorderLineStyle nNew)
bool GetFontCharMap(FontCharMapRef &rxFontCharMap) const
bool mbDiagBLtoTR
true = Top-left to bottom-right on.
Definition: xlstyle.hxx:535
SC_DLLPUBLIC void ApplyStyleAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScStyleSheet &rStyle)
Definition: document.cxx:4882
sal_uInt16 GetNextRecId()
Returns the record ID of the following record.
Definition: xistream.cxx:587
ScDocumentImport & GetDocImport()
Definition: xiroot.cxx:292
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:147
sal_Int32 nIndex
sal_uInt32 GetStdScNumFmt() const
Returns the core index of the current standard number format.
Definition: xlstyle.hxx:450
void FillFromCF(sal_uInt16 nAlign, sal_uInt16 nMiscAttrib)
Fills this struct with CF record data.
Definition: xistyle.cxx:802
sal_uInt8 mnCharSet
Windows font family.
Definition: xlstyle.hxx:294
ScAddress aStart
Definition: address.hxx:499
void ReadFontName8(XclImpStream &rStrm)
Reads and sets a Unicode string as font name.
Definition: xistyle.cxx:465
const XclImpFont * GetFont(sal_uInt16 nXFIndex) const
Returns the Excel font used in the specified XF record.
Definition: xistyle.cxx:1596
sal_uInt16 mnDiagColor
Palette index for bottom line.
Definition: xlstyle.hxx:528
const sal_uInt16 EXC_BORDER_HAIR
Definition: xlconst.hxx:251
void SetWidth(tools::Long nWidth)
void Finalize()
Applies styles and cell merging to the current sheet in the document.
Definition: xistyle.cxx:1984
void FillFromXF3(sal_uInt16 nArea)
Fills this struct with BIFF3/BIFF4 XF record data.
Definition: xistyle.cxx:1031
sal_uInt8 mnOrient
Vertical alignment.
Definition: xlstyle.hxx:491
std::vector< std::unique_ptr< XclImpStyle > > XclImpStyleList
Definition: xistyle.hxx:513
bool mbShadow
true = Outlined.
Definition: xlstyle.hxx:299
const sal_uInt16 EXC_XF_LINEBREAK
Styles don't have a parent.
Definition: xlstyle.hxx:148
Contains all XF records occurred in the file.
Definition: xistyle.hxx:477
void ReadCFFontBlock(XclImpStream &rStrm)
Reads the font block from a CF (conditional format) record.
Definition: xistyle.cxx:282
void SetAllUsedFlags(bool bUsed)
Sets all "attribute used" flags to the passed state.
Definition: xlstyle.cxx:1727
#define EMPTY_OUSTRING
Definition: global.hxx:214
XclImpNumFmtBuffer & GetNumFmtBuffer() const
Returns the number format buffer.
Definition: xiroot.cxx:151
const sal_uInt8 EXC_XF_DIFF_VALFMT
Shrink to fit into cell.
Definition: xlstyle.hxx:151
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:89
void TraceBorderLineStyle(bool bBorderLineStyle)
Definition: xltracer.cxx:74
ReturnType get_flagvalue(Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset)
Returns nSet, if at least one bit of nMask is set in nBitField, otherwise nUnset. ...
Definition: ftools.hxx:80
const sal_uInt32 EXC_CF_BORDER_TOP
Right border line modified?
Definition: xlcontent.hxx:72
XclImpXF(const XclImpXF &)=delete
make noncopyable
const sal_uInt16 EXC_ID_STYLEEXT
Default value for unused level.
Definition: xlstyle.hxx:241
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
SCROW mnScRow2
The first row of an equal-formatted range.
Definition: xistyle.hxx:529
SCROW Row() const
Definition: address.hxx:261
XclFontData maAppFont
List of all FONT records in the Excel file.
Definition: xistyle.hxx:196
Stores all data of an Excel font and provides import of FONT records.
Definition: xistyle.hxx:70
void SetManualRowHeight(SCROW nScRow)
Definition: colrowst.cxx:153
#define LANGUAGE_ENGLISH_US
XclImpCellBorder maBorder
All alignment attributes.
Definition: xistyle.hxx:435
Extends the XclCellBorder struct for import.
Definition: xistyle.hxx:286
SvxRotateMode
XclImpFontBuffer(const XclImpFontBuffer &)=delete
delete copy constructor
const sal_uInt16 EXC_XF_LOCKED
Definition: xlstyle.hxx:144
XclImpXFRangeBuffer(const XclImpXFRangeBuffer &)=delete
make noncopyable
FAMILY_MODERN
std::vector< std::pair< XclRange, OUString > > maHyperlinks
Array of column XF index buffers.
Definition: xistyle.hxx:665
bool mbDiagTLtoBR
Style of diagonal line(s).
Definition: xlstyle.hxx:534
void SetUsedFlags(bool bOuterUsed, bool bDiagUsed)
Sets outer line states and diagonal line states to used or unused.
Definition: xistyle.cxx:854
void TraceFillPattern(bool bFillPattern)
Definition: xltracer.cxx:80
const sal_uInt16 EXC_STYLE_XFMASK
Definition: xlstyle.hxx:222
void Find(XclImpXFRange *&rpPrevRange, XclImpXFRange *&rpNextRange, sal_uLong &rnNextIndex, SCROW nScRow)
Finds the previous and next row range from row position nScRow.
Definition: xistyle.cxx:1799
sal_Int16 mnLevel
ScRangeList maMergeList
Maps URLs to hyperlink cells.
Definition: xistyle.hxx:666
constexpr TypedWhichId< SfxBoolItem > ATTR_VERTICAL_ASIAN(137)
bool mbHidden
True = customized builtin style.
Definition: xistyle.hxx:469
std::vector< std::unique_ptr< XclImpXF > > maXFList
Definition: xistyle.hxx:516
IndexList::iterator end()
Definition: xistyle.hxx:576
OUString maName
Definition: xistyle.hxx:463
const sal_uInt8 EXC_ROT_STACKED
Text rotation: 90 deg clockwise.
Definition: xlconst.hxx:141
void SetCharWidth(const XclFontData &rFontData)
Sets the width of the '0' - '9' digit character as well as the ' ' space char (using the default font...
Definition: xlroot.cxx:207
bool IsBuiltin() const
Definition: xistyle.hxx:452
const sal_uInt32 EXC_CF_AREA_BGCOLOR
Foreground color modified?
Definition: xlcontent.hxx:77
const XclNumFmtMap & GetFormatMap() const
Returns the current number format map.
Definition: xlstyle.hxx:459
const XclImpRoot & mrRoot
Colors read from file.
Definition: xistyle.hxx:64
bool IsBoolCell() const
Definition: xistyle.hxx:363
ColorVec maColorTable
Definition: xistyle.hxx:63
constexpr TypedWhichId< SvxCrossedOutItem > ATTR_FONT_CROSSEDOUT(106)
sal_uIntPtr sal_uLong
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
bool mbCellXF
Index to parent style XF.
Definition: xlstyle.hxx:589
void FillToItemSet(SfxItemSet &rItemSet, bool bSkipPoolDefs=false) const
Inserts items representing this protection style into the item set.
Definition: xistyle.cxx:760
bool mbPattUsed
true = Background color used.
Definition: xistyle.hxx:328
constexpr TypedWhichId< SvxRotateModeItem > ATTR_ROTATE_MODE(136)
void FillFromXF3(sal_uInt32 nBorder)
Fills this struct with BIFF3/BIFF4 XF record data.
Definition: xistyle.cxx:870
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:285
sal_uInt16 mnXclNumFmt
Background area style.
Definition: xistyle.hxx:437
void FillFromXF8(sal_uInt32 nBorder1, sal_uInt32 nBorder2)
Fills this struct with BIFF8 XF record data.
Definition: xistyle.cxx:896
const sal_uInt16 EXC_BORDER_THICK
Definition: xlconst.hxx:248
sal_uInt8 mnRightLine
Style of left line.
Definition: xlstyle.hxx:530
bool HasAsianChars() const
Returns true, if this font contains characters for Asian scripts (CJK).
Definition: xistyle.hxx:95
css::uno::Reference< css::frame::XModel3 > GetModel() const
SvxEscapement GetScEscapement() const
Returns the Calc escapement style.
Definition: xlstyle.cxx:292
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:636
sal_uInt16 mnNextXclIdx
Maps Excel format indexes to Calc formats.
Definition: xistyle.hxx:243
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
SVX_ROTATE_MODE_STANDARD
bool mbFmtUsed
true = font index used.
Definition: xlstyle.hxx:592
void FillFromXF8(sal_uInt16 nAlign, sal_uInt16 nMiscAttrib)
Fills this struct with BIFF8 XF record data.
Definition: xistyle.cxx:791
XclFontData maData
Definition: xistyle.hxx:134
const SfxItemSet & GetItemSet() const
bool mbWeightUsed
true = Color used.
Definition: xistyle.hxx:142
Stores all default colors for a specific BIFF version.
Definition: xlstyle.hxx:250
sal_uInt16 mnHeight
Font color.
Definition: xlstyle.hxx:290
sal_uInt16 mnXclFont
Index to number format.
Definition: xistyle.hxx:438
const sal_uInt32 EXC_CF_AREA_PATTERN
Any border line modified?
Definition: xlcontent.hxx:75
Contains an (encoded) XF index for a range of rows in a single column.
Definition: xistyle.hxx:525
const sal_uInt16 EXC_XF_NOTFOUND
Excel index to default cell XF.
Definition: xlstyle.hxx:140
const sal_uInt16 EXC_FONTATTR_UNDERLINE
Definition: xlstyle.hxx:99
bool HasCharSet() const
Returns true, if the font character set is valid.
Definition: xistyle.hxx:88
ScAddress aEnd
Definition: address.hxx:500
rtl_TextEncoding GetFontEncoding() const
Returns the font text encoding.
Definition: xlstyle.cxx:249
basegfx::BColor maColor
sal_uInt16 mnXfId
Cell style name.
Definition: xistyle.hxx:464
virtual ~XclImpXFRangeBuffer() override
Definition: xistyle.cxx:1883
static sal_uInt8 GetXclRotFromOrient(sal_uInt8 nXclOrient)
Calculates BIFF8 rotation angle from BIFF2-BIFF5 text orientation.
Definition: xltools.cxx:176
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
const sal_uInt8 EXC_XF_VER_JUSTIFY
Definition: xlstyle.hxx:170
FAMILY_ROMAN
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
void SetLine(const editeng::SvxBorderLine *pNew)
bool mbItalicUsed
true = Underline style used.
Definition: xistyle.hxx:145
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
const sal_uInt16 EXC_COLOR_USEROFFSET
Definition: xlstyle.hxx:204
ScStyleSheet * mpStyleSheet
Calc item set.
Definition: xistyle.hxx:431
sal_uInt32 GetScFormat(sal_uInt16 nXclNumFmt) const
Returns the format key with the passed Excel index or NUMBERFORMAT_ENTRY_NOT_FOUND on error...
Definition: xistyle.cxx:724
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:322
RootData & GetOldRoot() const
Returns old RootData struct.
Definition: xlroot.hxx:138
Accessor class to ScDocument.
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4788
void SetDefaultXF(const XclImpXFIndex &rXFIndex)
Inserts a single row range into the list.
Definition: xistyle.cxx:1718
SCROW mnScRow1
Definition: xistyle.hxx:528
void CreateScFormats()
Creates the number formats in the Calc document.
Definition: xistyle.cxx:699
sal_uInt16 GetXfId() const
Definition: xistyle.hxx:451
const sal_uInt16 EXC_FONTATTR_ITALIC
Definition: xlstyle.hxx:98
const sal_uInt8 EXC_STYLE_USERDEF
"Followed_Hyperlink" style.
Definition: xlstyle.hxx:234
void FillToItemSet(SfxItemSet &rItemSet, XclFontItemType eType, bool bSkipPoolDefs=false) const
Fills all font properties to the item set.
Definition: xistyle.cxx:316
void ReadStyle(XclImpStream &rStrm)
Reads a STYLE record.
Definition: xistyle.cxx:1579
rtl_TextEncoding GetFontEncoding() const
Returns the text encoding for strings used with this font.
Definition: xistyle.cxx:239
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xiroot.hxx:131
sal_uInt8 mnBuiltinId
Formatting for this cell style.
Definition: xistyle.hxx:465
SvxCellVerJustify GetScVerAlign() const
Returns the Calc vertical alignment.
Definition: xlstyle.cxx:1581
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
void FillToItemSet(SfxItemSet &rItemSet, XclFontItemType eType, sal_uInt16 nFontIdx, bool bSkipPoolDefs=false) const
Fills all font properties from a FONT record to the item set.
Definition: xistyle.cxx:595
void ReadFontColor(XclImpStream &rStrm)
Reads and sets the font color.
Definition: xistyle.cxx:455
FontItalic GetScPosture() const
Returns the Calc font posture.
Definition: xlstyle.cxx:255
void SetMerge(SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2, SCROW nScRow2)
Inserts a complete merged cell range.
Definition: xistyle.cxx:1978
void FillFromXF2(sal_uInt8 nFlags)
Fills this struct with BIFF2 XF record data.
Definition: xistyle.cxx:765
XclImpCellProt maProtection
Calc cell style sheet.
Definition: xistyle.hxx:433
const ScPatternAttr & CreatePattern(bool bSkipPoolDefs=false)
Creates a Calc item set containing an item set with all cell properties.
Definition: xistyle.cxx:1244
void ApplyPattern(SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2, SCROW nScRow2, SCTAB nScTab)
Inserts all formatting attributes to the specified area in the Calc document.
Definition: xistyle.cxx:1410
const sal_uInt8 EXC_LINE_THIN
Definition: xlstyle.hxx:38
constexpr auto convertTwipToMm100(N n)
XclImpFont(const XclImpRoot &rRoot)
Definition: xistyle.cxx:192
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6087
ScStyleSheet * CreateStyleSheet()
Creates a cell style sheet and inserts it into the Calc document.
Definition: xistyle.cxx:1513
const sal_uInt8 EXC_LINE_HAIR
Definition: xlstyle.hxx:44
static void ApplyPatternForBiff2CellFormat(const XclImpRoot &rRoot, const ScAddress &rScPos, sal_uInt8 nFlags1, sal_uInt8 nFlags2, sal_uInt8 nFlags3)
Converts formatting information from BIFF2 cell record data directly.
Definition: xistyle.cxx:1426
const sal_uInt16 EXC_COLOR_BIFF2_BLACK
Definition: xlstyle.hxx:201
const sal_uInt16 EXC_FONTWGHT_BOLD
Definition: xlstyle.hxx:113
Contains all data of a cell style associated with an XF record.
Definition: xistyle.hxx:442
SvxCellJustifyMethod GetScVerJustifyMethod() const
Returns vertical justification method as Calc's attribute.
Definition: xlstyle.cxx:1596
bool mbHasAsian
true = Font contains Western script characters.
Definition: xistyle.hxx:137
void ReadXF4(XclImpStream &rStrm)
Definition: xistyle.cxx:1157
void setAttrEntries(SCTAB nTab, SCCOL nCol, Attrs &&rAttrs)
Set an array of cell attributes to specified column.
const ScPatternAttr * pPattern
Definition: attarray.hxx:83
XclImpPalette & GetPalette() const
Returns the color buffer.
Definition: xiroot.cxx:141
Contains the XF indexes for every used cell in a column.
Definition: xistyle.hxx:564
static Degree100 GetScRotation(sal_uInt16 nXclRot, Degree100 nRotForStacked)
Calculates an angle (in 1/100 of degrees) from an Excel angle value.
Definition: xltools.cxx:154
const sal_uInt16 EXC_FONT_NOTFOUND
Application font index.
Definition: xlstyle.hxx:77
void FillFromXF8(sal_uInt32 nBorder2, sal_uInt16 nArea)
Fills this struct with BIFF8 XF record data.
Definition: xistyle.cxx:1047
void SetXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index.
Definition: xistyle.cxx:1925
MS Excel 4.0.
Definition: xlconst.hxx:34
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:872
void SetColor(const Color &rColor)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
void FillToItemSet(SfxItemSet &rItemSet, const XclImpPalette &rPalette, bool bSkipPoolDefs=false) const
Inserts a box item representing this border style into the item set.
Definition: xistyle.cxx:980
void ReadStyle(XclImpStream &rStrm)
Reads a STYLE record.
Definition: xistyle.cxx:1477
ScStyleSheetPool & GetStyleSheetPool() const
Returns the style sheet pool of the Calc document.
Definition: xlroot.cxx:306
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
virtual ~XclImpXF() override
Definition: xistyle.cxx:1107
int nCount
const SCROW MAXROW
Definition: address.hxx:68
bool mbOutline
true = Struck out.
Definition: xlstyle.hxx:298
sal_uInt16 mnBackColor
Palette index to foreground color.
Definition: xlstyle.hxx:546
void SetHyperlink(const XclRange &rXclRange, const OUString &rUrl)
Inserts a range of hyperlink cells.
Definition: xistyle.cxx:1973
constexpr TypedWhichId< SvxJustifyMethodItem > ATTR_HOR_JUSTIFY_METHOD(130)
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1149
virtual SfxStyleSheetBase * First()
const sal_uInt8 EXC_XF_DIFF_ALIGN
Definition: xlstyle.hxx:153
SCTAB Tab() const
Definition: address.hxx:270
bool StartNextRecord()
Sets stream pointer to the start of the next record content.
Definition: xistream.cxx:456
const sal_uInt32 EXC_CF_AREA_FGCOLOR
Pattern modified?
Definition: xlcontent.hxx:76
void SetScWeight(FontWeight eScWeight)
Sets the Calc font weight.
Definition: xlstyle.cxx:341
sal_uInt8 mnDiagLine
Style of bottom line.
Definition: xlstyle.hxx:533
XclImpXFBuffer & GetXFBuffer() const
Returns the cell formatting attributes buffer.
Definition: xiroot.cxx:156
const editeng::SvxBorderLine * GetLine(SvxBoxItemLine nLine) const
sal_uInt16 mnRightColor
Palette index for left line.
Definition: xlstyle.hxx:525
sal_uInt16 mnForeColor
Definition: xlstyle.hxx:545
PITCH_VARIABLE
sal_uInt16 ReadCFFormat(XclImpStream &rStrm, bool bIFmt)
Read NumFmt from conditional format record.
Definition: xistyle.cxx:680
bool mbOutlineUsed
true = Strikeout used.
Definition: xistyle.hxx:147
sal_uInt16 mnTopColor
Palette index for right line.
Definition: xlstyle.hxx:526
bool mbItalic
Underline style.
Definition: xlstyle.hxx:296
XclImpXFBuffer(const XclImpXFBuffer &)=delete
make noncopyable
bool IsCellXF() const
Returns true, if this is a hard cell format.
Definition: xlstyle.hxx:579
const sal_uInt8 EXC_PATT_12_5_PERC
Definition: xlstyle.hxx:59
const XclFontData & GetFontData() const
Returns read-only access to font data.
Definition: xistyle.hxx:86
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
void SetColor(const Color &rCol)
const sal_uInt8 EXC_STYLEEXT_HIDDEN
Definition: xlstyle.hxx:244
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4745
bool mbFontUsed
true = cell protection used.
Definition: xlstyle.hxx:591
const XclImpFont * GetFont(sal_uInt16 nFontIndex) const
Returns the object that stores all contents of a FONT record.
Definition: xistyle.cxx:558
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
const sal_uInt8 EXC_XF2_LEFTLINE
Definition: xlstyle.hxx:180
bool mbAlignUsed
true = number format used.
Definition: xlstyle.hxx:593
sal_uInt8 mnVerAlign
Horizontal alignment.
Definition: xlstyle.hxx:490
Extends the XclCellAlign struct for import.
Definition: xistyle.hxx:264
bool empty() const
Definition: rangelst.hxx:88
const sal_uInt32 EXC_CF_FONT_STRIKEOUT
Font posture or weight modified?
Definition: xlcontent.hxx:89
#define SAL_N_ELEMENTS(arr)
sal_uInt16 mnLeftColor
Definition: xlstyle.hxx:524
::std::vector< Color > ColorVec
Definition: xistyle.hxx:62
bool mbHasCmplx
true = Font contains Asian script characters.
Definition: xistyle.hxx:138
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_TLBR(141)
void ReadXF(XclImpStream &rStrm)
Reads an XF record.
Definition: xistyle.cxx:1231
FontWeight GetScWeight() const
Returns the Calc font weight.
Definition: xlstyle.cxx:260
static SC_DLLPUBLIC void AddLanguage(SfxItemSet &rSet, const SvNumberFormatter &rFormatter)
Adds a language item to the item set, if the number format item contains a language that differs from...
Definition: global.cxx:955
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
XclFontItemType
Enumerates different types of Which-IDs for font items.
Definition: xlstyle.hxx:387
sal_uInt16 mnEscapem
Boldness: 400=normal, 700=bold.
Definition: xlstyle.hxx:292
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
const sal_uInt32 EXC_CF_FONT_STYLE
NumberFormat String or Id?
Definition: xlcontent.hxx:88
const sal_uInt8 EXC_XF_HOR_FILL
Definition: xlstyle.hxx:162
void FillToItemSet(SfxItemSet &rItemSet, const XclImpPalette &rPalette, bool bSkipPoolDefs=false) const
Inserts a brush item representing this area style into the item set.
Definition: xistyle.cxx:1076
constexpr TypedWhichId< SvxShadowedItem > ATTR_FONT_SHADOWED(108)
FontStrikeout GetScStrikeout() const
Returns the Calc strike-out style.
Definition: xlstyle.cxx:303
void FillFromCF8(sal_uInt16 nLineStyle, sal_uInt32 nLineColor, sal_uInt32 nFlags)
Fills this struct with BIFF8 CF (conditional format) record data.
Definition: xistyle.cxx:916
void SetBlankXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index for blank cells.
Definition: xistyle.cxx:1930
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35
const sal_uInt32 EXC_CF_BORDER_LEFT
Definition: xlcontent.hxx:70
IndexList maIndexList
Definition: xistyle.hxx:602
OUString maStyle
Font name.
Definition: xlstyle.hxx:288
sal_uInt8 mnUnderline
Windows character set.
Definition: xlstyle.hxx:295
static void PutItem(SfxItemSet &rItemSet, const SfxPoolItem &rItem, sal_uInt16 nWhichId, bool bSkipPoolDef)
Puts the item into the passed item set.
Definition: ftools.cxx:213
XclImpNumFmtBuffer(const XclImpRoot &rRoot)
Definition: xistyle.cxx:629
const sal_uInt16 EXC_FONTATTR_BOLD
Definition: xlstyle.hxx:97
bool mbUnderlUsed
true = Escapement type used.
Definition: xistyle.hxx:144
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CJK_FONT_HEIGHT(112)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const sal_uInt8 EXC_XF_DIFF_PROT
Definition: xlstyle.hxx:156
int i
void CreateUserStyles()
Creates all user defined style sheets.
Definition: xistyle.cxx:1612
XclImpStyleList maBuiltinStyles
List of contents of all XF record.
Definition: xistyle.hxx:517
const sal_uInt16 EXC_COLOR_WINDOWTEXT
System window background color (BIFF3-BIFF4).
Definition: xlstyle.hxx:207
void FillToItemSet(SfxItemSet &rItemSet, const XclImpFont *pFont, bool bSkipPoolDefs=false) const
Inserts items representing this alignment style into the item set.
Definition: xistyle.cxx:813
std::vector< ScAttrEntry > mvData
SvxCellJustifyMethod GetScHorJustifyMethod() const
Returns horizontal justification method as Calc's attribute.
Definition: xlstyle.cxx:1576
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:303
void FillFromXF2(sal_uInt8 nFlags)
Fills this struct with BIFF2 XF record data.
Definition: xistyle.cxx:1023
PITCH_FIXED
sal_uInt8 mnLevel
Identifier for builtin styles.
Definition: xistyle.hxx:466
void FillFromXF5(sal_uInt32 nArea)
Fills this struct with BIFF5/BIFF7 XF record data.
Definition: xistyle.cxx:1039
sal_Int16 SCCOL
Definition: types.hxx:21
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
XclImpPalette(const XclImpRoot &rRoot)
Definition: xistyle.cxx:146
void ReadXF3(XclImpStream &rStrm)
Definition: xistyle.cxx:1131
const sal_uInt32 EXC_XF_DIAGONAL_TL_TO_BR
Definition: xlstyle.hxx:189
Color GetDefColor(sal_uInt16 nXclIndex) const
Returns the default color for a (non-zero-based) Excel color or COL_AUTO on error.
Definition: xlstyle.cxx:142
void SetAllUsedFlags(bool bUsed)
Sets all font attributes to used or unused.
Definition: xistyle.cxx:208
XclImpXFIndex maXFIndex
The last row of an equal-formatted range.
Definition: xistyle.hxx:530
const sal_uInt8 EXC_XF2_VALFMT_MASK
Definition: xlstyle.hxx:177
void WriteFontProperties(ScfPropertySet &rPropSet, XclFontPropSetType eType, sal_uInt16 nFontIdx, const Color *pFontColor=nullptr) const
Writes all font properties to the passed property set.
Definition: xistyle.cxx:603
bool mbLocked
Definition: xlstyle.hxx:478
const SCCOL MAXCOL
Definition: address.hxx:69
void ReadFontData2(XclImpStream &rStrm)
Reads and sets height and flags.
Definition: xistyle.cxx:419
sal_uInt8 mnHorAlign
Definition: xlstyle.hxx:489
void FillScFmtToItemSet(SfxItemSet &rItemSet, sal_uInt32 nScNumFmt, bool bSkipPoolDefs=false) const
Fills a Calc number format to the passed item set.
Definition: xistyle.cxx:738
sal_uInt8 GetHorAlign() const
Definition: xistyle.hxx:390
const sal_uInt8 EXC_XF2_BACKGROUND
Definition: xlstyle.hxx:184
static Color GetPatternColor(const Color &rPattColor, const Color &rBackColor, sal_uInt16 nXclPattern)
Returns the best fitting color for an Excel pattern area format.
Definition: xltools.cxx:350
bool mbBackUsed
true = Foreground color used.
Definition: xistyle.hxx:327
const sal_uInt8 EXC_XF2_TOPLINE
Definition: xlstyle.hxx:182
const sal_uInt8 EXC_STYLEEXT_BUILTIN
Definition: xlstyle.hxx:243
const sal_uInt8 EXC_XF2_HIDDEN
Definition: xlstyle.hxx:179
size_t size() const
Definition: rangelst.hxx:89
const sal_uInt8 EXC_XF_DIFF_FONT
Definition: xlstyle.hxx:152
unsigned char sal_Bool
XclImpCellArea maArea
Border line style.
Definition: xistyle.hxx:436
static OUString GetBuiltInStyleName(sal_uInt8 nStyleId, std::u16string_view rName, sal_uInt8 nLevel)
Returns the specified built-in cell style name.
Definition: xltools.cxx:550
const sal_uInt8 EXC_XF_DIFF_AREA
Definition: xlstyle.hxx:155
bool get_flag(Type nBitField, Type nMask)
Returns true, if at least one of the bits set in nMask is set in nBitField.
Definition: ftools.hxx:75
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
const sal_uInt16 EXC_STYLE_BUILTIN
Definition: xlstyle.hxx:221
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
PITCH_DONTKNOW
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4817
MS Excel 3.0.
Definition: xlconst.hxx:33
SvNumFormatType
void SetUsedFlags(sal_uInt8 nUsedFlags)
Sets all "attribute used" flags according to the passed mask.
Definition: xistyle.cxx:1448
bool mbLineBreak
Indentation.
Definition: xlstyle.hxx:495
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
sal_uInt16 GetFontIndex() const
Definition: xistyle.hxx:391
const sal_uInt8 EXC_XF_HOR_CENTER_AS
Definition: xlstyle.hxx:164
void ReadFontData5(XclImpStream &rStrm)
Reads and sets height, flags, color, boldness, script, family and charset.
Definition: xistyle.cxx:434
const sal_uInt8 EXC_STYLE_NOLEVEL
Number of outline level styles.
Definition: xlstyle.hxx:237
SC_DLLPUBLIC const EditTextObject * GetEditText(const ScAddress &rPos) const
Definition: document.cxx:3642
void SetXF(SCROW nScRow, const XclImpXFIndex &rXFIndex)
Inserts a new (encoded) XF index (first try to expand the last range).
Definition: xistyle.cxx:1728
SVX_ROTATE_MODE_BOTTOM
const sal_uInt32 EXC_CF_BORDER_BOTTOM
Top border line modified?
Definition: xlcontent.hxx:73
bool mbFontNameUsed
true = Font contains Complex script characters.
Definition: xistyle.hxx:139
void SetRowDefXF(SCROW nScRow, sal_uInt16 nXFIndex)
Inserts a new XF index for all cells in a row.
Definition: xistyle.cxx:1940
void ReadEfont(XclImpStream &rStrm)
Reads an EFONT record (BIFF2 font color).
Definition: xistyle.cxx:589
bool mbBottomUsed
true = Top line style used.
Definition: xistyle.hxx:291
Contains all data of a XF record and a Calc item set.
Definition: xistyle.hxx:377
SC_DLLPUBLIC void DoMerge(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions=true)
Definition: documen3.cxx:2076
OutputDevice * GetPrinter() const
Returns pointer to the printer of the Calc document.
Definition: xlroot.cxx:301
sal_uInt8 mnPattern
Palette index to background color.
Definition: xlstyle.hxx:547
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CTL_FONT_HEIGHT(117)
FontPitch
void ReadXF8(XclImpStream &rStrm)
Definition: xistyle.cxx:1206
constexpr TypedWhichId< SvxFontItem > ATTR_CTL_FONT(116)
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
const sal_uInt8 EXC_FONTUNDERL_SINGLE
Definition: xlstyle.hxx:119
const sal_uInt16 EXC_BORDER_THIN
Definition: xlconst.hxx:250
void ReadFont(XclImpStream &rStrm)
Reads a FONT record for all BIFF versions.
Definition: xistyle.cxx:247
sal_uInt16 ReaduInt16()
Definition: xistream.cxx:649
ScRange & back()
Definition: rangelst.hxx:94
bool HasAnyOuterBorder() const
Returns true, if any of the outer border lines is visible.
Definition: xistyle.cxx:933
void ReadXF2(XclImpStream &rStrm)
Definition: xistyle.cxx:1111
void ReadPalette(XclImpStream &rStrm)
Reads a PALETTE record.
Definition: xistyle.cxx:167
const sal_uInt16 EXC_FONTWGHT_NORMAL
Definition: xlstyle.hxx:110
XclImpStyleList maUserStyles
List of built-in cell styles.
Definition: xistyle.hxx:518
const sal_uInt32 EXC_CF_FONT_UNDERL
Default flags.
Definition: xlcontent.hxx:92
sal_uInt8 mnLeftLine
Palette index for diagonal line(s).
Definition: xlstyle.hxx:529
XclImpCellBorder()
true = Diagonal line style used.
Definition: xistyle.cxx:849
void SetStyleSheet(ScStyleSheet *pNewStyle, bool bClearDirectFormat=true)
Definition: patattr.cxx:1169
const sal_uInt8 EXC_XF_DIFF_BORDER
Definition: xlstyle.hxx:154
SCCOL Col() const
Definition: address.hxx:266
XclImpCellArea()
true = Pattern used.
Definition: xistyle.cxx:1013
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:433
sal_uInt8 mnTextDir
Text orientation.
Definition: xlstyle.hxx:492
void FillFromXF3(sal_uInt16 nAlign)
Fills this struct with BIFF3 XF record data.
Definition: xistyle.cxx:770
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
std::vector< XclImpFont > maFontList
Definition: xistyle.hxx:195
const sal_uInt8 EXC_STYLE_NORMAL
Definition: xlstyle.hxx:224
void TryConcatPrev(sal_uLong nIndex)
Tries to concatenate a range with its predecessor.
Definition: xistyle.cxx:1866
void CreateUserStyle(const OUString &rFinalName)
Creates the Calc style sheet, if this is a user-defined style.
Definition: xistyle.cxx:1552
Color GetColor(sal_uInt16 nXclIndex) const
Returns the color for a (non-zero-based) Excel palette entry.
Definition: xistyle.cxx:156
sal_uInt16 mnParent
Definition: xlstyle.hxx:588
constexpr TypedWhichId< SvxFontItem > ATTR_CJK_FONT(111)
tools::Long const nBorder
XclImpXF * GetXF(sal_uInt16 nXFIndex)
Returns the object that stores all contents of an XF record.
Definition: xistyle.hxx:495
void FillToItemSet(SfxItemSet &rItemSet, sal_uInt16 nXclNumFmt, bool bSkipPoolDefs=false) const
Fills an Excel number format to the passed item set.
Definition: xistyle.cxx:730
const sal_uInt32 EXC_CF_BORDER_RIGHT
Left border line modified?
Definition: xlcontent.hxx:71
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
XclImpFont maFont4
Application font (for column width).
Definition: xistyle.hxx:197
void FillFromXF5(sal_uInt32 nBorder, sal_uInt32 nArea)
Fills this struct with BIFF5/BIFF7 XF record data.
Definition: xistyle.cxx:883
FontFamily
void ReadEfont(XclImpStream &rStrm)
Reads an EFONT record (BIFF2 font color).
Definition: xistyle.cxx:277
const sal_uInt16 EXC_FONTATTR_STRIKEOUT
Definition: xlstyle.hxx:100
void ReadFontName2(XclImpStream &rStrm)
Reads and sets a byte string as font name.
Definition: xistyle.cxx:460
constexpr TypedWhichId< SvxFrameDirectionItem > ATTR_WRITINGDIR(138)
std::size_t GetRecLeft()
Returns remaining data size of the whole record without record headers.
Definition: xistream.cxx:582
A wrapper for a UNO property set.
Definition: fapihelper.hxx:103
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual SfxStyleSheetBase * Next()
sal_Int32 SCROW
Definition: types.hxx:17
OUString ReadUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Reads ext.
Definition: xistream.cxx:891
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
sal_uInt8 mnBottomLine
Style of top line.
Definition: xlstyle.hxx:532
void ReadFormat(XclImpStream &rStrm)
Reads a FORMAT record.
Definition: xistyle.cxx:643
FontLineStyle GetScUnderline() const
Returns the Calc font underline style.
Definition: xlstyle.cxx:279
const sal_uInt16 EXC_XF_STYLE
Definition: xlstyle.hxx:146
OUString ReadByteString(bool b16BitLen)
Reads 8/16 bit string length, character array and returns the string.
Definition: xistream.cxx:959
constexpr TypedWhichId< SvxJustifyMethodItem > ATTR_VER_JUSTIFY_METHOD(133)
constexpr TypedWhichId< SvxPostureItem > ATTR_CTL_FONT_POSTURE(119)
void SetBoolXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index for boolean cells.
Definition: xistyle.cxx:1935
bool mbHasCharSet
All font attributes.
Definition: xistyle.hxx:135
ScPatternAttrPtr mpPattern
Definition: xistyle.hxx:430
const sal_uInt16 EXC_FONTATTR_OUTLINE
Definition: xlstyle.hxx:101
const sal_uInt16 EXC_FONTATTR_SHADOW
Definition: xlstyle.hxx:102
void WriteFontProperties(ScfPropertySet &rPropSet, XclFontPropSetType eType, const Color *pFontColor=nullptr) const
Writes all font properties to the passed property set.
Definition: xistyle.cxx:412
bool mbHasWstrn
true = Font contains own character set info.
Definition: xistyle.hxx:136
#define OSL_ENSURE_BIFF(c)
Definition: xltools.hxx:34
void ExportPalette()
Definition: xistyle.cxx:123
void SetScPosture(FontItalic eScPosture)
Sets the Calc font posture.
Definition: xlstyle.cxx:336
const sal_uInt8 EXC_PATT_SOLID
Definition: xlstyle.hxx:55
void ReadFont(XclImpStream &rStrm)
Reads a FONT record.
Definition: xistyle.cxx:577
void UpdateAppFont(const XclFontData &rFontData, bool bHasCharSet)
Updates the application default font.
Definition: xistyle.cxx:615
void FillFromXF5(sal_uInt16 nAlign)
Fills this struct with BIFF5/BIFF7 XF record data.
Definition: xistyle.cxx:783
void ReadXF5(XclImpStream &rStrm)
Definition: xistyle.cxx:1183
const sal_uInt16 EXC_COLOR_BIFF2_WHITE
Definition: xlstyle.hxx:202
IndexList::iterator begin()
Definition: xistyle.hxx:575
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
void FillFromCF8(sal_uInt16 nPattern, sal_uInt16 nColor, sal_uInt32 nFlags)
Fills this struct with BIFF8 CF (conditional format) record data.
Definition: xistyle.cxx:1055
#define PUTITEM(item, sc_which, ee_which)
void InitializeImport()
Clears all buffered data, used to set up for a new sheet.
Definition: xlstyle.cxx:1465
const sal_uInt8 EXC_LINE_NONE
Definition: xlstyle.hxx:37
SvxFrameDirection GetScFrameDir() const
Returns the Calc frame direction.
Definition: xlstyle.cxx:1601
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
Definition: xistream.cxx:798
unsigned char sal_uInt8
const sal_uInt8 EXC_XF2_LOCKED
Definition: xlstyle.hxx:178
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
bool mbStrikeUsed
true = Italic used.
Definition: xistyle.hxx:146
void SetFont(const vcl::Font &rNewFont)
sal_uInt8 ReaduInt8()
Definition: xistream.cxx:617
sal_uInt8 mnFamily
Escapement type.
Definition: xlstyle.hxx:293
void SetColumnDefXF(SCCOL nScCol, sal_uInt16 nXFIndex)
Inserts a new XF index for all cells in a column.
Definition: xistyle.cxx:1946
XclImpCellAlign maAlignment
Cell protection flags.
Definition: xistyle.hxx:434
bool mbHeightUsed
true = Font name, family, charset used.
Definition: xistyle.hxx:140
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits nMask=SfxStyleSearchBits::All) override
Definition: stlpool.cxx:72
bool HasUsedFlags() const
Returns true, if any "attribute used" flags are ste in this XF.
Definition: xlstyle.cxx:1732
FAMILY_SWISS
bool mbColorUsed
true = Font height used.
Definition: xistyle.hxx:141
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
XclImpFontBuffer & GetFontBuffer() const
Returns the font buffer.
Definition: xiroot.cxx:146
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxPostureItem > ATTR_CJK_FONT_POSTURE(114)
SvxBoxItemLine
sal_uInt16 mnWeight
Font height in twips (1/20 of a point).
Definition: xlstyle.hxx:291
bool mbRightUsed
true = Left line style used.
Definition: xistyle.hxx:289
virtual SC_DLLPUBLIC SfxItemSet & GetItemSet() override
Definition: stlsheet.cxx:128
const sal_uInt8 EXC_XF2_BOTTOMLINE
Definition: xlstyle.hxx:183
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
void SetUsedFlags(bool bUsed)
Sets colors and pattern state to used or unused.
Definition: xistyle.cxx:1018
sal_uInt16 GetFontIndex(sal_uInt16 nXFIndex) const
Returns the index to the Excel font used in the specified XF record.
Definition: xistyle.cxx:1590
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:151
void FillFromXF2(sal_uInt8 nNumFmt)
Fills this struct with BIFF2 XF record data.
Definition: xistyle.cxx:748
sal_uInt8 mnIndent
Text rotation angle.
Definition: xlstyle.hxx:494
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
Definition: document.cxx:6082
const sal_uInt8 EXC_FONTUNDERL_NONE
Definition: xlstyle.hxx:118
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:141
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
bool mbHidden
true = Locked against editing.
Definition: xlstyle.hxx:479
Cell with a single Boolean value.
Definition: xistyle.hxx:645
FontFamily GetScFamily(rtl_TextEncoding eDefTextEnc) const
Returns the Calc font family.
Definition: xlstyle.cxx:229
const sal_uInt32 EXC_XF_DIAGONAL_BL_TO_TR
Top-left to bottom-right.
Definition: xlstyle.hxx:190
const sal_uInt16 EXC_COLOR_WINDOWBACK
System window text color (>=BIFF5).
Definition: xlstyle.hxx:208
bool mbProtUsed
true = cell XF, false = style XF.
Definition: xlstyle.hxx:590
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6092
bool mbEscapemUsed
true = Weight used.
Definition: xistyle.hxx:143
bool mbBuiltin
Level for builtin column/row styles.
Definition: xistyle.hxx:467
bool mbTopUsed
true = Right line style used.
Definition: xistyle.hxx:290
Stores the default colors for the current BIFF version and the contents of a PALETTE record...
Definition: xistyle.hxx:44
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
const sal_uInt8 EXC_PATT_NONE
Definition: xlstyle.hxx:54
const sal_uInt8 EXC_XF_VER_DISTRIB
Definition: xlstyle.hxx:171
XclImpIndexMap maIndexMap
Definition: xistyle.hxx:242
#define SAL_WARN(area, stream)
XclImpFont maCtrlFont
Built-in font with index 4.
Definition: xistyle.hxx:198
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
Color maColor
String with styles (bold, italic).
Definition: xlstyle.hxx:289
::std::vector< Color > ColorVec
Definition: xistyle.cxx:85
sal_uInt8 mnRotation
CTL text direction.
Definition: xlstyle.hxx:493
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:290
const sal_uInt16 EXC_XF8_SHRINK
Definition: xlstyle.hxx:186
OUString maFinalName
True = style not visible in GUI.
Definition: xistyle.hxx:471
MS Excel 2.1.
Definition: xlconst.hxx:32
sal_uInt16 GetXFIndex() const
Definition: xistyle.hxx:362
void SetFontData(const XclFontData &rFontData, bool bHasCharSet)
Sets the passed font data and all used flags to 'used'.
Definition: xistyle.cxx:214
void ApplyPatternToAttrVector(::std::vector< ScAttrEntry > &rAttrs, SCROW nRow1, SCROW nRow2, sal_uInt32 nForceScNumFmt)
Definition: xistyle.cxx:1338
This class is used to import record oriented streams.
Definition: xistream.hxx:277
const sal_uInt8 EXC_STYLEEXT_CUSTOM
Definition: xlstyle.hxx:245
const sal_uInt16 EXC_XF_HIDDEN
Definition: xlstyle.hxx:145
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:1564
void WriteFontProperties(ScfPropertySet &rPropSet, XclFontPropSetType eType, const XclFontData &rFontData, bool bHasWstrn, bool bHasAsian, bool bHasCmplx, const Color *pFontColor)
Writes all font properties to the passed property set, uses passed color as font color.
Definition: xlstyle.cxx:693
XclImpColRowSettings * pColRowBuff
Definition: root.hxx:52
XclImpStyle(const XclImpRoot &rRoot)
Definition: xistyle.cxx:1465
bool mbBorderUsed
true = alignment used.
Definition: xlstyle.hxx:594
XclImpStyleMap maStylesByXf
List of user defined cell styles.
Definition: xistyle.hxx:519
void InsertFormat(sal_uInt16 nXclNumFmt, const OUString &rFormat)
Inserts a new number format for the specified Excel format index.
Definition: xlstyle.cxx:1470
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:1887
bool mbStrikeout
true = Italic.
Definition: xlstyle.hxx:297
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
bool Contains(SCROW nScRow) const
Returns true, if nScRow is contained in own row range.
Definition: xistyle.hxx:558
Access to global data from other classes.
Definition: xiroot.hxx:125
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
sal_uInt32 ReaduInt32()
Definition: xistream.cxx:685
SCROW nEndRow
Definition: attarray.hxx:82
struct _ADOIndex Index
static rtl_TextEncoding GetSystemTextEncoding()
Returns system text encoding for byte string conversion.
Definition: ftools.cxx:115
constexpr TypedWhichId< SvxWeightItem > ATTR_CJK_FONT_WEIGHT(113)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:546
Contains base members for XF record import/export.
Definition: xlstyle.hxx:562
void Insert(XclImpXFRange *pXFRange, sal_uLong nIndex)
Insert a range into the list at the specified index.
Definition: xistyle.cxx:1794
ScStyleSheet * mpStyleSheet
Final name used in the Calc document.
Definition: xistyle.hxx:472
void FillFromXF4(sal_uInt16 nAlign)
Fills this struct with BIFF4 XF record data.
Definition: xistyle.cxx:776
void FillFromXF3(sal_uInt16 nProt)
Fills this struct with BIFF3-BIFF8 XF record data.
Definition: xistyle.cxx:754
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_BLTR(142)
constexpr TypedWhichId< SvxContourItem > ATTR_FONT_CONTOUR(107)
XclImpXFInsertMode
Insertion mode of an XF index.
Definition: xistyle.hxx:641
SvxCellHorJustify GetScHorAlign() const
Returns the Calc horizontal alignment.
Definition: xlstyle.cxx:1558
void RemoveAll()
Definition: rangelst.cxx:1113
const OUString * GetStyleName() const
Definition: patattr.cxx:1164
All text objects in charts.
Definition: xlstyle.hxx:398
SC_DLLPUBLIC void GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab, CellType &rCellType) const
Definition: document.cxx:3778
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
Definition: xistyle.cxx:84
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:58
void TraceDates(sal_uInt16 nNumFmt)
Definition: xltracer.cxx:67
const sal_uInt8 EXC_XF2_RIGHTLINE
Definition: xlstyle.hxx:181
sal_Int16 SCTAB
Definition: types.hxx:22
constexpr TypedWhichId< SvxMarginItem > ATTR_MARGIN(143)
void WriteDefaultCtrlFontProperties(ScfPropertySet &rPropSet) const
Writes default font properties for form controls to the passed property set.
Definition: xistyle.cxx:610
OUString maName
Definition: xlstyle.hxx:287
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
bool mbShadowUsed
true = Outlined used.
Definition: xistyle.hxx:148
void SetBorderLine(const ScRange &rRange, SCTAB nScTab, SvxBoxItemLine nLine)
Copies border of the last cell of the range to the first cell to keep it visible when the range is me...
Definition: xistyle.cxx:1957
ScDocument & getDoc()
std::vector< std::shared_ptr< XclImpXFRangeColumn > > maColumns
Definition: xistyle.hxx:663
const sal_uInt16 EXC_BORDER_MEDIUM
Definition: xlconst.hxx:249