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