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