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