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