LibreOffice Module sc (master) 1
xestyle.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 <utility>
22#include <xestyle.hxx>
23
24#include <algorithm>
25#include <iterator>
26#include <com/sun/star/i18n/ScriptType.hpp>
28#include <rtl/tencinfo.h>
29#include <vcl/font.hxx>
31#include <scitems.hxx>
33#include <editeng/boxitem.hxx>
34#include <editeng/lineitem.hxx>
35#include <editeng/brushitem.hxx>
37#include <editeng/fontitem.hxx>
39#include <editeng/langitem.hxx>
40#include <document.hxx>
41#include <stlpool.hxx>
42#include <stlsheet.hxx>
43#include <patattr.hxx>
44#include <attrib.hxx>
45#include <globstr.hrc>
46#include <scresid.hxx>
47#include <xestring.hxx>
48#include <xltools.hxx>
49#include <conditio.hxx>
50#include <dbdata.hxx>
51#include <filterentries.hxx>
52
53#include <o3tl/safeint.hxx>
54#include <oox/export/utils.hxx>
56#include <oox/token/tokens.hxx>
57#include <oox/token/namespaces.hxx>
59#include <svl/numformat.hxx>
60
61using namespace ::com::sun::star;
62using namespace oox;
63
64// PALETTE record - color information =========================================
65
66namespace {
67
68sal_uInt32 lclGetWeighting( XclExpColorType eType )
69{
70 switch( eType )
71 {
72 case EXC_COLOR_CHARTLINE: return 1;
74 case EXC_COLOR_CHARTAREA: return 2;
77 case EXC_COLOR_CTRLTEXT: return 10;
78 case EXC_COLOR_TABBG:
79 case EXC_COLOR_CELLAREA: return 20;
80 case EXC_COLOR_GRID: return 50;
81 default: OSL_FAIL( "lclGetWeighting - unknown color type" );
82 }
83 return 1;
84}
85
86sal_Int32 lclGetColorDistance( const Color& rColor1, const Color& rColor2 )
87{
88 sal_Int32 nDist = rColor1.GetRed() - rColor2.GetRed();
89 nDist *= nDist * 77;
90 sal_Int32 nDummy = rColor1.GetGreen() - rColor2.GetGreen();
91 nDist += nDummy * nDummy * 151;
92 nDummy = rColor1.GetBlue() - rColor2.GetBlue();
93 nDist += nDummy * nDummy * 28;
94 return nDist;
95}
96
97sal_uInt8 lclGetMergedColorComp( sal_uInt8 nComp1, sal_uInt32 nWeight1, sal_uInt8 nComp2, sal_uInt32 nWeight2 )
98{
99 sal_uInt8 nComp1Dist = ::std::min< sal_uInt8 >( nComp1, 0xFF - nComp1 );
100 sal_uInt8 nComp2Dist = ::std::min< sal_uInt8 >( nComp2, 0xFF - nComp2 );
101 if( nComp1Dist != nComp2Dist )
102 {
103 /* #i36945# One of the passed RGB components is nearer at the limits (0x00 or 0xFF).
104 Increase its weighting to prevent fading of the colors during reduction. */
105 const sal_uInt8& rnCompNearer = (nComp1Dist < nComp2Dist) ? nComp1 : nComp2;
106 sal_uInt32& rnWeight = (nComp1Dist < nComp2Dist) ? nWeight1 : nWeight2;
107 rnWeight *= ((rnCompNearer - 0x80L) * (rnCompNearer - 0x7FL) / 0x1000L + 1);
108 }
109 sal_uInt32 nWSum = nWeight1 + nWeight2;
110 return static_cast< sal_uInt8 >( (nComp1 * nWeight1 + nComp2 * nWeight2 + nWSum / 2) / nWSum );
111}
112
113void lclSetMixedColor( Color& rDest, const Color& rSrc1, const Color& rSrc2 )
114{
115 rDest.SetRed( static_cast< sal_uInt8 >( (static_cast< sal_uInt16 >( rSrc1.GetRed() ) + rSrc2.GetRed()) / 2 ) );
116 rDest.SetGreen( static_cast< sal_uInt8 >( (static_cast< sal_uInt16 >( rSrc1.GetGreen() ) + rSrc2.GetGreen()) / 2 ) );
117 rDest.SetBlue( static_cast< sal_uInt8 >( (static_cast< sal_uInt16 >( rSrc1.GetBlue() ) + rSrc2.GetBlue()) / 2 ) );
118}
119
120} // namespace
121
122// additional classes for color reduction -------------------------------------
123
124namespace {
125
132class XclListColor
133{
134private:
135 Color maColor;
136 sal_uInt32 mnColorId;
137 sal_uInt32 mnWeight;
138 bool mbBaseColor;
139
140public:
141 explicit XclListColor( const Color& rColor, sal_uInt32 nColorId );
142
144 const Color& GetColor() const { return maColor; }
146 sal_uInt32 GetColorId() const { return mnColorId; }
148 sal_uInt32 GetWeighting() const { return mnWeight; }
150 bool IsBaseColor() const { return mbBaseColor; }
151
153 void AddWeighting( sal_uInt32 nWeight ) { mnWeight += nWeight; }
155 void Merge( const XclListColor& rColor );
156};
157
158XclListColor::XclListColor( const Color& rColor, sal_uInt32 nColorId ) :
159 maColor( rColor ),
160 mnColorId( nColorId ),
161 mnWeight( 0 )
162{
163 mbBaseColor =
164 ((rColor.GetRed() == 0x00) || (rColor.GetRed() == 0xFF)) &&
165 ((rColor.GetGreen() == 0x00) || (rColor.GetGreen() == 0xFF)) &&
166 ((rColor.GetBlue() == 0x00) || (rColor.GetBlue() == 0xFF));
167}
168
169void XclListColor::Merge( const XclListColor& rColor )
170{
171 sal_uInt32 nWeight2 = rColor.GetWeighting();
172 // do not change RGB value of base colors
173 if( !mbBaseColor )
174 {
175 maColor.SetRed( lclGetMergedColorComp( maColor.GetRed(), mnWeight, rColor.maColor.GetRed(), nWeight2 ) );
176 maColor.SetGreen( lclGetMergedColorComp( maColor.GetGreen(), mnWeight, rColor.maColor.GetGreen(), nWeight2 ) );
177 maColor.SetBlue( lclGetMergedColorComp( maColor.GetBlue(), mnWeight, rColor.maColor.GetBlue(), nWeight2 ) );
178 }
179 AddWeighting( nWeight2 );
180}
181
183struct XclColorIdData
184{
185 Color maColor;
186 sal_uInt32 mnIndex;
188 void Set( const Color& rColor, sal_uInt32 nIndex ) { maColor = rColor; mnIndex = nIndex; }
189};
190
192struct XclPaletteColor
193{
194 Color maColor;
195 bool mbUsed;
196
197 explicit XclPaletteColor( const Color& rColor ) : maColor( rColor ), mbUsed( false ) {}
198 void SetColor( const Color& rColor ) { maColor = rColor; mbUsed = true; }
199};
200
203struct XclRemap
204{
205 sal_uInt32 mnPalIndex;
206 bool mbProcessed;
207
208 explicit XclRemap() : mnPalIndex( 0 ), mbProcessed( false ) {}
209 void SetIndex( sal_uInt32 nPalIndex )
210 { mnPalIndex = nPalIndex; mbProcessed = true; }
211};
212
214struct XclNearest
215{
216 sal_uInt32 mnPalIndex;
217 sal_Int32 mnDist;
218
219 explicit XclNearest() : mnPalIndex( 0 ), mnDist( 0 ) {}
220};
221
222} // namespace
223
225{
226public:
227 explicit XclExpPaletteImpl( const XclDefaultPalette& rDefPal );
228
232 sal_uInt32 InsertColor( const Color& rColor, XclExpColorType eType, sal_uInt16 nAutoDefault = 0 );
234 static sal_uInt32 GetColorIdFromIndex( sal_uInt16 nIndex );
235
237 void Finalize();
238
240 sal_uInt16 GetColorIndex( sal_uInt32 nColorId ) const;
241
246 void GetMixedColors(
247 sal_uInt16& rnXclForeIx, sal_uInt16& rnXclBackIx, sal_uInt8& rnXclPattern,
248 sal_uInt32 nForeColorId, sal_uInt32 nBackColorId ) const;
249
252 Color GetColor( sal_uInt16 nXclIndex ) const;
253
255 bool IsDefaultPalette() const;
259
260private:
262 static sal_uInt16 GetXclIndex( sal_uInt32 nIndex )
263 { return static_cast< sal_uInt16 >( nIndex + EXC_COLOR_USEROFFSET ); }
264
266 const Color& GetOriginalColor( sal_uInt32 nColorId ) const;
267
269 XclListColor* SearchListEntry( const Color& rColor, sal_uInt32& rnIndex );
271 XclListColor* CreateListEntry( const Color& rColor, sal_uInt32 nIndex );
272
274 void RawReducePalette( sal_uInt32 nPass );
277
279 sal_uInt32 GetLeastUsedListColor() const;
283 sal_uInt32 GetNearestListColor( const Color& rColor, sal_uInt32 nIgnore ) const;
285 sal_uInt32 GetNearestListColor( sal_uInt32 nIndex ) const;
286
290 sal_Int32 GetNearestPaletteColor(
291 sal_uInt32& rnIndex,
292 const Color& rColor ) const;
295 sal_Int32 GetNearPaletteColors(
296 sal_uInt32& rnFirst, sal_uInt32& rnSecond,
297 const Color& rColor ) const;
298
299private:
300 typedef std::vector< std::unique_ptr<XclListColor> > XclListColorList;
301 typedef std::shared_ptr< XclListColorList > XclListColorListRef;
302
305 std::vector< XclColorIdData >
307 std::vector< XclPaletteColor >
309 sal_uInt32 mnLastIdx;
310};
311
312const sal_uInt32 EXC_PAL_INDEXBASE = 0xFFFF0000;
313const sal_uInt32 EXC_PAL_MAXRAWSIZE = 1024;
314
316 mrDefPal( rDefPal ),
317 mxColorList( std::make_shared<XclListColorList>() ),
318 mnLastIdx( 0 )
319{
320 // initialize maPalette with default colors
321 sal_uInt16 nCount = static_cast< sal_uInt16 >( mrDefPal.GetColorCount() );
322 maPalette.reserve( nCount );
323 for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx )
324 maPalette.emplace_back( mrDefPal.GetDefColor( GetXclIndex( nIdx ) ) );
325
327}
328
329sal_uInt32 XclExpPaletteImpl::InsertColor( const Color& rColor, XclExpColorType eType, sal_uInt16 nAutoDefault )
330{
331 if( rColor == COL_AUTO )
332 return GetColorIdFromIndex( nAutoDefault );
333
334 sal_uInt32 nFoundIdx = 0;
335 XclListColor* pEntry = SearchListEntry( rColor, nFoundIdx );
336 if( !pEntry || (pEntry->GetColor() != rColor) )
337 pEntry = CreateListEntry( rColor, nFoundIdx );
338 pEntry->AddWeighting( lclGetWeighting( eType ) );
339
340 return pEntry->GetColorId();
341}
342
343sal_uInt32 XclExpPaletteImpl::GetColorIdFromIndex( sal_uInt16 nIndex )
344{
345 return EXC_PAL_INDEXBASE | nIndex;
346}
347
349{
350// --- build initial color ID data vector (maColorIdDataVec) ---
351
352 sal_uInt32 nCount = mxColorList->size();
353 maColorIdDataVec.resize( nCount );
354 for( sal_uInt32 nIdx = 0; nIdx < nCount; ++nIdx )
355 {
356 const XclListColor& listColor = *mxColorList->at( nIdx );
357 maColorIdDataVec[ listColor.GetColorId() ].Set( listColor.GetColor(), nIdx );
358 }
359
360// --- loop as long as current color count does not fit into palette of current BIFF ---
361
362 // phase 1: raw reduction (performance reasons, #i36945#)
363 sal_uInt32 nPass = 0;
364 while( mxColorList->size() > EXC_PAL_MAXRAWSIZE )
365 RawReducePalette( nPass++ );
366
367 // phase 2: precise reduction using advanced color merging based on color weighting
368 while( mxColorList->size() > mrDefPal.GetColorCount() )
370
371// --- use default palette and replace colors with nearest used colors ---
372
373 nCount = mxColorList->size();
374 std::vector< XclRemap > aRemapVec( nCount );
375 std::vector< XclNearest > aNearestVec( nCount );
376
377 // in each run: search the best fitting color and replace a default color with it
378 for( sal_uInt32 nRun = 0; nRun < nCount; ++nRun )
379 {
380 sal_uInt32 nIndex;
381 // find nearest unused default color for each unprocessed list color
382 for( nIndex = 0; nIndex < nCount; ++nIndex )
383 aNearestVec[ nIndex ].mnDist = aRemapVec[ nIndex ].mbProcessed ? SAL_MAX_INT32 :
384 GetNearestPaletteColor( aNearestVec[ nIndex ].mnPalIndex, mxColorList->at( nIndex )->GetColor() );
385 // find the list color which is nearest to a default color
386 sal_uInt32 nFound = 0;
387 for( nIndex = 1; nIndex < nCount; ++nIndex )
388 if( aNearestVec[ nIndex ].mnDist < aNearestVec[ nFound ].mnDist )
389 nFound = nIndex;
390 // replace default color with list color
391 sal_uInt32 nNearest = aNearestVec[ nFound ].mnPalIndex;
392 OSL_ENSURE( nNearest < maPalette.size(), "XclExpPaletteImpl::Finalize - algorithm error" );
393 maPalette[ nNearest ].SetColor( mxColorList->at( nFound )->GetColor() );
394 aRemapVec[ nFound ].SetIndex( nNearest );
395 }
396
397 // remap color ID data map (maColorIdDataVec) from list indexes to palette indexes
398 for( auto& rColorIdData : maColorIdDataVec )
399 rColorIdData.mnIndex = aRemapVec[ rColorIdData.mnIndex ].mnPalIndex;
400}
401
402sal_uInt16 XclExpPaletteImpl::GetColorIndex( sal_uInt32 nColorId ) const
403{
404 sal_uInt16 nRet = 0;
405 if( nColorId >= EXC_PAL_INDEXBASE )
406 nRet = static_cast< sal_uInt16 >( nColorId & ~EXC_PAL_INDEXBASE );
407 else if( nColorId < maColorIdDataVec.size() )
408 nRet = GetXclIndex( maColorIdDataVec[ nColorId ].mnIndex );
409 return nRet;
410}
411
413 sal_uInt16& rnXclForeIx, sal_uInt16& rnXclBackIx, sal_uInt8& rnXclPattern,
414 sal_uInt32 nForeColorId, sal_uInt32 nBackColorId ) const
415{
416 rnXclForeIx = GetColorIndex( nForeColorId );
417 rnXclBackIx = GetColorIndex( nBackColorId );
418 if( (rnXclPattern != EXC_PATT_SOLID) || (nForeColorId >= maColorIdDataVec.size()) )
419 return;
420
421 // now we have solid pattern, and a defined foreground (background doesn't care for solid pattern)
422
423 sal_uInt32 nIndex1, nIndex2;
424 Color aForeColor( GetOriginalColor( nForeColorId ) );
425 sal_Int32 nFirstDist = GetNearPaletteColors( nIndex1, nIndex2, aForeColor );
426 if( (nIndex1 >= maPalette.size()) || (nIndex2 >= maPalette.size()) )
427 return;
428
429 Color aColorArr[ 5 ];
430 aColorArr[ 0 ] = maPalette[ nIndex1 ].maColor;
431 aColorArr[ 4 ] = maPalette[ nIndex2 ].maColor;
432 lclSetMixedColor( aColorArr[ 2 ], aColorArr[ 0 ], aColorArr[ 4 ] );
433 lclSetMixedColor( aColorArr[ 1 ], aColorArr[ 0 ], aColorArr[ 2 ] );
434 lclSetMixedColor( aColorArr[ 3 ], aColorArr[ 2 ], aColorArr[ 4 ] );
435
436 sal_Int32 nMinDist = nFirstDist;
437 sal_uInt32 nMinIndex = 0;
438 for( sal_uInt32 nCnt = 1; nCnt < 4; ++nCnt )
439 {
440 sal_Int32 nDist = lclGetColorDistance( aForeColor, aColorArr[ nCnt ] );
441 if( nDist < nMinDist )
442 {
443 nMinDist = nDist;
444 nMinIndex = nCnt;
445 }
446 }
447 rnXclForeIx = GetXclIndex( nIndex1 );
448 rnXclBackIx = GetXclIndex( nIndex2 );
449 if( nMinDist < nFirstDist )
450 {
451 switch( nMinIndex )
452 {
453 case 1: rnXclPattern = EXC_PATT_75_PERC; break;
454 case 2: rnXclPattern = EXC_PATT_50_PERC; break;
455 case 3: rnXclPattern = EXC_PATT_25_PERC; break;
456 }
457 }
458}
459
460Color XclExpPaletteImpl::GetColor( sal_uInt16 nXclIndex ) const
461{
462 if( nXclIndex >= EXC_COLOR_USEROFFSET )
463 {
464 sal_uInt32 nIdx = nXclIndex - EXC_COLOR_USEROFFSET;
465 if( nIdx < maPalette.size() )
466 return maPalette[ nIdx ].maColor;
467 }
468 return mrDefPal.GetDefColor( nXclIndex );
469}
470
472{
473 bool bDefault = true;
474 for( sal_uInt32 nIdx = 0, nSize = static_cast< sal_uInt32 >( maPalette.size() ); bDefault && (nIdx < nSize); ++nIdx )
475 bDefault = maPalette[ nIdx ].maColor == mrDefPal.GetDefColor( GetXclIndex( nIdx ) );
476 return bDefault;
477}
478
480{
481 rStrm << static_cast< sal_uInt16 >( maPalette.size() );
482 for( const auto& rColor : maPalette )
483 rStrm << rColor.maColor;
484}
485
487{
488 if( maPalette.empty() )
489 return;
490
491 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
492 rStyleSheet->startElement(XML_colors);
493 rStyleSheet->startElement(XML_indexedColors);
494 for( const auto& rColor : maPalette )
495 rStyleSheet->singleElement(XML_rgbColor, XML_rgb, XclXmlUtils::ToOString(rColor.maColor));
496 rStyleSheet->endElement( XML_indexedColors );
497 rStyleSheet->endElement( XML_colors );
498}
499
500const Color& XclExpPaletteImpl::GetOriginalColor( sal_uInt32 nColorId ) const
501{
502 if( nColorId < maColorIdDataVec.size() )
503 return maColorIdDataVec[ nColorId ].maColor;
504 return maPalette[ 0 ].maColor;
505}
506
507XclListColor* XclExpPaletteImpl::SearchListEntry( const Color& rColor, sal_uInt32& rnIndex )
508{
509 rnIndex = 0;
510
511 if (mxColorList->empty())
512 return nullptr;
513
514 XclListColor* pEntry = nullptr;
515
516 // search optimization for equal-colored objects occurring repeatedly
517 if (mnLastIdx < mxColorList->size())
518 {
519 pEntry = (*mxColorList)[mnLastIdx].get();
520 if( pEntry->GetColor() == rColor )
521 {
522 rnIndex = mnLastIdx;
523 return pEntry;
524 }
525 }
526
527 // binary search for color
528 sal_uInt32 nBegIdx = 0;
529 sal_uInt32 nEndIdx = mxColorList->size();
530 bool bFound = false;
531 while( !bFound && (nBegIdx < nEndIdx) )
532 {
533 rnIndex = (nBegIdx + nEndIdx) / 2;
534 pEntry = (*mxColorList)[rnIndex].get();
535 bFound = pEntry->GetColor() == rColor;
536 if( !bFound )
537 {
538 if( pEntry->GetColor() < rColor )
539 nBegIdx = rnIndex + 1;
540 else
541 nEndIdx = rnIndex;
542 }
543 }
544
545 // not found - use end of range as new insertion position
546 if( !bFound )
547 rnIndex = nEndIdx;
548
549 mnLastIdx = rnIndex;
550 return pEntry;
551}
552
553XclListColor* XclExpPaletteImpl::CreateListEntry( const Color& rColor, sal_uInt32 nIndex )
554{
555 XclListColor* pEntry = new XclListColor( rColor, mxColorList->size() );
556 mxColorList->insert(mxColorList->begin() + nIndex, std::unique_ptr<XclListColor>(pEntry));
557 return pEntry;
558}
559
561{
562 /* Fast palette reduction - in each call of this function one RGB component
563 of each color is reduced to a lower number of distinct values.
564 Pass 0: Blue is reduced to 128 distinct values.
565 Pass 1: Red is reduced to 128 distinct values.
566 Pass 2: Green is reduced to 128 distinct values.
567 Pass 3: Blue is reduced to 64 distinct values.
568 Pass 4: Red is reduced to 64 distinct values.
569 Pass 5: Green is reduced to 64 distinct values.
570 And so on...
571 */
572
574 mxColorList = std::make_shared<XclListColorList>();
575
576 // maps old list indexes to new list indexes, used to update maColorIdDataVec
577 ScfUInt32Vec aListIndexMap;
578 aListIndexMap.reserve( xOldList->size() );
579
580 // preparations
581 sal_uInt8 nR, nG, nB;
582 sal_uInt8& rnComp = ((nPass % 3 == 0) ? nB : ((nPass % 3 == 1) ? nR : nG));
583 nPass /= 3;
584 OSL_ENSURE( nPass < 7, "XclExpPaletteImpl::RawReducePalette - reduction not terminated" );
585
586 static const sal_uInt8 spnFactor2[] = { 0x81, 0x82, 0x84, 0x88, 0x92, 0xAA, 0xFF };
587 sal_uInt8 nFactor1 = static_cast< sal_uInt8 >( 0x02 << nPass );
588 sal_uInt8 nFactor2 = spnFactor2[ nPass ];
589 sal_uInt8 nFactor3 = static_cast< sal_uInt8 >( 0x40 >> nPass );
590
591 // process each color in the old color list
592 for(const std::unique_ptr<XclListColor> & pOldColor : *xOldList)
593 {
594 // get the old list entry
595 const XclListColor* pOldEntry = pOldColor.get();
596 nR = pOldEntry->GetColor().GetRed();
597 nG = pOldEntry->GetColor().GetGreen();
598 nB = pOldEntry->GetColor().GetBlue();
599
600 /* Calculate the new RGB component (rnComp points to one of nR, nG, nB).
601 Using integer arithmetic with its rounding errors, the results of
602 this calculation are always exactly in the range 0x00 to 0xFF
603 (simply cutting the lower bits would darken the colors slightly). */
604 sal_uInt32 nNewComp = rnComp;
605 nNewComp /= nFactor1;
606 nNewComp *= nFactor2;
607 nNewComp /= nFactor3;
608 rnComp = static_cast< sal_uInt8 >( nNewComp );
609 Color aNewColor( nR, nG, nB );
610
611 // find or insert the new color
612 sal_uInt32 nFoundIdx = 0;
613 XclListColor* pNewEntry = SearchListEntry( aNewColor, nFoundIdx );
614 if( !pNewEntry || (pNewEntry->GetColor() != aNewColor) )
615 pNewEntry = CreateListEntry( aNewColor, nFoundIdx );
616 pNewEntry->AddWeighting( pOldEntry->GetWeighting() );
617 aListIndexMap.push_back( nFoundIdx );
618 }
619
620 // update color ID data map (maps color IDs to color list indexes), replace old by new list indexes
621 for( auto& rColorIdData : maColorIdDataVec )
622 rColorIdData.mnIndex = aListIndexMap[ rColorIdData.mnIndex ];
623}
624
626{
627 // find a list color to remove
628 sal_uInt32 nRemove = GetLeastUsedListColor();
629 // find its nearest neighbor
630 sal_uInt32 nKeep = GetNearestListColor( nRemove );
631
632 // merge both colors to one color, remove one color from list
633 XclListColor* pKeepEntry = mxColorList->at(nKeep).get();
634 XclListColor* pRemoveEntry = mxColorList->at(nRemove).get();
635 if( !(pKeepEntry && pRemoveEntry) )
636 return;
637
638 // merge both colors (if pKeepEntry is a base color, it will not change)
639 pKeepEntry->Merge( *pRemoveEntry );
640 // remove the less used color, adjust nKeep index if kept color follows removed color
641 XclListColorList::iterator itr = mxColorList->begin();
642 ::std::advance(itr, nRemove);
643 mxColorList->erase(itr);
644 if( nKeep > nRemove ) --nKeep;
645
646 // recalculate color ID data map (maps color IDs to color list indexes)
647 for( auto& rColorIdData : maColorIdDataVec )
648 {
649 if( rColorIdData.mnIndex > nRemove )
650 --rColorIdData.mnIndex;
651 else if( rColorIdData.mnIndex == nRemove )
652 rColorIdData.mnIndex = nKeep;
653 }
654}
655
657{
658 sal_uInt32 nFound = 0;
659 sal_uInt32 nMinW = SAL_MAX_UINT32;
660
661 for( sal_uInt32 nIdx = 0, nCount = mxColorList->size(); nIdx < nCount; ++nIdx )
662 {
663 XclListColor& rEntry = *mxColorList->at( nIdx );
664 // ignore the base colors
665 if( !rEntry.IsBaseColor() && (rEntry.GetWeighting() < nMinW) )
666 {
667 nFound = nIdx;
668 nMinW = rEntry.GetWeighting();
669 }
670 }
671 return nFound;
672}
673
674sal_uInt32 XclExpPaletteImpl::GetNearestListColor( const Color& rColor, sal_uInt32 nIgnore ) const
675{
676 sal_uInt32 nFound = 0;
677 sal_Int32 nMinD = SAL_MAX_INT32;
678
679 for( sal_uInt32 nIdx = 0, nCount = mxColorList->size(); nIdx < nCount; ++nIdx )
680 {
681 if( nIdx != nIgnore )
682 {
683 if( XclListColor* pEntry = mxColorList->at(nIdx).get() )
684 {
685 sal_Int32 nDist = lclGetColorDistance( rColor, pEntry->GetColor() );
686 if( nDist < nMinD )
687 {
688 nFound = nIdx;
689 nMinD = nDist;
690 }
691 }
692 }
693 }
694 return nFound;
695}
696
697sal_uInt32 XclExpPaletteImpl::GetNearestListColor( sal_uInt32 nIndex ) const
698{
699 if (nIndex >= mxColorList->size())
700 return 0;
701 XclListColor* pEntry = mxColorList->at(nIndex).get();
702 return GetNearestListColor( pEntry->GetColor(), nIndex );
703}
704
706 sal_uInt32& rnIndex, const Color& rColor ) const
707{
708 rnIndex = 0;
709 sal_Int32 nDist = SAL_MAX_INT32;
710
711 sal_uInt32 nPaletteIndex = 0;
712 for( const auto& rPaletteColor : maPalette )
713 {
714 if( !rPaletteColor.mbUsed )
715 {
716 sal_Int32 nCurrDist = lclGetColorDistance( rColor, rPaletteColor.maColor );
717 if( nCurrDist < nDist )
718 {
719 rnIndex = nPaletteIndex;
720 nDist = nCurrDist;
721 }
722 }
723 ++nPaletteIndex;
724 }
725 return nDist;
726}
727
729 sal_uInt32& rnFirst, sal_uInt32& rnSecond, const Color& rColor ) const
730{
731 rnFirst = rnSecond = 0;
732 sal_Int32 nDist1 = SAL_MAX_INT32;
733 sal_Int32 nDist2 = SAL_MAX_INT32;
734
735 sal_uInt32 nPaletteIndex = 0;
736 for( const auto& rPaletteColor : maPalette )
737 {
738 sal_Int32 nCurrDist = lclGetColorDistance( rColor, rPaletteColor.maColor );
739 if( nCurrDist < nDist1 )
740 {
741 rnSecond = rnFirst;
742 nDist2 = nDist1;
743 rnFirst = nPaletteIndex;
744 nDist1 = nCurrDist;
745 }
746 else if( nCurrDist < nDist2 )
747 {
748 rnSecond = nPaletteIndex;
749 nDist2 = nCurrDist;
750 }
751 ++nPaletteIndex;
752 }
753 return nDist1;
754}
755
757 XclDefaultPalette( rRoot ),
759{
760 mxImpl = std::make_shared<XclExpPaletteImpl>( *this );
761 SetRecSize( GetColorCount() * 4 + 2 );
762}
763
765{
766}
767
768sal_uInt32 XclExpPalette::InsertColor( const Color& rColor, XclExpColorType eType, sal_uInt16 nAutoDefault )
769{
770 return mxImpl->InsertColor( rColor, eType, nAutoDefault );
771}
772
773sal_uInt32 XclExpPalette::GetColorIdFromIndex( sal_uInt16 nIndex )
774{
776}
777
779{
780 mxImpl->Finalize();
781}
782
783sal_uInt16 XclExpPalette::GetColorIndex( sal_uInt32 nColorId ) const
784{
785 return mxImpl->GetColorIndex( nColorId );
786}
787
789 sal_uInt16& rnXclForeIx, sal_uInt16& rnXclBackIx, sal_uInt8& rnXclPattern,
790 sal_uInt32 nForeColorId, sal_uInt32 nBackColorId ) const
791{
792 return mxImpl->GetMixedColors( rnXclForeIx, rnXclBackIx, rnXclPattern, nForeColorId, nBackColorId );
793}
794
795Color XclExpPalette::GetColor( sal_uInt16 nXclIndex ) const
796{
797 return mxImpl->GetColor( nXclIndex );
798}
799
801{
802 if( !mxImpl->IsDefaultPalette() )
804}
805
807{
808 if( !mxImpl->IsDefaultPalette() )
809 mxImpl->SaveXml( rStrm );
810}
811
813{
814 mxImpl->WriteBody( rStrm );
815}
816
817// FONT record - font information =============================================
818
819namespace {
820
821typedef ::std::pair< sal_uInt16, sal_Int16 > WhichAndScript;
822
823sal_Int16 lclCheckFontItems( const SfxItemSet& rItemSet,
824 const WhichAndScript& rWAS1, const WhichAndScript& rWAS2, const WhichAndScript& rWAS3 )
825{
826 if( ScfTools::CheckItem( rItemSet, rWAS1.first, false ) ) return rWAS1.second;
827 if( ScfTools::CheckItem( rItemSet, rWAS2.first, false ) ) return rWAS2.second;
828 if( ScfTools::CheckItem( rItemSet, rWAS3.first, false ) ) return rWAS3.second;
829 return 0;
830};
831
832} // namespace
833
834sal_Int16 XclExpFontHelper::GetFirstUsedScript( const XclExpRoot& rRoot, const SfxItemSet& rItemSet )
835{
836 namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
837
838 /* #i17050# #i107170# We need to determine which font items are set in the
839 item set, and which script type we should prefer according to the
840 current language settings. */
841
842 static const WhichAndScript WAS_LATIN( ATTR_FONT, css::i18n::ScriptType::LATIN );
843 static const WhichAndScript WAS_ASIAN( ATTR_CJK_FONT, css::i18n::ScriptType::ASIAN );
844 static const WhichAndScript WAS_CMPLX( ATTR_CTL_FONT, css::i18n::ScriptType::COMPLEX );
845
846 /* do not let a font from a parent style override an explicit
847 cell font. */
848
849 sal_Int16 nDefScript = rRoot.GetDefApiScript();
850 sal_Int16 nScript = 0;
851 const SfxItemSet* pCurrSet = &rItemSet;
852
853 while( (nScript == 0) && pCurrSet )
854 {
855 switch( nDefScript )
856 {
857 case ApiScriptType::LATIN:
858 nScript = lclCheckFontItems( *pCurrSet, WAS_LATIN, WAS_CMPLX, WAS_ASIAN );
859 break;
860 case ApiScriptType::ASIAN:
861 nScript = lclCheckFontItems( *pCurrSet, WAS_ASIAN, WAS_CMPLX, WAS_LATIN );
862 break;
863 case ApiScriptType::COMPLEX:
864 nScript = lclCheckFontItems( *pCurrSet, WAS_CMPLX, WAS_ASIAN, WAS_LATIN );
865 break;
866 default:
867 OSL_FAIL( "XclExpFontHelper::GetFirstUsedScript - unknown script type" );
868 nScript = ApiScriptType::LATIN;
869 };
870 pCurrSet = pCurrSet->GetParent();
871 }
872
873 if (nScript == 0)
874 nScript = nDefScript;
875
876 if (nScript == 0)
877 {
878 OSL_FAIL( "XclExpFontHelper::GetFirstUsedScript - unknown script type" );
879 nScript = ApiScriptType::LATIN;
880 }
881
882 return nScript;
883}
884
885vcl::Font XclExpFontHelper::GetFontFromItemSet( const XclExpRoot& rRoot, const SfxItemSet& rItemSet, sal_Int16 nScript )
886{
887 // if WEAK is passed, guess script type from existing items in the item set
888 if( nScript == css::i18n::ScriptType::WEAK )
889 nScript = GetFirstUsedScript( rRoot, rItemSet );
890
891 // convert to core script type constants
893
894 // fill the font object
895 vcl::Font aFont;
896 ScPatternAttr::fillFontOnly(aFont, rItemSet, nullptr, nullptr, nullptr, nScScript);
897 return aFont;
898}
899
901{
902 sal_Int16 nScript = GetFirstUsedScript(rRoot, rItemSet);
903
904 // convert to core script type constants
906 return ScPatternAttr::GetDxfFont(rItemSet, nScScript);
907}
908
909bool XclExpFontHelper::CheckItems( const XclExpRoot& rRoot, const SfxItemSet& rItemSet, sal_Int16 nScript, bool bDeep )
910{
911 static const sal_uInt16 pnCommonIds[] = {
914 static const sal_uInt16 pnLatinIds[] = {
916 static const sal_uInt16 pnAsianIds[] = {
918 static const sal_uInt16 pnComplexIds[] = {
920
921 bool bUsed = ScfTools::CheckItems( rItemSet, pnCommonIds, bDeep );
922 if( !bUsed )
923 {
924 namespace ApiScriptType = css::i18n::ScriptType;
925 // if WEAK is passed, guess script type from existing items in the item set
926 if( nScript == ApiScriptType::WEAK )
927 nScript = GetFirstUsedScript( rRoot, rItemSet );
928 // check the correct items
929 switch( nScript )
930 {
931 case ApiScriptType::LATIN: bUsed = ScfTools::CheckItems( rItemSet, pnLatinIds, bDeep ); break;
932 case ApiScriptType::ASIAN: bUsed = ScfTools::CheckItems( rItemSet, pnAsianIds, bDeep ); break;
933 case ApiScriptType::COMPLEX: bUsed = ScfTools::CheckItems( rItemSet, pnComplexIds, bDeep ); break;
934 default: OSL_FAIL( "XclExpFontHelper::CheckItems - unknown script type" );
935 }
936 }
937 return bUsed;
938}
939
940namespace {
941
942std::size_t lclCalcHash( const XclFontData& rFontData )
943{
944 std::size_t seed = 0;
945 o3tl::hash_combine(seed, rFontData.maName);
946 o3tl::hash_combine(seed, rFontData.maComplexColor);
947 o3tl::hash_combine(seed, rFontData.mnWeight);
948 o3tl::hash_combine(seed, rFontData.mnCharSet);
949 o3tl::hash_combine(seed, rFontData.mnFamily);
950 o3tl::hash_combine(seed, rFontData.mnHeight);
951 o3tl::hash_combine(seed, rFontData.mnUnderline);
952 o3tl::hash_combine(seed, rFontData.mnEscapem);
953 o3tl::hash_combine(seed, rFontData.mbItalic);
954 o3tl::hash_combine(seed, rFontData.mbStrikeout);
955 o3tl::hash_combine(seed, rFontData.mbOutline);
956 o3tl::hash_combine(seed, rFontData.mbShadow);
957 return seed;
958}
959
960} // namespace
961
963 const XclFontData& rFontData, XclExpColorType eColorType ) :
965 XclExpRoot( rRoot ),
966 maData( rFontData )
967{
968 // insert font color into palette
970 // hash value for faster comparison
971 mnHash = lclCalcHash( maData );
972 // record size
973 sal_Int32 nStrLen = maData.maName.getLength();
974 SetRecSize( ((GetBiff() == EXC_BIFF8) ? (nStrLen * 2 + 1) : nStrLen) + 15 );
975}
976
977bool XclExpFont::Equals( const XclFontData& rFontData, sal_uInt32 nHash ) const
978{
979 return (mnHash == nHash) && (maData == rFontData);
980}
981
983{
984 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
985 rStyleSheet->startElement(XML_font);
986 XclXmlUtils::WriteFontData( rStyleSheet, maData, XML_name );
987 // OOXTODO: XML_scheme; //scheme/@val values: "major", "minor", "none"
988 rStyleSheet->endElement( XML_font );
989}
990
991// private --------------------------------------------------------------------
992
994{
995 sal_uInt16 nAttr = EXC_FONTATTR_NONE;
997 if( maData.mnUnderline > 0 )
998 ::set_flag( nAttr, EXC_FONTATTR_UNDERLINE, true );
1002
1003 OSL_ENSURE( maData.maName.getLength() < 256, "XclExpFont::WriteBody - font name too long" );
1004 XclExpString aFontName;
1005 if( GetBiff() <= EXC_BIFF5 )
1007 else
1009
1011 << nAttr
1013 << maData.mnWeight
1014 << maData.mnEscapem
1016 << maData.mnFamily
1017 << maData.mnCharSet
1018 << sal_uInt8( 0 )
1019 << aFontName;
1020}
1021
1023 const SfxItemSet& rItemSet):
1024 XclExpRoot(rRoot)
1025{
1027}
1028
1029namespace {
1030
1031const char* getUnderlineOOXValue(FontLineStyle eUnderline)
1032{
1033 switch (eUnderline)
1034 {
1035 case LINESTYLE_NONE:
1036 case LINESTYLE_DONTKNOW:
1037 return "none";
1038 case LINESTYLE_DOUBLE:
1040 return "double";
1041 default:
1042 return "single";
1043 }
1044}
1045
1046const char* getFontFamilyOOXValue(FontFamily eValue)
1047{
1048 switch (eValue)
1049 {
1050 case FAMILY_DONTKNOW:
1051 return "0";
1052 case FAMILY_SWISS:
1053 case FAMILY_SYSTEM:
1054 return "2";
1055 case FAMILY_ROMAN:
1056 return "1";
1057 case FAMILY_SCRIPT:
1058 return "4";
1059 case FAMILY_MODERN:
1060 return "3";
1061 case FAMILY_DECORATIVE:
1062 return "5";
1063 default:
1064 return "0";
1065 }
1066}
1067
1068}
1069
1071{
1072 if (maDxfData.isEmpty())
1073 return;
1074
1075 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
1076 rStyleSheet->startElement(XML_font);
1077
1078 if (maDxfData.pFontAttr)
1079 {
1080 OUString aFontName = (*maDxfData.pFontAttr)->GetFamilyName();
1081
1082 aFontName = XclTools::GetXclFontName(aFontName);
1083 if (!aFontName.isEmpty())
1084 {
1085 rStyleSheet->singleElement(XML_name, XML_val, aFontName);
1086 }
1087
1088 rtl_TextEncoding eTextEnc = (*maDxfData.pFontAttr)->GetCharSet();
1089 sal_uInt8 nExcelCharSet = rtl_getBestWindowsCharsetFromTextEncoding(eTextEnc);
1090 if (nExcelCharSet)
1091 {
1092 rStyleSheet->singleElement(XML_charset, XML_val, OString::number(nExcelCharSet));
1093 }
1094
1095 FontFamily eFamily = (*maDxfData.pFontAttr)->GetFamily();
1096 const char* pVal = getFontFamilyOOXValue(eFamily);
1097 if (pVal)
1098 {
1099 rStyleSheet->singleElement(XML_family, XML_val, pVal);
1100 }
1101 }
1102
1103 if (maDxfData.eWeight)
1104 {
1105 rStyleSheet->singleElement(XML_b,
1106 XML_val, ToPsz10(*maDxfData.eWeight != WEIGHT_NORMAL));
1107 }
1108
1109 if (maDxfData.eItalic)
1110 {
1111 bool bItalic = (*maDxfData.eItalic == ITALIC_OBLIQUE) || (*maDxfData.eItalic == ITALIC_NORMAL);
1112 rStyleSheet->singleElement(XML_i, XML_val, ToPsz10(bItalic));
1113 }
1114
1115 if (maDxfData.eStrike)
1116 {
1117 bool bStrikeout =
1121
1122 rStyleSheet->singleElement(XML_strike, XML_val, ToPsz10(bStrikeout));
1123 }
1124
1125 if (maDxfData.bOutline)
1126 {
1127 rStyleSheet->singleElement(XML_outline, XML_val, ToPsz10(*maDxfData.bOutline));
1128 }
1129
1130 if (maDxfData.bShadow)
1131 {
1132 rStyleSheet->singleElement(XML_shadow, XML_val, ToPsz10(*maDxfData.bShadow));
1133 }
1134
1135 if (maDxfData.aColor)
1136 {
1137 rStyleSheet->singleElement(XML_color,
1139 }
1140
1142 {
1143 rStyleSheet->singleElement(XML_sz,
1144 XML_val, OString::number(*maDxfData.nFontHeight/20));
1145 }
1146
1147 if (maDxfData.eUnder)
1148 {
1149 const char* pVal = getUnderlineOOXValue(*maDxfData.eUnder);
1150 rStyleSheet->singleElement(XML_u, XML_val, pVal);
1151 }
1152
1153 rStyleSheet->endElement(XML_font);
1154}
1155
1158{
1159}
1160
1161bool XclExpBlindFont::Equals( const XclFontData& /*rFontData*/, sal_uInt32 /*nHash*/ ) const
1162{
1163 return false;
1164}
1165
1167{
1168 // do nothing
1169}
1170
1172 XclExpRoot( rRoot ),
1173 mnXclMaxSize( 0 )
1174{
1175 switch( GetBiff() )
1176 {
1180 default: DBG_ERROR_BIFF();
1181 }
1183}
1184
1185const XclExpFont* XclExpFontBuffer::GetFont( sal_uInt16 nXclFont ) const
1186{
1187 return maFontList.GetRecord( nXclFont );
1188}
1189
1191{
1192 return maFontList.GetRecord( EXC_FONT_APP )->GetFontData(); // exists always
1193}
1194
1196 const XclFontData& rFontData, XclExpColorType eColorType, bool bAppFont )
1197{
1198 if( bAppFont )
1199 {
1200 XclExpFontRef xFont = new XclExpFont( GetRoot(), rFontData, eColorType );
1202 // set width of '0' character for column width export
1203 SetCharWidth( xFont->GetFontData() );
1204 return EXC_FONT_APP;
1205 }
1206
1207 size_t nPos = Find( rFontData );
1209 {
1210 // not found in buffer - create new font
1211 size_t nSize = maFontList.GetSize();
1212 if( nSize < mnXclMaxSize )
1213 {
1214 // possible to insert
1215 maFontList.AppendNewRecord( new XclExpFont( GetRoot(), rFontData, eColorType ) );
1216 nPos = nSize; // old size is last position now
1217 }
1218 else
1219 {
1220 // buffer is full - ignore new font, use default font
1222 }
1223 }
1224 return static_cast< sal_uInt16 >( nPos );
1225}
1226
1227sal_uInt16 XclExpFontBuffer::Insert(const SvxFont& rFont, model::ComplexColor const& rComplexColor, XclExpColorType eColorType )
1228{
1229 return Insert(XclFontData(rFont, rComplexColor), eColorType);
1230}
1231
1232sal_uInt16 XclExpFontBuffer::Insert(const SfxItemSet& rItemSet, sal_Int16 nScript, XclExpColorType eColorType, bool bAppFont )
1233{
1234 // #i17050# script type now provided by caller
1235 vcl::Font aFont = XclExpFontHelper::GetFontFromItemSet(GetRoot(), rItemSet, nScript);
1236 model::ComplexColor aComplexColor;
1237 ScPatternAttr::fillColor(aComplexColor, rItemSet, ScAutoFontColorMode::Raw);
1238 return Insert(XclFontData(aFont, aComplexColor), eColorType, bAppFont );
1239}
1240
1242{
1244}
1245
1247{
1248 if( maFontList.IsEmpty() )
1249 return;
1250
1251 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
1252 rStyleSheet->startElement(XML_fonts, XML_count, OString::number(maFontList.GetSize()));
1253
1255
1256 rStyleSheet->endElement( XML_fonts );
1257}
1258
1259// private --------------------------------------------------------------------
1260
1262{
1263 XclFontData aFontData;
1264 aFontData.maName = "Arial";
1265 aFontData.SetScFamily( FAMILY_DONTKNOW );
1267 aFontData.SetScHeight( 200 ); // 200 twips = 10 pt
1268 aFontData.SetScWeight( WEIGHT_NORMAL );
1269
1270 switch( GetBiff() )
1271 {
1272 case EXC_BIFF5:
1273 {
1275 aFontData.SetScWeight( WEIGHT_BOLD );
1277 aFontData.SetScWeight( WEIGHT_NORMAL );
1278 aFontData.SetScPosture( ITALIC_NORMAL );
1280 aFontData.SetScWeight( WEIGHT_BOLD );
1282 // the blind font with index 4
1284 // already add the first user defined font (Excel does it too)
1285 aFontData.SetScWeight( WEIGHT_NORMAL );
1286 aFontData.SetScPosture( ITALIC_NONE );
1288 }
1289 break;
1290 case EXC_BIFF8:
1291 {
1292 XclExpFontRef xFont = new XclExpFont( GetRoot(), aFontData, EXC_COLOR_CELLTEXT );
1293 maFontList.AppendRecord( xFont );
1294 maFontList.AppendRecord( xFont );
1295 maFontList.AppendRecord( xFont );
1296 maFontList.AppendRecord( xFont );
1297 if( GetOutput() == EXC_OUTPUT_BINARY )
1298 // the blind font with index 4
1300 }
1301 break;
1302 default:
1304 }
1305}
1306
1307size_t XclExpFontBuffer::Find( const XclFontData& rFontData )
1308{
1309 sal_uInt32 nHash = lclCalcHash( rFontData );
1310 for( size_t nPos = 0, nSize = maFontList.GetSize(); nPos < nSize; ++nPos )
1311 if( maFontList.GetRecord( nPos )->Equals( rFontData, nHash ) )
1312 return nPos;
1313 return EXC_FONTLIST_NOTFOUND;
1314}
1315
1316// FORMAT record - number formats =============================================
1317
1318namespace {
1319
1321struct XclExpNumFmtPred
1322{
1323 sal_uInt32 mnScNumFmt;
1324 explicit XclExpNumFmtPred( sal_uInt32 nScNumFmt ) : mnScNumFmt( nScNumFmt ) {}
1325 bool operator()( const XclExpNumFmt& rFormat ) const
1326 { return rFormat.mnScNumFmt == mnScNumFmt; }
1327};
1328
1329}
1330
1332{
1333 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
1334 rStyleSheet->singleElement( XML_numFmt,
1335 XML_numFmtId, OString::number(mnXclNumFmt),
1336 XML_formatCode, maNumFmtString );
1337}
1338
1340 XclExpRoot( rRoot ),
1342 mpKeywordTable( new NfKeywordTable ),
1343 mnStdFmt( GetFormatter().GetStandardIndex( ScGlobal::eLnge ) )
1344{
1345 switch( GetBiff() )
1346 {
1349 default: mnXclOffset = 0; DBG_ERROR_BIFF();
1350 }
1351
1352 mxFormatter->FillKeywordTableForExcel( *mpKeywordTable );
1353}
1354
1356{
1357}
1358
1359sal_uInt16 XclExpNumFmtBuffer::Insert( sal_uInt32 nScNumFmt )
1360{
1361 XclExpNumFmtVec::const_iterator aIt =
1362 ::std::find_if( maFormatMap.begin(), maFormatMap.end(), XclExpNumFmtPred( nScNumFmt ) );
1363 if( aIt != maFormatMap.end() )
1364 return aIt->mnXclNumFmt;
1365
1366 size_t nSize = maFormatMap.size();
1367 if( nSize < o3tl::make_unsigned( 0xFFFF - mnXclOffset ) )
1368 {
1369 sal_uInt16 nXclNumFmt = static_cast< sal_uInt16 >( nSize + mnXclOffset );
1370 maFormatMap.emplace_back( nScNumFmt, nXclNumFmt, GetFormatCode( nScNumFmt ) );
1371 return nXclNumFmt;
1372 }
1373
1374 return 0;
1375}
1376
1378{
1379 for( const auto& rEntry : maFormatMap )
1380 WriteFormatRecord( rStrm, rEntry );
1381}
1382
1384{
1385 if( maFormatMap.empty() )
1386 return;
1387
1388 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
1389 rStyleSheet->startElement(XML_numFmts, XML_count, OString::number(maFormatMap.size()));
1390 for( auto& rEntry : maFormatMap )
1391 {
1392 rEntry.SaveXml( rStrm );
1393 }
1394 rStyleSheet->endElement( XML_numFmts );
1395}
1396
1397void XclExpNumFmtBuffer::WriteFormatRecord( XclExpStream& rStrm, sal_uInt16 nXclNumFmt, const OUString& rFormatStr )
1398{
1399 XclExpString aExpStr;
1400 if( GetBiff() <= EXC_BIFF5 )
1401 aExpStr.AssignByte( rFormatStr, GetTextEncoding(), XclStrFlags::EightBitLength );
1402 else
1403 aExpStr.Assign( rFormatStr );
1404
1405 rStrm.StartRecord( EXC_ID4_FORMAT, 2 + aExpStr.GetSize() );
1406 rStrm << nXclNumFmt << aExpStr;
1407 rStrm.EndRecord();
1408}
1409
1411{
1413}
1414
1415namespace {
1416
1417OUString GetNumberFormatCode(const XclRoot& rRoot, const sal_uInt32 nScNumFmt, SvNumberFormatter* pFormatter, const NfKeywordTable* pKeywordTable)
1418{
1419 return rRoot.GetFormatter().GetFormatStringForExcel( nScNumFmt, *pKeywordTable, *pFormatter);
1420}
1421
1422}
1423
1424OUString XclExpNumFmtBuffer::GetFormatCode( sal_uInt32 nScNumFmt )
1425{
1426 return GetNumberFormatCode( *this, nScNumFmt, mxFormatter.get(), mpKeywordTable.get() );
1427}
1428
1429// XF, STYLE record - Cell formatting =========================================
1430
1431bool XclExpCellProt::FillFromItemSet( const SfxItemSet& rItemSet, bool bStyle )
1432{
1433 const ScProtectionAttr& rProtItem = rItemSet.Get( ATTR_PROTECTION );
1434 mbLocked = rProtItem.GetProtection();
1435 mbHidden = rProtItem.GetHideFormula() || rProtItem.GetHideCell();
1436 return ScfTools::CheckItem( rItemSet, ATTR_PROTECTION, bStyle );
1437}
1438
1439void XclExpCellProt::FillToXF3( sal_uInt16& rnProt ) const
1440{
1441 ::set_flag( rnProt, EXC_XF_LOCKED, mbLocked );
1442 ::set_flag( rnProt, EXC_XF_HIDDEN, mbHidden );
1443}
1444
1446{
1447 rStrm.GetCurrentStream()->singleElement( XML_protection,
1448 XML_locked, ToPsz( mbLocked ),
1449 XML_hidden, ToPsz( mbHidden ) );
1450}
1451
1452bool XclExpCellAlign::FillFromItemSet(const XclRoot& rRoot, const SfxItemSet& rItemSet,
1453 bool bForceLineBreak, XclBiff eBiff, bool bStyle)
1454{
1455 bool bUsed = false;
1456 SvxCellHorJustify eHorAlign = rItemSet.Get( ATTR_HOR_JUSTIFY ).GetValue();
1457 SvxCellVerJustify eVerAlign = rItemSet.Get( ATTR_VER_JUSTIFY ).GetValue();
1458
1459 switch( eBiff )
1460 {
1461 case EXC_BIFF8: // attributes new in BIFF8
1462 {
1463 // text indent
1464 tools::Long nTmpIndent = rItemSet.Get( ATTR_INDENT ).GetValue(); // already in twips
1465 tools::Long nSpaceWidth = rRoot.GetSpaceWidth();
1466 sal_Int32 nIndent = static_cast<double>(nTmpIndent) / (3.0 * nSpaceWidth) + 0.5;
1467 mnIndent = limit_cast< sal_uInt8 >( nIndent, 0, 15 );
1468 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_INDENT, bStyle );
1469
1470 // shrink to fit
1471 mbShrink = rItemSet.Get( ATTR_SHRINKTOFIT ).GetValue();
1472 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_SHRINKTOFIT, bStyle );
1473
1474 // CTL text direction
1475 SetScFrameDir( rItemSet.Get( ATTR_WRITINGDIR ).GetValue() );
1476 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_WRITINGDIR, bStyle );
1477
1478 [[fallthrough]];
1479 }
1480
1481 case EXC_BIFF5: // attributes new in BIFF5
1482 case EXC_BIFF4: // attributes new in BIFF4
1483 {
1484 // vertical alignment
1485 SetScVerAlign( eVerAlign );
1486 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_VER_JUSTIFY, bStyle );
1487
1488 // stacked/rotation
1489 bool bStacked = rItemSet.Get( ATTR_STACKED ).GetValue();
1490 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_STACKED, bStyle );
1491 if( bStacked )
1492 {
1494 }
1495 else
1496 {
1497 // rotation
1498 Degree100 nScRot = rItemSet.Get( ATTR_ROTATE_VALUE ).GetValue();
1500 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_ROTATE_VALUE, bStyle );
1501 }
1503
1504 [[fallthrough]];
1505 }
1506
1507 case EXC_BIFF3: // attributes new in BIFF3
1508 {
1509 // text wrap
1510 mbLineBreak = bForceLineBreak || rItemSet.Get( ATTR_LINEBREAK ).GetValue();
1511 bUsed |= bForceLineBreak || ScfTools::CheckItem( rItemSet, ATTR_LINEBREAK, bStyle );
1512
1513 [[fallthrough]];
1514 }
1515
1516 case EXC_BIFF2: // attributes new in BIFF2
1517 {
1518 // horizontal alignment
1519 SetScHorAlign( eHorAlign );
1520 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_HOR_JUSTIFY, bStyle );
1521 }
1522
1523 break;
1524 default: DBG_ERROR_BIFF();
1525 }
1526
1527 if (eBiff == EXC_BIFF8)
1528 {
1529 // Adjust for distributed alignments.
1530 if (eHorAlign == SvxCellHorJustify::Block)
1531 {
1532 SvxCellJustifyMethod eHorJustMethod =
1534 if (eHorJustMethod == SvxCellJustifyMethod::Distribute)
1536 }
1537
1538 if (eVerAlign == SvxCellVerJustify::Block)
1539 {
1540 SvxCellJustifyMethod eVerJustMethod =
1542 if (eVerJustMethod == SvxCellJustifyMethod::Distribute)
1544 }
1545 }
1546
1547 return bUsed;
1548}
1549
1550void XclExpCellAlign::FillToXF5( sal_uInt16& rnAlign ) const
1551{
1552 ::insert_value( rnAlign, mnHorAlign, 0, 3 );
1554 ::insert_value( rnAlign, mnVerAlign, 4, 3 );
1555 ::insert_value( rnAlign, mnOrient, 8, 2 );
1556}
1557
1558void XclExpCellAlign::FillToXF8( sal_uInt16& rnAlign, sal_uInt16& rnMiscAttrib ) const
1559{
1560 ::insert_value( rnAlign, mnHorAlign, 0, 3 );
1562 ::insert_value( rnAlign, mnVerAlign, 4, 3 );
1563 ::insert_value( rnAlign, mnRotation, 8, 8 );
1564 ::insert_value( rnMiscAttrib, mnIndent, 0, 4 );
1565 ::set_flag( rnMiscAttrib, EXC_XF8_SHRINK, mbShrink );
1566 ::insert_value( rnMiscAttrib, mnTextDir, 6, 2 );
1567}
1568
1569static const char* ToHorizontalAlignment( sal_uInt8 nHorAlign )
1570{
1571 switch( nHorAlign )
1572 {
1573 case EXC_XF_HOR_GENERAL: return "general";
1574 case EXC_XF_HOR_LEFT: return "left";
1575 case EXC_XF_HOR_CENTER: return "center";
1576 case EXC_XF_HOR_RIGHT: return "right";
1577 case EXC_XF_HOR_FILL: return "fill";
1578 case EXC_XF_HOR_JUSTIFY: return "justify";
1579 case EXC_XF_HOR_CENTER_AS: return "centerContinuous";
1580 case EXC_XF_HOR_DISTRIB: return "distributed";
1581 }
1582 return "*unknown*";
1583}
1584
1585static const char* ToVerticalAlignment( sal_uInt8 nVerAlign )
1586{
1587 switch( nVerAlign )
1588 {
1589 case EXC_XF_VER_TOP: return "top";
1590 case EXC_XF_VER_CENTER: return "center";
1591 case EXC_XF_VER_BOTTOM: return "bottom";
1592 case EXC_XF_VER_JUSTIFY: return "justify";
1593 case EXC_XF_VER_DISTRIB: return "distributed";
1594 }
1595 return "*unknown*";
1596}
1597
1599{
1600 rStrm.GetCurrentStream()->singleElement( XML_alignment,
1601 XML_horizontal, ToHorizontalAlignment( mnHorAlign ),
1602 XML_vertical, ToVerticalAlignment( mnVerAlign ),
1603 XML_textRotation, OString::number(mnRotation),
1604 XML_wrapText, ToPsz( mbLineBreak ),
1605 XML_indent, OString::number(mnIndent),
1606 // OOXTODO: XML_relativeIndent, mnIndent?
1607 // OOXTODO: XML_justifyLastLine,
1608 XML_shrinkToFit, ToPsz( mbShrink ),
1609 XML_readingOrder, sax_fastparser::UseIf(OString::number(mnTextDir), mnTextDir != EXC_XF_TEXTDIR_CONTEXT) );
1610}
1611
1612namespace {
1613
1614void lclGetBorderLine(
1615 sal_uInt8& rnXclLine, sal_uInt32& rnColorId, model::ComplexColor& rComplexColor,
1616 const ::editeng::SvxBorderLine* pLine, XclExpPalette& rPalette, XclBiff eBiff )
1617{
1618 // Document: sc/qa/unit/data/README.cellborders
1619
1620 enum CalcLineIndex{Idx_None, Idx_Solid, Idx_Dotted, Idx_Dashed, Idx_FineDashed, Idx_DashDot, Idx_DashDotDot, Idx_DoubleThin, Idx_Last};
1621 enum ExcelWidthIndex{Width_Hair, Width_Thin, Width_Medium, Width_Thick, Width_Last};
1622 static sal_uInt8 Map_LineLO_toMS[Idx_Last][Width_Last] =
1623 {
1624 // 0,05 - 0,74 0,75 - 1,49 1,50 - 2,49 2,50 - 9,00 Width Range [pt]
1625 // EXC_BORDER_HAIR EXC_BORDER_THIN EXC_BORDER_MEDIUM EXC_BORDER_THICK MS Width
1626 {EXC_LINE_NONE , EXC_LINE_NONE , EXC_LINE_NONE , EXC_LINE_NONE }, // 0 BorderLineStyle::NONE
1627 {EXC_LINE_HAIR , EXC_LINE_THIN , EXC_LINE_MEDIUM , EXC_LINE_THICK }, // 1 BorderLineStyle::SOLID
1633 {EXC_LINE_DOUBLE , EXC_LINE_DOUBLE , EXC_LINE_DOUBLE , EXC_LINE_DOUBLE } // 7 BorderLineStyle::DOUBLE_THIN
1634 }; // Line Name
1635
1636 rnXclLine = EXC_LINE_NONE;
1637 if( pLine )
1638 {
1639 sal_uInt16 nOuterWidth = pLine->GetOutWidth();
1640 ExcelWidthIndex nOuterWidthIndx;
1641 CalcLineIndex nStyleIndex;
1642
1643 switch (pLine->GetBorderLineStyle())
1644 {
1645 case SvxBorderLineStyle::NONE:
1646 nStyleIndex = Idx_None;
1647 break;
1648 case SvxBorderLineStyle::SOLID:
1649 nStyleIndex = Idx_Solid;
1650 break;
1651 case SvxBorderLineStyle::DOTTED:
1652 nStyleIndex = Idx_Dotted;
1653 break;
1654 case SvxBorderLineStyle::DASHED:
1655 nStyleIndex = Idx_Dashed;
1656 break;
1657 case SvxBorderLineStyle::FINE_DASHED:
1658 nStyleIndex = Idx_FineDashed;
1659 break;
1660 case SvxBorderLineStyle::DASH_DOT:
1661 nStyleIndex = Idx_DashDot;
1662 break;
1663 case SvxBorderLineStyle::DASH_DOT_DOT:
1664 nStyleIndex = Idx_DashDotDot;
1665 break;
1666 case SvxBorderLineStyle::DOUBLE_THIN:
1667 // the "nOuterWidth" is not right for this line type
1668 // but at the moment width it not important for that
1669 // the right function is nOuterWidth = (sal_uInt16) pLine->GetWidth();
1670 nStyleIndex = Idx_DoubleThin;
1671 break;
1672 default:
1673 nStyleIndex = Idx_Solid;
1674 }
1675
1676 if( nOuterWidth >= EXC_BORDER_THICK )
1677 nOuterWidthIndx = Width_Thick;
1678 else if( nOuterWidth >= EXC_BORDER_MEDIUM )
1679 nOuterWidthIndx = Width_Medium;
1680 else if( nOuterWidth >= EXC_BORDER_THIN )
1681 nOuterWidthIndx = Width_Thin;
1682 else if ( nOuterWidth >= EXC_BORDER_HAIR )
1683 nOuterWidthIndx = Width_Hair;
1684 else
1685 nOuterWidthIndx = Width_Thin;
1686
1687 rnXclLine = Map_LineLO_toMS[nStyleIndex][nOuterWidthIndx];
1688 }
1689
1690 if( (eBiff == EXC_BIFF2) && (rnXclLine != EXC_LINE_NONE) )
1691 rnXclLine = EXC_LINE_THIN;
1692
1693 if (pLine && (rnXclLine != EXC_LINE_NONE))
1694 {
1695 rnColorId = rPalette.InsertColor(pLine->GetColor(), EXC_COLOR_CELLBORDER);
1696 rComplexColor = pLine->getComplexColor();
1697 }
1698 else
1699 {
1701 }
1702}
1703
1704} // namespace
1705
1707 mnLeftColorId( XclExpPalette::GetColorIdFromIndex( mnLeftColor ) ),
1708 mnRightColorId( XclExpPalette::GetColorIdFromIndex( mnRightColor ) ),
1709 mnTopColorId( XclExpPalette::GetColorIdFromIndex( mnTopColor ) ),
1710 mnBottomColorId( XclExpPalette::GetColorIdFromIndex( mnBottomColor ) ),
1711 mnDiagColorId( XclExpPalette::GetColorIdFromIndex( mnDiagColor ) )
1712{
1713}
1714
1716 const SfxItemSet& rItemSet, XclExpPalette& rPalette, XclBiff eBiff, bool bStyle )
1717{
1718 bool bUsed = false;
1719
1720 switch( eBiff )
1721 {
1722 case EXC_BIFF8: // attributes new in BIFF8
1723 {
1724 const SvxLineItem& rTLBRItem = rItemSet.Get( ATTR_BORDER_TLBR );
1725 sal_uInt8 nTLBRLine;
1726 sal_uInt32 nTLBRColorId;
1727 model::ComplexColor aTLBRComplexColor;
1728 lclGetBorderLine( nTLBRLine, nTLBRColorId, aTLBRComplexColor, rTLBRItem.GetLine(), rPalette, eBiff );
1729 mbDiagTLtoBR = (nTLBRLine != EXC_LINE_NONE);
1730
1731 const SvxLineItem& rBLTRItem = rItemSet.Get( ATTR_BORDER_BLTR );
1732 sal_uInt8 nBLTRLine;
1733 sal_uInt32 nBLTRColorId;
1734 model::ComplexColor aBLTRComplexColor;
1735 lclGetBorderLine( nBLTRLine, nBLTRColorId, aBLTRComplexColor, rBLTRItem.GetLine(), rPalette, eBiff );
1736 mbDiagBLtoTR = (nBLTRLine != EXC_LINE_NONE);
1737
1738 if( ::ScHasPriority( rTLBRItem.GetLine(), rBLTRItem.GetLine() ) )
1739 {
1740 mnDiagLine = nTLBRLine;
1741 mnDiagColorId = nTLBRColorId;
1742 }
1743 else
1744 {
1745 mnDiagLine = nBLTRLine;
1746 mnDiagColorId = nBLTRColorId;
1747 }
1748
1749 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_BORDER_TLBR, bStyle ) ||
1750 ScfTools::CheckItem( rItemSet, ATTR_BORDER_BLTR, bStyle );
1751
1752 [[fallthrough]];
1753 }
1754
1755 case EXC_BIFF5:
1756 case EXC_BIFF4:
1757 case EXC_BIFF3:
1758 case EXC_BIFF2:
1759 {
1760 const SvxBoxItem& rBoxItem = rItemSet.Get( ATTR_BORDER );
1761
1762 lclGetBorderLine(mnLeftLine, mnLeftColorId, maComplexColorLeft, rBoxItem.GetLeft(), rPalette, eBiff);
1763 lclGetBorderLine(mnRightLine, mnRightColorId, maComplexColorRight, rBoxItem.GetRight(), rPalette, eBiff);
1764 lclGetBorderLine(mnTopLine, mnTopColorId, maComplexColorTop, rBoxItem.GetTop(), rPalette, eBiff);
1765 lclGetBorderLine(mnBottomLine, mnBottomColorId, maComplexColorBottom, rBoxItem.GetBottom(), rPalette, eBiff);
1766
1767 bUsed |= ScfTools::CheckItem( rItemSet, ATTR_BORDER, bStyle );
1768 }
1769
1770 break;
1771 default: DBG_ERROR_BIFF();
1772 }
1773
1774 return bUsed;
1775}
1776
1778{
1784}
1785
1786void XclExpCellBorder::FillToXF5( sal_uInt32& rnBorder, sal_uInt32& rnArea ) const
1787{
1788 ::insert_value( rnBorder, mnTopLine, 0, 3 );
1789 ::insert_value( rnBorder, mnLeftLine, 3, 3 );
1790 ::insert_value( rnArea, mnBottomLine, 22, 3 );
1791 ::insert_value( rnBorder, mnRightLine, 6, 3 );
1792 ::insert_value( rnBorder, mnTopColor, 9, 7 );
1793 ::insert_value( rnBorder, mnLeftColor, 16, 7 );
1794 ::insert_value( rnArea, mnBottomColor, 25, 7 );
1795 ::insert_value( rnBorder, mnRightColor, 23, 7 );
1796}
1797
1798void XclExpCellBorder::FillToXF8( sal_uInt32& rnBorder1, sal_uInt32& rnBorder2 ) const
1799{
1800 ::insert_value( rnBorder1, mnLeftLine, 0, 4 );
1801 ::insert_value( rnBorder1, mnRightLine, 4, 4 );
1802 ::insert_value( rnBorder1, mnTopLine, 8, 4 );
1803 ::insert_value( rnBorder1, mnBottomLine, 12, 4 );
1804 ::insert_value( rnBorder1, mnLeftColor, 16, 7 );
1805 ::insert_value( rnBorder1, mnRightColor, 23, 7 );
1806 ::insert_value( rnBorder2, mnTopColor, 0, 7 );
1807 ::insert_value( rnBorder2, mnBottomColor, 7, 7 );
1808 ::insert_value( rnBorder2, mnDiagColor, 14, 7 );
1809 ::insert_value( rnBorder2, mnDiagLine, 21, 4 );
1812}
1813
1814void XclExpCellBorder::FillToCF8( sal_uInt16& rnLine, sal_uInt32& rnColor ) const
1815{
1816 ::insert_value( rnLine, mnLeftLine, 0, 4 );
1817 ::insert_value( rnLine, mnRightLine, 4, 4 );
1818 ::insert_value( rnLine, mnTopLine, 8, 4 );
1819 ::insert_value( rnLine, mnBottomLine, 12, 4 );
1820 ::insert_value( rnColor, mnLeftColor, 0, 7 );
1821 ::insert_value( rnColor, mnRightColor, 7, 7 );
1822 ::insert_value( rnColor, mnTopColor, 16, 7 );
1823 ::insert_value( rnColor, mnBottomColor, 23, 7 );
1824}
1825
1826static const char* ToLineStyle( sal_uInt8 nLineStyle )
1827{
1828 switch( nLineStyle )
1829 {
1830 case EXC_LINE_NONE: return "none";
1831 case EXC_LINE_THIN: return "thin";
1832 case EXC_LINE_MEDIUM: return "medium";
1833 case EXC_LINE_THICK: return "thick";
1834 case EXC_LINE_DOUBLE: return "double";
1835 case EXC_LINE_HAIR: return "hair";
1836 case EXC_LINE_DOTTED: return "dotted";
1837 case EXC_LINE_DASHED: return "dashed";
1838 case EXC_LINE_MEDIUM_DASHED: return "mediumDashed";
1839 case EXC_LINE_THIN_DASHDOT: return "dashDot";
1840 case EXC_LINE_THIN_DASHDOTDOT: return "dashDotDot";
1841 case EXC_LINE_MEDIUM_DASHDOT: return "mediumDashDot";
1842 case EXC_LINE_MEDIUM_DASHDOTDOT: return "mediumDashDotDot";
1843 case EXC_LINE_MEDIUM_SLANT_DASHDOT: return "slantDashDot";
1844 }
1845 return "*unknown*";
1846}
1847
1848static void lcl_WriteBorder(XclExpXmlStream& rStrm, sal_Int32 nElement, sal_uInt8 nLineStyle, const Color& rColor, model::ComplexColor const& rComplexColor)
1849{
1850 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
1851 if( nLineStyle == EXC_LINE_NONE )
1852 {
1853 rStyleSheet->singleElement(nElement);
1854 }
1855 else if (rComplexColor.isValidSchemeType())
1856 {
1857 rStyleSheet->startElement(nElement, XML_style, ToLineStyle(nLineStyle));
1858
1859 sal_Int32 nTheme = oox::convertThemeColorTypeToExcelThemeNumber(rComplexColor.getSchemeType());
1860 double fTintShade = oox::convertColorTransformsToTintOrShade(rComplexColor);
1861 rStyleSheet->singleElement(XML_color,
1862 XML_theme, OString::number(nTheme),
1863 XML_tint, sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0));
1864
1865 rStyleSheet->endElement(nElement);
1866 }
1867 else if (rColor == Color(0, 0, 0))
1868 {
1869 rStyleSheet->singleElement(nElement, XML_style, ToLineStyle(nLineStyle));
1870 }
1871 else
1872 {
1873 rStyleSheet->startElement(nElement, XML_style, ToLineStyle(nLineStyle));
1874 rStyleSheet->singleElement(XML_color, XML_rgb, XclXmlUtils::ToOString(rColor));
1875 rStyleSheet->endElement( nElement );
1876 }
1877}
1878
1880{
1881 sax_fastparser::FSHelperPtr& rStyleSheet = rStream.GetCurrentStream();
1882
1883 XclExpPalette& rPalette = rStream.GetRoot().GetPalette();
1884
1885 rStyleSheet->startElement( XML_border,
1886 XML_diagonalUp, ToPsz( mbDiagBLtoTR ),
1887 XML_diagonalDown, ToPsz( mbDiagTLtoBR )
1888 // OOXTODO: XML_outline
1889 );
1890
1891 lcl_WriteBorder(rStream, XML_left, mnLeftLine, rPalette.GetColor(mnLeftColor), maComplexColorLeft);
1892 lcl_WriteBorder(rStream, XML_right, mnRightLine, rPalette.GetColor(mnRightColor), maComplexColorRight);
1893 lcl_WriteBorder(rStream, XML_top, mnTopLine, rPalette.GetColor(mnTopColor), maComplexColorTop);
1895 lcl_WriteBorder(rStream, XML_diagonal, mnDiagLine, rPalette.GetColor(mnDiagColor), maComplexColorDiagonal);
1896
1897 // OOXTODO: XML_vertical, XML_horizontal
1898 rStyleSheet->endElement( XML_border );
1899}
1900
1902 mnForeColorId(XclExpPalette::GetColorIdFromIndex(mnForeColor)),
1903 mnBackColorId(XclExpPalette::GetColorIdFromIndex(mnBackColor)),
1904 maForeColor(COL_TRANSPARENT),
1905 maBackColor(COL_TRANSPARENT)
1906{
1907}
1908
1911 , mnForeColorId(0)
1912 , mnBackColorId(0)
1913 , maForeColor(aForeColor)
1914 , maBackColor(aBackColor)
1915{
1916}
1917
1918bool XclExpCellArea::FillFromItemSet( const SfxItemSet& rItemSet, XclExpPalette& rPalette, bool bStyle )
1919{
1920 const SvxBrushItem& rBrushItem = rItemSet.Get( ATTR_BACKGROUND );
1921
1922 if (rBrushItem.getComplexColor().getType() != model::ColorType::Unused)
1924
1925 if( rBrushItem.GetColor().IsTransparent() )
1926 {
1930 }
1931 else
1932 {
1934 mnForeColorId = rPalette.InsertColor( rBrushItem.GetColor(), EXC_COLOR_CELLAREA );
1936 }
1937 return ScfTools::CheckItem( rItemSet, ATTR_BACKGROUND, bStyle );
1938}
1939
1941{
1943}
1944
1945void XclExpCellArea::FillToXF5( sal_uInt32& rnArea ) const
1946{
1947 ::insert_value( rnArea, mnPattern, 16, 6 );
1948 ::insert_value( rnArea, mnForeColor, 0, 7 );
1949 ::insert_value( rnArea, mnBackColor, 7, 7 );
1950}
1951
1952void XclExpCellArea::FillToXF8( sal_uInt32& rnBorder2, sal_uInt16& rnArea ) const
1953{
1954 ::insert_value( rnBorder2, mnPattern, 26, 6 );
1955 ::insert_value( rnArea, mnForeColor, 0, 7 );
1956 ::insert_value( rnArea, mnBackColor, 7, 7 );
1957}
1958
1959void XclExpCellArea::FillToCF8( sal_uInt16& rnPattern, sal_uInt16& rnColor ) const
1960{
1961 XclCellArea aTmp( *this );
1962 if( !aTmp.IsTransparent() && (aTmp.mnBackColor == EXC_COLOR_WINDOWTEXT) )
1963 aTmp.mnBackColor = 0;
1964 if( aTmp.mnPattern == EXC_PATT_SOLID )
1965 ::std::swap( aTmp.mnForeColor, aTmp.mnBackColor );
1966 ::insert_value( rnColor, aTmp.mnForeColor, 0, 7 );
1967 ::insert_value( rnColor, aTmp.mnBackColor, 7, 7 );
1968 ::insert_value( rnPattern, aTmp.mnPattern, 10, 6 );
1969}
1970
1971static const char* ToPatternType( sal_uInt8 nPattern )
1972{
1973 switch( nPattern )
1974 {
1975 case EXC_PATT_NONE: return "none";
1976 case EXC_PATT_SOLID: return "solid";
1977 case EXC_PATT_50_PERC: return "mediumGray";
1978 case EXC_PATT_75_PERC: return "darkGray";
1979 case EXC_PATT_25_PERC: return "lightGray";
1980 case EXC_PATT_12_5_PERC: return "gray125";
1981 case EXC_PATT_6_25_PERC: return "gray0625";
1982 }
1983 return "*unknown*";
1984}
1985
1987{
1988 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
1989 rStyleSheet->startElement(XML_fill);
1990
1991 // OOXTODO: XML_gradientFill
1992
1993 XclExpPalette& rPalette = rStrm.GetRoot().GetPalette();
1994
1995 if (mnPattern == EXC_PATT_NONE ||
1997 {
1998 rStyleSheet->singleElement(XML_patternFill, XML_patternType, ToPatternType(mnPattern));
1999 }
2000 else
2001 {
2002 rStyleSheet->startElement(XML_patternFill, XML_patternType, ToPatternType(mnPattern));
2003
2005 {
2007 {
2010 rStyleSheet->singleElement(XML_fgColor,
2011 XML_theme, OString::number(nTheme),
2012 XML_tint, sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0));
2013 }
2014 else if (maForeColor != COL_TRANSPARENT)
2015 {
2016 rStyleSheet->singleElement(XML_fgColor, XML_rgb, XclXmlUtils::ToOString(maForeColor));
2017 }
2018
2020 {
2023 rStyleSheet->singleElement(XML_bgColor,
2024 XML_theme, OString::number(nTheme),
2025 XML_tint, sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0));
2026 }
2027 else if (maBackColor != COL_TRANSPARENT)
2028 {
2029 rStyleSheet->singleElement(XML_bgColor, XML_rgb, XclXmlUtils::ToOString(maBackColor));
2030 }
2031 }
2032 else
2033 {
2035 {
2038
2039 rStyleSheet->singleElement(XML_fgColor,
2040 XML_theme, OString::number(nTheme),
2041 XML_tint, sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0));
2042 }
2043 else if (mnForeColor != 0)
2044 {
2045 rStyleSheet->singleElement(XML_fgColor, XML_rgb, XclXmlUtils::ToOString(rPalette.GetColor(mnForeColor)));
2046 }
2047
2049 {
2052 rStyleSheet->singleElement(XML_bgColor,
2053 XML_theme, OString::number(nTheme),
2054 XML_tint, sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0));
2055 }
2056 else if (mnBackColor != 0)
2057 {
2058 rStyleSheet->singleElement(XML_bgColor, XML_rgb, XclXmlUtils::ToOString(rPalette.GetColor(mnBackColor)));
2059 }
2060 }
2061
2062 rStyleSheet->endElement( XML_patternFill );
2063 }
2064
2065 rStyleSheet->endElement( XML_fill );
2066}
2067
2069{
2070 if( !ScfTools::CheckItem( rItemSet, ATTR_BACKGROUND, true ) )
2071 return false;
2072
2073 const SvxBrushItem& rBrushItem = rItemSet.Get( ATTR_BACKGROUND );
2074 maColor = rBrushItem.GetColor();
2075 maComplexColor = rBrushItem.getComplexColor();
2076
2077 return true;
2078}
2079
2081{
2082 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
2083 rStyleSheet->startElement(XML_fill);
2084 rStyleSheet->startElement(XML_patternFill);
2086 {
2089 rStyleSheet->singleElement(XML_bgColor,
2090 XML_theme, OString::number(nTheme),
2091 XML_tint, sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0));
2092 }
2093 else
2094 rStyleSheet->singleElement(XML_bgColor, XML_rgb, XclXmlUtils::ToOString(maColor));
2095
2096 rStyleSheet->endElement( XML_patternFill );
2097 rStyleSheet->endElement( XML_fill );
2098}
2099
2101 mnXFId( XclExpXFBuffer::GetDefCellXFId() ),
2102 mnXFIndex( EXC_XF_DEFAULTCELL )
2103{
2104}
2105
2107{
2109}
2110
2112 const XclExpRoot& rRoot, const ScPatternAttr& rPattern, sal_Int16 nScript,
2113 sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak ) :
2114 XclXFBase( true ),
2115 XclExpRoot( rRoot )
2116{
2118 Init( rPattern.GetItemSet(), nScript, nForceScNumFmt, nForceXclFont, bForceLineBreak, false );
2119}
2120
2121XclExpXF::XclExpXF( const XclExpRoot& rRoot, const SfxStyleSheetBase& rStyleSheet ) :
2122 XclXFBase( false ),
2123 XclExpRoot( rRoot ),
2124 mnParentXFId( XclExpXFBuffer::GetXFIdFromIndex( EXC_XF_STYLEPARENT ) )
2125{
2126 bool bDefStyle = (rStyleSheet.GetName() == ScResId( STR_STYLENAME_STANDARD ));
2127 sal_Int16 nScript = bDefStyle ? GetDefApiScript() : css::i18n::ScriptType::WEAK;
2128 Init( const_cast< SfxStyleSheetBase& >( rStyleSheet ).GetItemSet(), nScript,
2130}
2131
2132XclExpXF::XclExpXF( const XclExpRoot& rRoot, bool bCellXF ) :
2133 XclXFBase( bCellXF ),
2134 XclExpRoot( rRoot ),
2135 mnParentXFId( XclExpXFBuffer::GetXFIdFromIndex( EXC_XF_STYLEPARENT ) )
2136{
2137 InitDefault();
2138}
2139
2140bool XclExpXF::Equals( const ScPatternAttr& rPattern,
2141 sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak ) const
2142{
2143 return IsCellXF() && (mpItemSet == &rPattern.GetItemSet()) &&
2144 (!bForceLineBreak || maAlignment.mbLineBreak) &&
2145 ((nForceScNumFmt == NUMBERFORMAT_ENTRY_NOT_FOUND) || (mnScNumFmt == nForceScNumFmt)) &&
2146 ((nForceXclFont == EXC_FONT_NOTFOUND) || (mnXclFont == nForceXclFont));
2147}
2148
2149bool XclExpXF::Equals( const SfxStyleSheetBase& rStyleSheet ) const
2150{
2151 return IsStyleXF() && (mpItemSet == &const_cast< SfxStyleSheetBase& >( rStyleSheet ).GetItemSet());
2152}
2153
2155{
2158}
2159
2160bool XclExpXF::Equals( const XclExpXF& rCmpXF ) const
2161{
2162 return XclXFBase::Equals( rCmpXF ) &&
2163 (maProtection == rCmpXF.maProtection) && (maAlignment == rCmpXF.maAlignment) &&
2164 (maBorder == rCmpXF.maBorder) && (maArea == rCmpXF.maArea) &&
2165 (mnXclFont == rCmpXF.mnXclFont) && (mnXclNumFmt == rCmpXF.mnXclNumFmt) &&
2166 (mnParentXFId == rCmpXF.mnParentXFId);
2167}
2168
2170{
2171 SetRecHeader( EXC_ID5_XF, (GetBiff() == EXC_BIFF8) ? 20 : 16 );
2172 mpItemSet = nullptr;
2174 mnXclFont = mnXclNumFmt = 0;
2175 SetXmlIds(0, 0);
2176}
2177
2178void XclExpXF::Init( const SfxItemSet& rItemSet, sal_Int16 nScript,
2179 sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak, bool bDefStyle )
2180{
2181 InitDefault();
2182 mpItemSet = &rItemSet;
2183
2184 // cell protection
2186
2187 // font
2188 if( nForceXclFont == EXC_FONT_NOTFOUND )
2189 {
2190 mnXclFont = GetFontBuffer().Insert( rItemSet, nScript, EXC_COLOR_CELLTEXT, bDefStyle );
2191 mbFontUsed = XclExpFontHelper::CheckItems( GetRoot(), rItemSet, nScript, IsStyleXF() );
2192 }
2193 else
2194 {
2195 mnXclFont = nForceXclFont;
2196 mbFontUsed = true;
2197 }
2198
2199 // number format
2200 if (nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND)
2201 mnXclNumFmt = nForceScNumFmt;
2202 else
2203 {
2204 // Built-in formats of dedicated languages may be attributed using the
2205 // system language (or even other?) format with a language attribute,
2206 // obtain the "real" format key.
2207 mnScNumFmt = rItemSet.Get( ATTR_VALUE_FORMAT ).GetValue();
2208 LanguageType nLang = rItemSet.Get( ATTR_LANGUAGE_FORMAT).GetLanguage();
2211 }
2214
2215 // alignment
2216 mbAlignUsed = maAlignment.FillFromItemSet(*this, rItemSet, bForceLineBreak, GetBiff(), IsStyleXF());
2217
2218 // cell border
2220
2221 // background area
2223
2224 // set all b***Used flags to true in "Default"/"Normal" style
2225 if( bDefStyle )
2226 SetAllUsedFlags( true );
2227}
2228
2230{
2231 sal_uInt8 nUsedFlags = 0;
2232 /* In cell XFs a set bit means a used attribute, in style XFs a cleared bit.
2233 "mbCellXF == mb***Used" evaluates to correct value in cell and style XFs. */
2240 return nUsedFlags;
2241}
2242
2244{
2245 sal_uInt16 nTypeProt = 0, nAlign = 0;
2246 sal_uInt32 nArea = 0, nBorder = 0;
2247
2248 ::set_flag( nTypeProt, EXC_XF_STYLE, IsStyleXF() );
2249 ::insert_value( nTypeProt, mnParent, 4, 12 );
2250 ::insert_value( nAlign, GetUsedFlags(), 10, 6 );
2251
2252 maProtection.FillToXF3( nTypeProt );
2253 maAlignment.FillToXF5( nAlign );
2254 maBorder.FillToXF5( nBorder, nArea );
2255 maArea.FillToXF5( nArea );
2256
2257 rStrm << mnXclFont << mnXclNumFmt << nTypeProt << nAlign << nArea << nBorder;
2258}
2259
2261{
2262 sal_uInt16 nTypeProt = 0, nAlign = 0, nMiscAttrib = 0, nArea = 0;
2263 sal_uInt32 nBorder1 = 0, nBorder2 = 0;
2264
2265 ::set_flag( nTypeProt, EXC_XF_STYLE, IsStyleXF() );
2266 ::insert_value( nTypeProt, mnParent, 4, 12 );
2267 ::insert_value( nMiscAttrib, GetUsedFlags(), 10, 6 );
2268
2269 maProtection.FillToXF3( nTypeProt );
2270 maAlignment.FillToXF8( nAlign, nMiscAttrib );
2271 maBorder.FillToXF8( nBorder1, nBorder2 );
2272 maArea.FillToXF8( nBorder2, nArea );
2273
2274 rStrm << mnXclFont << mnXclNumFmt << nTypeProt << nAlign << nMiscAttrib << nBorder1 << nBorder2 << nArea;
2275}
2276
2278{
2279 XclExpXFId aParentId( mnParentXFId );
2280 aParentId.ConvertXFIndex( GetRoot() );
2281 mnParent = aParentId.mnXFIndex;
2282 switch( GetBiff() )
2283 {
2284 case EXC_BIFF5: WriteBody5( rStrm ); break;
2285 case EXC_BIFF8: WriteBody8( rStrm ); break;
2286 default: DBG_ERROR_BIFF();
2287 }
2288}
2289
2290void XclExpXF::SetXmlIds( sal_uInt32 nBorderId, sal_uInt32 nFillId )
2291{
2292 mnBorderId = nBorderId;
2293 mnFillId = nFillId;
2294}
2295
2297{
2298 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
2299
2300 sal_Int32 nXfId = 0;
2301 const XclExpXF* pStyleXF = nullptr;
2302 if( IsCellXF() )
2303 {
2304 sal_uInt16 nXFIndex = rStrm.GetRoot().GetXFBuffer().GetXFIndex( mnParentXFId );
2305 nXfId = rStrm.GetRoot().GetXFBuffer().GetXmlStyleIndex( nXFIndex );
2306 pStyleXF = rStrm.GetRoot().GetXFBuffer().GetXFById( mnParentXFId );
2307 }
2308
2309 rStyleSheet->startElement( XML_xf,
2310 XML_numFmtId, OString::number(mnXclNumFmt),
2311 XML_fontId, OString::number(mnXclFont),
2312 XML_fillId, OString::number(mnFillId),
2313 XML_borderId, OString::number(mnBorderId),
2314 XML_xfId, sax_fastparser::UseIf(OString::number(nXfId), !IsStyleXF()),
2315 // OOXTODO: XML_quotePrefix,
2316 // OOXTODO: XML_pivotButton,
2317 // OOXTODO: XML_applyNumberFormat, ;
2318 XML_applyFont, ToPsz( mbFontUsed ),
2319 // OOXTODO: XML_applyFill,
2320 XML_applyBorder, ToPsz( mbBorderUsed ),
2321 XML_applyAlignment, ToPsz( mbAlignUsed ),
2322 XML_applyProtection, ToPsz( mbProtUsed ) );
2323 if( mbAlignUsed )
2325 else if ( pStyleXF )
2326 pStyleXF->GetAlignmentData().SaveXml( rStrm );
2327 if( mbProtUsed )
2329 else if ( pStyleXF )
2330 pStyleXF->GetProtectionData().SaveXml( rStrm );
2331
2332 // OOXTODO: XML_extLst
2333 rStyleSheet->endElement( XML_xf );
2334}
2335
2336XclExpDefaultXF::XclExpDefaultXF( const XclExpRoot& rRoot, bool bCellXF ) :
2337 XclExpXF( rRoot, bCellXF )
2338{
2339}
2340
2341void XclExpDefaultXF::SetFont( sal_uInt16 nXclFont )
2342{
2343 mnXclFont = nXclFont;
2344 mbFontUsed = true;
2345}
2346
2347void XclExpDefaultXF::SetNumFmt( sal_uInt16 nXclNumFmt )
2348{
2349 mnXclNumFmt = nXclNumFmt;
2350 mbFmtUsed = true;
2351}
2352
2353XclExpStyle::XclExpStyle( sal_uInt32 nXFId, OUString aStyleName ) :
2355 maName(std::move( aStyleName )),
2356 maXFId( nXFId ),
2357 mnStyleId( EXC_STYLE_USERDEF ),
2359{
2360 OSL_ENSURE( !maName.isEmpty(), "XclExpStyle::XclExpStyle - empty style name" );
2361#if OSL_DEBUG_LEVEL > 0
2362 sal_uInt8 nStyleId, nLevel; // do not use members for debug tests
2363 OSL_ENSURE( !XclTools::GetBuiltInStyleId( nStyleId, nLevel, maName ),
2364 "XclExpStyle::XclExpStyle - this is a built-in style" );
2365#endif
2366}
2367
2368XclExpStyle::XclExpStyle( sal_uInt32 nXFId, sal_uInt8 nStyleId, sal_uInt8 nLevel ) :
2370 maXFId( nXFId ),
2371 mnStyleId( nStyleId ),
2372 mnLevel( nLevel )
2373{
2374}
2375
2377{
2378 maXFId.ConvertXFIndex( rStrm.GetRoot() );
2381
2382 if( IsBuiltIn() )
2383 {
2384 rStrm << mnStyleId << mnLevel;
2385 }
2386 else
2387 {
2388 XclExpString aNameEx;
2389 if( rStrm.GetRoot().GetBiff() == EXC_BIFF8 )
2390 aNameEx.Assign( maName );
2391 else
2392 aNameEx.AssignByte( maName, rStrm.GetRoot().GetTextEncoding(), XclStrFlags::EightBitLength );
2393 rStrm << aNameEx;
2394 }
2395}
2396
2397static const char* lcl_StyleNameFromId( sal_Int32 nStyleId )
2398{
2399 switch( nStyleId )
2400 {
2401 case 0: return "Normal";
2402 case 3: return "Comma";
2403 case 4: return "Currency";
2404 case 5: return "Percent";
2405 case 6: return "Comma [0]";
2406 case 7: return "Currency [0]";
2407 }
2408 return "*unknown*";
2409}
2410
2412{
2413 constexpr sal_Int32 CELL_STYLE_MAX_BUILTIN_ID = 54;
2414 OString sName;
2415 OString sBuiltinId;
2416 const char* pBuiltinId = nullptr;
2417 if( IsBuiltIn() )
2418 {
2419 sName = OString( lcl_StyleNameFromId( mnStyleId ) );
2420 sBuiltinId = OString::number( std::min( static_cast<sal_Int32>( CELL_STYLE_MAX_BUILTIN_ID - 1 ), static_cast <sal_Int32>( mnStyleId ) ) );
2421 pBuiltinId = sBuiltinId.getStr();
2422 }
2423 else
2424 sName = maName.toUtf8();
2425
2426 // get the index in sortedlist associated with the mnXId
2427 sal_Int32 nXFId = rStrm.GetRoot().GetXFBuffer().GetXFIndex( maXFId.mnXFId );
2428 // get the style index associated with index into sortedlist
2429 nXFId = rStrm.GetRoot().GetXFBuffer().GetXmlStyleIndex( nXFId );
2430 rStrm.GetCurrentStream()->singleElement( XML_cellStyle,
2431 XML_name, sName,
2432 XML_xfId, OString::number(nXFId),
2433// builtinId of 54 or above is invalid according to OpenXML SDK validator.
2434 XML_builtinId, pBuiltinId
2435 // OOXTODO: XML_iLevel,
2436 // OOXTODO: XML_hidden,
2437 // XML_customBuiltin, ToPsz( ! IsBuiltIn() )
2438 );
2439 // OOXTODO: XML_extLst
2440}
2441
2442namespace {
2443
2444const sal_uInt32 EXC_XFLIST_INDEXBASE = 0xFFFE0000;
2446const sal_uInt32 EXC_XFLIST_HARDLIMIT = 256 * 1024;
2447
2448bool lclIsBuiltInStyle( const OUString& rStyleName )
2449{
2450 return
2451 XclTools::IsBuiltInStyleName( rStyleName ) ||
2452 XclTools::IsCondFormatStyleName( rStyleName );
2453}
2454
2455} // namespace
2456
2458 mnStyleId( EXC_STYLE_USERDEF ),
2460 mbPredefined( true ),
2461 mbHasStyleRec( false )
2462{
2463}
2464
2465namespace {
2466
2468struct XclExpBorderPred
2469{
2470 const XclExpCellBorder&
2471 mrBorder;
2472 explicit XclExpBorderPred( const XclExpCellBorder& rBorder ) : mrBorder( rBorder ) {}
2473 bool operator()( const XclExpCellBorder& rBorder ) const;
2474};
2475
2476}
2477
2478bool XclExpBorderPred::operator()( const XclExpCellBorder& rBorder ) const
2479{
2480 return
2481 mrBorder.mnLeftColor == rBorder.mnLeftColor &&
2482 mrBorder.mnRightColor == rBorder.mnRightColor &&
2483 mrBorder.mnTopColor == rBorder.mnTopColor &&
2484 mrBorder.mnBottomColor == rBorder.mnBottomColor &&
2485 mrBorder.mnDiagColor == rBorder.mnDiagColor &&
2486 mrBorder.mnLeftLine == rBorder.mnLeftLine &&
2487 mrBorder.mnRightLine == rBorder.mnRightLine &&
2488 mrBorder.mnTopLine == rBorder.mnTopLine &&
2489 mrBorder.mnBottomLine == rBorder.mnBottomLine &&
2490 mrBorder.mnDiagLine == rBorder.mnDiagLine &&
2491 mrBorder.mbDiagTLtoBR == rBorder.mbDiagTLtoBR &&
2492 mrBorder.mbDiagBLtoTR == rBorder.mbDiagBLtoTR &&
2493 mrBorder.mnLeftColorId == rBorder.mnLeftColorId &&
2494 mrBorder.mnRightColorId == rBorder.mnRightColorId &&
2495 mrBorder.mnTopColorId == rBorder.mnTopColorId &&
2496 mrBorder.mnBottomColorId == rBorder.mnBottomColorId &&
2497 mrBorder.mnDiagColorId == rBorder.mnDiagColorId;
2498}
2499
2500namespace {
2501
2502struct XclExpFillPred
2503{
2504 const XclExpCellArea&
2505 mrFill;
2506 explicit XclExpFillPred( const XclExpCellArea& rFill ) : mrFill( rFill ) {}
2507 bool operator()( const XclExpCellArea& rFill ) const;
2508};
2509
2510}
2511
2512bool XclExpFillPred::operator()( const XclExpCellArea& rFill ) const
2513{
2514 return
2515 mrFill.mnForeColor == rFill.mnForeColor &&
2516 mrFill.mnBackColor == rFill.mnBackColor &&
2517 mrFill.mnPattern == rFill.mnPattern &&
2518 mrFill.mnForeColorId == rFill.mnForeColorId &&
2519 mrFill.mnBackColorId == rFill.mnBackColorId;
2520}
2521
2523 XclExpRoot( rRoot )
2524{
2525}
2526
2528{
2531}
2532
2533sal_uInt32 XclExpXFBuffer::Insert( const ScPatternAttr* pPattern, sal_Int16 nScript )
2534{
2535 return InsertCellXF( pPattern, nScript, NUMBERFORMAT_ENTRY_NOT_FOUND, EXC_FONT_NOTFOUND, false );
2536}
2537
2538sal_uInt32 XclExpXFBuffer::InsertWithFont( const ScPatternAttr* pPattern, sal_Int16 nScript,
2539 sal_uInt16 nForceXclFont, bool bForceLineBreak )
2540{
2541 return InsertCellXF( pPattern, nScript, NUMBERFORMAT_ENTRY_NOT_FOUND, nForceXclFont, bForceLineBreak );
2542}
2543
2544sal_uInt32 XclExpXFBuffer::InsertWithNumFmt( const ScPatternAttr* pPattern, sal_Int16 nScript, sal_uInt32 nForceScNumFmt, bool bForceLineBreak )
2545{
2546 return InsertCellXF( pPattern, nScript, nForceScNumFmt, EXC_FONT_NOTFOUND, bForceLineBreak );
2547}
2548
2549sal_uInt32 XclExpXFBuffer::InsertStyle( const SfxStyleSheetBase* pStyleSheet )
2550{
2551 return pStyleSheet ? InsertStyleXF( *pStyleSheet ) : GetXFIdFromIndex( EXC_XF_DEFAULTSTYLE );
2552}
2553
2554sal_uInt32 XclExpXFBuffer::GetXFIdFromIndex( sal_uInt16 nXFIndex )
2555{
2556 return EXC_XFLIST_INDEXBASE | nXFIndex;
2557}
2558
2560{
2562}
2563
2564const XclExpXF* XclExpXFBuffer::GetXFById( sal_uInt32 nXFId ) const
2565{
2566 return maXFList.GetRecord( nXFId );
2567}
2568
2570{
2571 for( size_t nPos = 0, nSize = maXFList.GetSize(); nPos < nSize; ++nPos )
2573
2574 sal_uInt32 nTotalCount = static_cast< sal_uInt32 >( maXFList.GetSize() );
2575 sal_uInt32 nId;
2576 maXFIndexVec.resize( nTotalCount, EXC_XF_DEFAULTCELL );
2577 maStyleIndexes.resize( nTotalCount, EXC_XF_DEFAULTCELL );
2578 maCellIndexes.resize( nTotalCount, EXC_XF_DEFAULTCELL );
2579
2580 XclExpBuiltInMap::const_iterator aBuiltInEnd = maBuiltInMap.end();
2581 /* nMaxBuiltInXFId used to decide faster whether an XF record is
2582 user-defined. If the current XF ID is greater than this value,
2583 maBuiltInMap doesn't need to be searched. */
2584 sal_uInt32 nMaxBuiltInXFId = maBuiltInMap.empty() ? 0 : maBuiltInMap.rbegin()->first;
2585
2586 // *** map all built-in XF records (cell and style) *** -------------------
2587
2588 // do not change XF order -> std::map<> iterates elements in ascending order
2589 for( const auto& rEntry : maBuiltInMap )
2590 AppendXFIndex( rEntry.first );
2591
2592 // *** insert all user-defined style XF records, without reduce *** -------
2593
2594 sal_uInt32 nStyleXFCount = 0; // counts up to EXC_XF_MAXSTYLECOUNT limit
2595
2596 for( nId = 0; nId < nTotalCount; ++nId )
2597 {
2599 if( xXF->IsStyleXF() && ((nId > nMaxBuiltInXFId) || (maBuiltInMap.find( nId ) == aBuiltInEnd)) )
2600 {
2601 if( nStyleXFCount < EXC_XF_MAXSTYLECOUNT )
2602 {
2603 // maximum count of styles not reached
2604 AppendXFIndex( nId );
2605 ++nStyleXFCount;
2606 }
2607 else
2608 {
2609 /* Maximum count of styles reached - do not append more
2610 pointers to XFs; use default style XF instead; do not break
2611 the loop to initialize all maXFIndexVec elements. */
2613 }
2614 }
2615 }
2616
2617 // *** insert all cell XF records *** -------------------------------------
2618
2619 // start position to search for equal inserted XF records
2620 size_t nSearchStart = maSortedXFList.GetSize();
2621
2622 // break the loop if XF limit reached - maXFIndexVec is already initialized with default index
2624 for( nId = 0; (nId < nTotalCount) && (maSortedXFList.GetSize() < EXC_XF_MAXCOUNT); ++nId )
2625 {
2627 if( xXF->IsCellXF() && ((nId > nMaxBuiltInXFId) || (maBuiltInMap.find( nId ) == aBuiltInEnd)) )
2628 {
2629 // try to find an XF record equal to *xXF, which is already inserted
2630 sal_uInt16 nFoundIndex = EXC_XF_NOTFOUND;
2631
2632 // first try if it is equal to the default cell XF
2633 if( xDefCellXF->Equals( *xXF ) )
2634 {
2635 nFoundIndex = EXC_XF_DEFAULTCELL;
2636 }
2637 else for( size_t nSearchPos = nSearchStart, nSearchEnd = maSortedXFList.GetSize();
2638 (nSearchPos < nSearchEnd) && (nFoundIndex == EXC_XF_NOTFOUND); ++nSearchPos )
2639 {
2640 if( maSortedXFList.GetRecord( nSearchPos )->Equals( *xXF ) )
2641 nFoundIndex = static_cast< sal_uInt16 >( nSearchPos );
2642 }
2643
2644 if( nFoundIndex != EXC_XF_NOTFOUND )
2645 // equal XF already in the list, use its resulting XF index
2646 maXFIndexVec[ nId ] = nFoundIndex;
2647 else
2648 AppendXFIndex( nId );
2649 }
2650 }
2651
2652 sal_uInt16 nXmlStyleIndex = 0;
2653 sal_uInt16 nXmlCellIndex = 0;
2654
2655 size_t nXFCount = maSortedXFList.GetSize();
2656 for( size_t i = 0; i < nXFCount; ++i )
2657 {
2659 if( xXF->IsStyleXF() )
2660 maStyleIndexes[ i ] = nXmlStyleIndex++;
2661 else
2662 maCellIndexes[ i ] = nXmlCellIndex++;
2663 }
2664}
2665
2666sal_uInt16 XclExpXFBuffer::GetXFIndex( sal_uInt32 nXFId ) const
2667{
2668 sal_uInt16 nXFIndex = EXC_XF_DEFAULTSTYLE;
2669 if( nXFId >= EXC_XFLIST_INDEXBASE )
2670 nXFIndex = static_cast< sal_uInt16 >( nXFId & ~EXC_XFLIST_INDEXBASE );
2671 else if( nXFId < maXFIndexVec.size() )
2672 nXFIndex = maXFIndexVec[ nXFId ];
2673 return nXFIndex;
2674}
2675
2676sal_Int32 XclExpXFBuffer::GetXmlStyleIndex( sal_uInt32 nXFIndex ) const
2677{
2678 OSL_ENSURE( nXFIndex < maStyleIndexes.size(), "XclExpXFBuffer::GetXmlStyleIndex - invalid index!" );
2679 if( nXFIndex >= maStyleIndexes.size() )
2680 return 0; // should be caught/debugged via above assert; return "valid" index.
2681 return maStyleIndexes[ nXFIndex ];
2682}
2683
2684sal_Int32 XclExpXFBuffer::GetXmlCellIndex( sal_uInt32 nXFIndex ) const
2685{
2686 OSL_ENSURE( nXFIndex < maCellIndexes.size(), "XclExpXFBuffer::GetXmlStyleIndex - invalid index!" );
2687 if( nXFIndex >= maCellIndexes.size() )
2688 return 0; // should be caught/debugged via above assert; return "valid" index.
2689 return maCellIndexes[ nXFIndex ];
2690}
2691
2693{
2694 // save all XF records contained in the maSortedXFList vector (sorted by XF index)
2696 // save all STYLE records
2698}
2699
2700static void lcl_GetCellCounts( const XclExpRecordList< XclExpXF >& rXFList, sal_Int32& rCells, sal_Int32& rStyles )
2701{
2702 rCells = 0;
2703 rStyles = 0;
2704 size_t nXFCount = rXFList.GetSize();
2705 for( size_t i = 0; i < nXFCount; ++i )
2706 {
2708 if( xXF->IsCellXF() )
2709 ++rCells;
2710 else if( xXF->IsStyleXF() )
2711 ++rStyles;
2712 }
2713}
2714
2716{
2717 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
2718
2719 rStyleSheet->startElement(XML_fills, XML_count, OString::number(maFills.size()));
2720 for( const auto& rFill : maFills )
2721 {
2722 rFill.SaveXml( rStrm );
2723 }
2724 rStyleSheet->endElement( XML_fills );
2725
2726 rStyleSheet->startElement(XML_borders, XML_count, OString::number(maBorders.size()));
2727 for( const auto& rBorder : maBorders )
2728 {
2729 rBorder.SaveXml( rStrm );
2730 }
2731 rStyleSheet->endElement( XML_borders );
2732
2733 // save all XF records contained in the maSortedXFList vector (sorted by XF index)
2734 sal_Int32 nCells, nStyles;
2735 lcl_GetCellCounts( maSortedXFList, nCells, nStyles );
2736
2737 if( nStyles > 0 )
2738 {
2739 rStyleSheet->startElement(XML_cellStyleXfs, XML_count, OString::number(nStyles));
2740 size_t nXFCount = maSortedXFList.GetSize();
2741 for( size_t i = 0; i < nXFCount; ++i )
2742 {
2744 if( ! xXF->IsStyleXF() )
2745 continue;
2746 SaveXFXml( rStrm, *xXF );
2747 }
2748 rStyleSheet->endElement( XML_cellStyleXfs );
2749 }
2750
2751 if( nCells > 0 )
2752 {
2753 rStyleSheet->startElement(XML_cellXfs, XML_count, OString::number(nCells));
2754 size_t nXFCount = maSortedXFList.GetSize();
2755 for( size_t i = 0; i < nXFCount; ++i )
2756 {
2758 if( ! xXF->IsCellXF() )
2759 continue;
2760 SaveXFXml( rStrm, *xXF );
2761 }
2762 rStyleSheet->endElement( XML_cellXfs );
2763 }
2764
2765 // save all STYLE records
2766 rStyleSheet->startElement(XML_cellStyles, XML_count, OString::number(maStyleList.GetSize()));
2768 rStyleSheet->endElement( XML_cellStyles );
2769}
2770
2772{
2773 XclExpBorderList::iterator aBorderPos =
2774 std::find_if( maBorders.begin(), maBorders.end(), XclExpBorderPred( rXF.GetBorderData() ) );
2775 OSL_ENSURE( aBorderPos != maBorders.end(), "XclExpXFBuffer::SaveXml - Invalid @borderId!" );
2776 XclExpFillList::iterator aFillPos =
2777 std::find_if( maFills.begin(), maFills.end(), XclExpFillPred( rXF.GetAreaData() ) );
2778 OSL_ENSURE( aFillPos != maFills.end(), "XclExpXFBuffer::SaveXml - Invalid @fillId!" );
2779
2780 sal_Int32 nBorderId = 0, nFillId = 0;
2781 if( aBorderPos != maBorders.end() )
2782 nBorderId = std::distance( maBorders.begin(), aBorderPos );
2783 if( aFillPos != maFills.end() )
2784 nFillId = std::distance( maFills.begin(), aFillPos );
2785
2786 rXF.SetXmlIds( nBorderId, nFillId );
2787 rXF.SaveXml( rStrm );
2788}
2789
2790sal_uInt32 XclExpXFBuffer::FindXF( const ScPatternAttr& rPattern,
2791 sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak ) const
2792{
2793 if (nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND && nForceXclFont == EXC_FONT_NOTFOUND)
2794 {
2795 FindKey key1 { /*mbCellXF*/true, &rPattern.GetItemSet(), nForceScNumFmt, 0 };
2796 FindKey key2 { /*mbCellXF*/true, &rPattern.GetItemSet(), nForceScNumFmt, EXC_FONT_NOTFOUND };
2797 auto it1 = maXFFindMap.lower_bound(key1);
2798 if (it1 != maXFFindMap.end())
2799 {
2800 auto it2 = maXFFindMap.upper_bound(key2);
2801 for (auto it = it1; it != it2; ++it)
2802 for (auto const & nPos : it->second)
2803 if( maXFList.GetRecord( nPos )->Equals( rPattern, nForceScNumFmt, nForceXclFont, bForceLineBreak ) )
2804 return nPos;
2805 }
2806 }
2807 else if (nForceScNumFmt == NUMBERFORMAT_ENTRY_NOT_FOUND || nForceXclFont == EXC_FONT_NOTFOUND)
2808 {
2809 FindKey key1 { /*mbCellXF*/true, &rPattern.GetItemSet(), 0, 0 };
2810 FindKey key2 { /*mbCellXF*/true, &rPattern.GetItemSet(), NUMBERFORMAT_ENTRY_NOT_FOUND, EXC_FONT_NOTFOUND };
2811 auto it1 = maXFFindMap.lower_bound(key1);
2812 if (it1 != maXFFindMap.end())
2813 {
2814 auto it2 = maXFFindMap.upper_bound(key2);
2815 for (auto it = it1; it != it2; ++it)
2816 for (auto const & nPos : it->second)
2817 if( maXFList.GetRecord( nPos )->Equals( rPattern, nForceScNumFmt, nForceXclFont, bForceLineBreak ) )
2818 return nPos;
2819 }
2820 }
2821 else
2822 {
2823 FindKey key { /*mbCellXF*/true, &rPattern.GetItemSet(), nForceScNumFmt, nForceXclFont };
2824 auto it = maXFFindMap.find(key);
2825 if (it == maXFFindMap.end())
2826 return EXC_XFID_NOTFOUND;
2827 for (auto const & nPos : it->second)
2828 if( maXFList.GetRecord( nPos )->Equals( rPattern, nForceScNumFmt, nForceXclFont, bForceLineBreak ) )
2829 return nPos;
2830 }
2831 return EXC_XFID_NOTFOUND;
2832}
2833
2834sal_uInt32 XclExpXFBuffer::FindXF( const SfxStyleSheetBase& rStyleSheet ) const
2835{
2836 const SfxItemSet* pItemSet = &const_cast< SfxStyleSheetBase& >( rStyleSheet ).GetItemSet();
2837 FindKey key1 { /*mbCellXF*/false, pItemSet, 0, 0 };
2838 FindKey key2 { /*mbCellXF*/false, pItemSet, NUMBERFORMAT_ENTRY_NOT_FOUND, EXC_FONT_NOTFOUND };
2839 auto it1 = maXFFindMap.lower_bound(key1);
2840 auto it2 = maXFFindMap.upper_bound(key2);
2841 for (auto it = it1; it != it2; ++it)
2842 for (auto const & nPos : it->second)
2843 if( maXFList.GetRecord( nPos )->Equals( rStyleSheet ) )
2844 return nPos;
2845 return EXC_XFID_NOTFOUND;
2846}
2847
2848sal_uInt32 XclExpXFBuffer::FindBuiltInXF( sal_uInt8 nStyleId, sal_uInt8 nLevel ) const
2849{
2850 auto aIt = std::find_if(maBuiltInMap.begin(), maBuiltInMap.end(),
2851 [&nStyleId, nLevel](const XclExpBuiltInMap::value_type& rEntry) {
2852 return (rEntry.second.mnStyleId == nStyleId) && (rEntry.second.mnLevel == nLevel);
2853 });
2854 if (aIt != maBuiltInMap.end())
2855 return aIt->first;
2856 return EXC_XFID_NOTFOUND;
2857}
2858
2860{
2861 return { rRec.IsCellXF(), rRec.GetItemSet(), rRec.GetScNumFmt(), rRec.GetXclFont() };
2862}
2863
2864sal_uInt32 XclExpXFBuffer::InsertCellXF( const ScPatternAttr* pPattern, sal_Int16 nScript,
2865 sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak )
2866{
2867 const ScPatternAttr* pDefPattern = GetDoc().GetDefPattern();
2868 if( !pPattern )
2869 pPattern = pDefPattern;
2870
2871 // special handling for default cell formatting
2872 if( (pPattern == pDefPattern) && !bForceLineBreak &&
2873 (nForceScNumFmt == NUMBERFORMAT_ENTRY_NOT_FOUND) &&
2874 (nForceXclFont == EXC_FONT_NOTFOUND) )
2875 {
2876 // Is it the first try to insert the default cell format?
2877 bool& rbPredefined = maBuiltInMap[ EXC_XF_DEFAULTCELL ].mbPredefined;
2878 if( rbPredefined )
2879 {
2880 // remove old entry in find-map
2882 auto it = std::find(rPositions.begin(), rPositions.end(), EXC_XF_DEFAULTCELL);
2883 rPositions.erase(it);
2884 // replace default cell pattern
2885 XclExpXFRef xNewXF = new XclExpXF( GetRoot(), *pPattern, nScript );
2887 // and add new entry in find-map
2888 maXFFindMap[ToFindKey(*xNewXF)].push_back(EXC_XF_DEFAULTCELL);
2889 rbPredefined = false;
2890 }
2891 return GetDefCellXFId();
2892 }
2893
2894 sal_uInt32 nXFId = FindXF( *pPattern, nForceScNumFmt, nForceXclFont, bForceLineBreak );
2895 if( nXFId == EXC_XFID_NOTFOUND )
2896 {
2897 // not found - insert new cell XF
2898 if( maXFList.GetSize() < EXC_XFLIST_HARDLIMIT )
2899 {
2900 auto pNewExp = new XclExpXF(
2901 GetRoot(), *pPattern, nScript, nForceScNumFmt, nForceXclFont, bForceLineBreak );
2902 maXFList.AppendNewRecord( pNewExp );
2903 // do not set nXFId before the AppendNewRecord() call - it may insert 2 XFs (style+cell)
2904 nXFId = static_cast< sal_uInt32 >( maXFList.GetSize() - 1 );
2905 maXFFindMap[ToFindKey(*pNewExp)].push_back(nXFId);
2906 }
2907 else
2908 {
2909 // list full - fall back to default cell XF
2910 nXFId = GetDefCellXFId();
2911 }
2912 }
2913 return nXFId;
2914}
2915
2916sal_uInt32 XclExpXFBuffer::InsertStyleXF( const SfxStyleSheetBase& rStyleSheet )
2917{
2918 // *** try, if it is a built-in style - create new XF or replace existing predefined XF ***
2919
2920 sal_uInt8 nStyleId, nLevel;
2921 if( XclTools::GetBuiltInStyleId( nStyleId, nLevel, rStyleSheet.GetName() ) )
2922 {
2923 // try to find the built-in XF record (if already created in InsertDefaultRecords())
2924 sal_uInt32 nXFId = FindBuiltInXF( nStyleId, nLevel );
2925 if( nXFId == EXC_XFID_NOTFOUND )
2926 {
2927 // built-in style XF not yet created - do it now
2928 XclExpXFRef xXF = new XclExpXF( GetRoot(), rStyleSheet );
2929 nXFId = AppendBuiltInXFWithStyle( xXF, nStyleId, nLevel );
2930 // this new XF record is not predefined
2931 maBuiltInMap[ nXFId ].mbPredefined = false;
2932 }
2933 else
2934 {
2935 OSL_ENSURE( maXFList.HasRecord( nXFId ), "XclExpXFBuffer::InsertStyleXF - built-in XF not found" );
2936 // XF record still predefined? -> Replace with real XF
2937 bool& rbPredefined = maBuiltInMap[ nXFId ].mbPredefined;
2938 if( rbPredefined )
2939 {
2940 // remove old entry in find-map
2941 auto & rPositions = maXFFindMap[ToFindKey(*maXFList.GetRecord(nXFId))];
2942 auto it = std::find(rPositions.begin(), rPositions.end(), nXFId);
2943 rPositions.erase(it);
2944 // replace predefined built-in style (ReplaceRecord() deletes old record)
2945 XclExpXFRef pNewExp = new XclExpXF( GetRoot(), rStyleSheet );
2946 maXFList.ReplaceRecord( pNewExp, nXFId );
2947 // and add new entry in find-map
2948 maXFFindMap[ToFindKey(*pNewExp)].push_back(nXFId);
2949 rbPredefined = false;
2950 }
2951 }
2952
2953 // STYLE already inserted? (may be not, i.e. for RowLevel/ColLevel or Hyperlink styles)
2954 bool& rbHasStyleRec = maBuiltInMap[ nXFId ].mbHasStyleRec;
2955 if( !rbHasStyleRec )
2956 {
2957 maStyleList.AppendNewRecord( new XclExpStyle( nXFId, nStyleId, nLevel ) );
2958 rbHasStyleRec = true;
2959 }
2960
2961 return nXFId;
2962 }
2963
2964 // *** try to find the XF record of a user-defined style ***
2965
2966 sal_uInt32 nXFId = FindXF( rStyleSheet );
2967 if( nXFId == EXC_XFID_NOTFOUND )
2968 {
2969 // not found - insert new style XF and STYLE
2970 nXFId = static_cast< sal_uInt32 >( maXFList.GetSize() );
2971 if( nXFId < EXC_XFLIST_HARDLIMIT )
2972 {
2973 auto pNewExp = new XclExpXF( GetRoot(), rStyleSheet );
2974 maXFList.AppendNewRecord( pNewExp );
2975 // create the STYLE record
2976 if( !rStyleSheet.GetName().isEmpty() )
2977 maStyleList.AppendNewRecord( new XclExpStyle( nXFId, rStyleSheet.GetName() ) );
2978 maXFFindMap[ToFindKey(*pNewExp)].push_back(nXFId);
2979 }
2980 else
2981 // list full - fall back to default style XF
2983 }
2984 return nXFId;
2985}
2986
2988{
2989 SfxStyleSheetIterator aStyleIter( GetDoc().GetStyleSheetPool(), SfxStyleFamily::Para );
2990 for( SfxStyleSheetBase* pStyleSheet = aStyleIter.First(); pStyleSheet; pStyleSheet = aStyleIter.Next() )
2991 if( pStyleSheet->IsUserDefined() && !lclIsBuiltInStyle( pStyleSheet->GetName() ) )
2992 InsertStyleXF( *pStyleSheet );
2993}
2994
2995sal_uInt32 XclExpXFBuffer::AppendBuiltInXF( XclExpXFRef const & xXF, sal_uInt8 nStyleId, sal_uInt8 nLevel )
2996{
2997 sal_uInt32 nXFId = static_cast< sal_uInt32 >( maXFList.GetSize() );
2998 maXFList.AppendRecord( xXF );
2999 maXFFindMap[ToFindKey(*xXF)].push_back(nXFId);
3000 XclExpBuiltInInfo& rInfo = maBuiltInMap[ nXFId ];
3001 rInfo.mnStyleId = nStyleId;
3002 rInfo.mnLevel = nLevel;
3003 rInfo.mbPredefined = true;
3004 return nXFId;
3005}
3006
3008{
3009 sal_uInt32 nXFId = AppendBuiltInXF( xXF, nStyleId, nLevel );
3010 maStyleList.AppendNewRecord( new XclExpStyle( nXFId, nStyleId, nLevel ) );
3011 maBuiltInMap[ nXFId ].mbHasStyleRec = true; // mark existing STYLE record
3012 return nXFId;
3013}
3014
3016{
3017 XclExpCellArea aFill;
3018 aFill.mnPattern = EXC_PATT_NONE;
3019 return aFill;
3020}
3021
3023{
3024 XclExpCellArea aFill;
3026 aFill.mnForeColor = 0;
3027 aFill.mnBackColor = 0;
3028 return aFill;
3029}
3030
3032{
3033 maFills.push_back( lcl_GetPatternFill_None() );
3034 maFills.push_back( lcl_GetPatternFill_Gray125() );
3035
3036 // index 0: default style
3037 if( SfxStyleSheetBase* pDefStyleSheet = GetStyleSheetPool().Find( ScResId( STR_STYLENAME_STANDARD ), SfxStyleFamily::Para ) )
3038 {
3039 XclExpXFRef xDefStyle = new XclExpXF( GetRoot(), *pDefStyleSheet );
3040 sal_uInt32 nXFId = AppendBuiltInXFWithStyle( xDefStyle, EXC_STYLE_NORMAL );
3041 // mark this XF as not predefined, prevents overwriting
3042 maBuiltInMap[ nXFId ].mbPredefined = false;
3043 }
3044 else
3045 {
3046 OSL_FAIL( "XclExpXFBuffer::InsertDefaultRecords - default style not found" );
3047 XclExpXFRef xDefStyle = new XclExpDefaultXF( GetRoot(), false );
3048 xDefStyle->SetAllUsedFlags( true );
3050 }
3051
3052 // index 1-14: RowLevel and ColLevel styles (without STYLE records)
3053 XclExpDefaultXF aLevelStyle( GetRoot(), false );
3054 // RowLevel_1, ColLevel_1
3055 aLevelStyle.SetFont( 1 );
3056 AppendBuiltInXF( new XclExpDefaultXF( aLevelStyle ), EXC_STYLE_ROWLEVEL, 0 );
3057 AppendBuiltInXF( new XclExpDefaultXF( aLevelStyle ), EXC_STYLE_COLLEVEL, 0 );
3058 // RowLevel_2, ColLevel_2
3059 aLevelStyle.SetFont( 2 );
3060 AppendBuiltInXF( new XclExpDefaultXF( aLevelStyle ), EXC_STYLE_ROWLEVEL, 1 );
3061 AppendBuiltInXF( new XclExpDefaultXF( aLevelStyle ), EXC_STYLE_COLLEVEL, 1 );
3062 // RowLevel_3, ColLevel_3 ... RowLevel_7, ColLevel_7
3063 aLevelStyle.SetFont( 0 );
3064 for( sal_uInt8 nLevel = 2; nLevel < EXC_STYLE_LEVELCOUNT; ++nLevel )
3065 {
3066 AppendBuiltInXF( new XclExpDefaultXF( aLevelStyle ), EXC_STYLE_ROWLEVEL, nLevel );
3067 AppendBuiltInXF( new XclExpDefaultXF( aLevelStyle ), EXC_STYLE_COLLEVEL, nLevel );
3068 }
3069
3070 // index 15: default hard cell format, placeholder to be able to add more built-in styles
3073 maBuiltInMap[ EXC_XF_DEFAULTCELL ].mbPredefined = true;
3074
3075 // index 16-20: other built-in styles
3076 XclExpDefaultXF aFormatStyle( GetRoot(), false );
3077 aFormatStyle.SetFont( 1 );
3078 aFormatStyle.SetNumFmt( 43 );
3080 aFormatStyle.SetNumFmt( 41 );
3082 aFormatStyle.SetNumFmt( 44 );
3084 aFormatStyle.SetNumFmt( 42 );
3086 aFormatStyle.SetNumFmt( 9 );
3088
3089 // other built-in style XF records (i.e. Hyperlink styles) are created on demand
3090
3091 /* Insert the real default hard cell format -> 0 is document default pattern.
3092 Do it here (and not already above) to really have all built-in styles. */
3093 Insert( nullptr, GetDefApiScript() );
3094}
3095
3096void XclExpXFBuffer::AppendXFIndex( sal_uInt32 nXFId )
3097{
3098 OSL_ENSURE( nXFId < maXFIndexVec.size(), "XclExpXFBuffer::AppendXFIndex - XF ID out of range" );
3099 maXFIndexVec[ nXFId ] = static_cast< sal_uInt16 >( maSortedXFList.GetSize() );
3100 XclExpXFRef xXF = maXFList.GetRecord( nXFId );
3101 AddBorderAndFill( *xXF );
3103 OSL_ENSURE( maXFList.HasRecord( nXFId ), "XclExpXFBuffer::AppendXFIndex - XF not found" );
3104}
3105
3107{
3108 if( std::none_of( maBorders.begin(), maBorders.end(), XclExpBorderPred( rXF.GetBorderData() ) ) )
3109 {
3110 maBorders.push_back( rXF.GetBorderData() );
3111 }
3112
3113 if( std::none_of( maFills.begin(), maFills.end(), XclExpFillPred( rXF.GetAreaData() ) ) )
3114 {
3115 maFills.push_back( rXF.GetAreaData() );
3116 }
3117}
3118
3120 : XclExpRoot( rRoot ),
3121 mpKeywordTable( new NfKeywordTable )
3122{
3123 // Special number formatter for conversion.
3125 xFormatter->FillKeywordTableForExcel( *mpKeywordTable );
3126
3127 SCTAB nTables = rRoot.GetDoc().GetTableCount();
3128 sal_Int32 nDxfId = 0;
3129 for(SCTAB nTab = 0; nTab < nTables; ++nTab)
3130 {
3131 // Color filters
3132 std::vector<ScDBData*> pDBData = rRoot.GetDoc().GetDBCollection()->GetAllDBsFromTab(nTab);
3133 for (auto& pData : pDBData)
3134 {
3135 ScRange aRange;
3136 pData->GetArea(aRange);
3137 for (auto nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); nCol++)
3138 {
3139 ScFilterEntries aFilterEntries;
3140 rRoot.GetDoc().GetFilterEntriesArea(nCol, aRange.aStart.Row(),
3141 aRange.aEnd.Row(), nTab, true, aFilterEntries);
3142
3143 // Excel has all filter values stored as foreground colors
3144 // Does not matter it is text color or cell background color
3145 for (auto& rColor : aFilterEntries.getBackgroundColors())
3146 {
3147 if (!maColorToDxfId.emplace(rColor, nDxfId).second)
3148 continue;
3149
3150 std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(rColor, 0));
3151 maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
3152 nDxfId++;
3153 }
3154 for (auto& rColor : aFilterEntries.getTextColors())
3155 {
3156 if (!maColorToDxfId.emplace(rColor, nDxfId).second)
3157 continue;
3158
3159 std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(rColor, 0));
3160 maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
3161 nDxfId++;
3162 }
3163 }
3164 }
3165
3166 // Conditional formatting
3167 ScConditionalFormatList* pList = rRoot.GetDoc().GetCondFormList(nTab);
3168 if (pList)
3169 {
3170 for (const auto& rxItem : *pList)
3171 {
3172 size_t nEntryCount = rxItem->size();
3173 for (size_t nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry)
3174 {
3175 const ScFormatEntry* pFormatEntry = rxItem->GetEntry(nFormatEntry);
3176 if (!pFormatEntry
3177 || (pFormatEntry->GetType() != ScFormatEntry::Type::Condition
3178 && pFormatEntry->GetType() != ScFormatEntry::Type::Date
3179 && pFormatEntry->GetType() != ScFormatEntry::Type::ExtCondition))
3180 continue;
3181
3182 OUString aStyleName;
3183 if (pFormatEntry->GetType() == ScFormatEntry::Type::Condition
3184 || pFormatEntry->GetType() == ScFormatEntry::Type::ExtCondition)
3185 {
3186 const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry);
3187 aStyleName= pEntry->GetStyle();
3188 }
3189 else
3190 {
3191 const ScCondDateFormatEntry* pEntry = static_cast<const ScCondDateFormatEntry*>(pFormatEntry);
3192 aStyleName = pEntry->GetStyleName();
3193 }
3194
3195 if (maStyleNameToDxfId.emplace(aStyleName, nDxfId).second)
3196 {
3197 SfxStyleSheetBase* pStyle = rRoot.GetDoc().GetStyleSheetPool()->Find(aStyleName, SfxStyleFamily::Para);
3198 if(!pStyle)
3199 continue;
3200
3201 SfxItemSet& rSet = pStyle->GetItemSet();
3202
3203 std::unique_ptr<XclExpCellBorder> pBorder(new XclExpCellBorder);
3204 if (!pBorder->FillFromItemSet( rSet, GetPalette(), GetBiff()) )
3205 {
3206 pBorder.reset();
3207 }
3208
3209 std::unique_ptr<XclExpCellAlign> pAlign(new XclExpCellAlign);
3210 if (!pAlign->FillFromItemSet(rRoot, rSet, false, GetBiff()))
3211 {
3212 pAlign.reset();
3213 }
3214
3215 std::unique_ptr<XclExpCellProt> pCellProt(new XclExpCellProt);
3216 if (!pCellProt->FillFromItemSet( rSet ))
3217 {
3218 pCellProt.reset();
3219 }
3220
3221 std::unique_ptr<XclExpColor> pColor(new XclExpColor);
3222 if(!pColor->FillFromItemSet( rSet ))
3223 {
3224 pColor.reset();
3225 }
3226
3227 std::unique_ptr<XclExpDxfFont> pFont(new XclExpDxfFont(rRoot, rSet));
3228
3229 std::unique_ptr<XclExpNumFmt> pNumFormat;
3230 if( const SfxUInt32Item *pPoolItem = rSet.GetItemIfSet( ATTR_VALUE_FORMAT ) )
3231 {
3232 sal_uInt32 nScNumFmt = pPoolItem->GetValue();
3233 sal_Int32 nXclNumFmt = GetRoot().GetNumFmtBuffer().Insert(nScNumFmt);
3234 pNumFormat.reset(new XclExpNumFmt( nScNumFmt, nXclNumFmt, GetNumberFormatCode( *this, nScNumFmt, xFormatter.get(), mpKeywordTable.get() )));
3235 }
3236
3237 maDxf.push_back(std::make_unique<XclExpDxf>( rRoot, std::move(pAlign), std::move(pBorder),
3238 std::move(pFont), std::move(pNumFormat), std::move(pCellProt), std::move(pColor) ));
3239 ++nDxfId;
3240 }
3241
3242 }
3243 }
3244 }
3245 }
3246}
3247
3248sal_Int32 XclExpDxfs::GetDxfId( const OUString& rStyleName ) const
3249{
3250 std::map<OUString, sal_Int32>::const_iterator itr = maStyleNameToDxfId.find(rStyleName);
3251 if(itr!= maStyleNameToDxfId.end())
3252 return itr->second;
3253 return -1;
3254}
3255
3256sal_Int32 XclExpDxfs::GetDxfByColor(Color aColor) const
3257{
3258 std::map<Color, sal_Int32>::const_iterator itr = maColorToDxfId.find(aColor);
3259 if (itr != maColorToDxfId.end())
3260 return itr->second;
3261 return -1;
3262}
3263
3265{
3266 maColorToDxfId.emplace(aColor, maDxf.size());
3267
3268 std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(aColor, 0));
3269 maDxf.push_back(std::make_unique<XclExpDxf>(GetRoot(), std::move(pExpCellArea)));
3270}
3271
3273{
3274 if(maDxf.empty())
3275 return;
3276
3277 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
3278 rStyleSheet->startElement(XML_dxfs, XML_count, OString::number(maDxf.size()));
3279
3280 for ( auto& rxDxf : maDxf )
3281 {
3282 rxDxf->SaveXml( rStrm );
3283 }
3284
3285 rStyleSheet->endElement( XML_dxfs );
3286}
3287
3289{
3290 for (auto& rxDxf : maDxf)
3291 {
3292 rxDxf->SetFinalColors();
3293 }
3294}
3295
3296XclExpDxf::XclExpDxf( const XclExpRoot& rRoot, std::unique_ptr<XclExpCellAlign> pAlign, std::unique_ptr<XclExpCellBorder> pBorder,
3297 std::unique_ptr<XclExpDxfFont> pFont, std::unique_ptr<XclExpNumFmt> pNumberFmt, std::unique_ptr<XclExpCellProt> pProt,
3298 std::unique_ptr<XclExpColor> pColor)
3299 : XclExpRoot( rRoot ),
3300 mpAlign(std::move(pAlign)),
3301 mpBorder(std::move(pBorder)),
3302 mpFont(std::move(pFont)),
3303 mpNumberFmt(std::move(pNumberFmt)),
3304 mpProt(std::move(pProt)),
3305 mpColor(std::move(pColor))
3306{
3307}
3308
3309XclExpDxf::XclExpDxf(const XclExpRoot& rRoot, std::unique_ptr<XclExpCellArea> pCellArea)
3310 : XclExpRoot(rRoot)
3311 , mpCellArea(std::move(pCellArea))
3312{
3313}
3314
3316{
3317}
3318
3320{
3321 if (mpBorder)
3322 {
3323 mpBorder->SetFinalColors(GetPalette());
3324 }
3325}
3326
3328{
3329 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
3330 rStyleSheet->startElement(XML_dxf);
3331
3332 if (mpFont)
3333 mpFont->SaveXml(rStrm);
3334 if (mpNumberFmt)
3335 mpNumberFmt->SaveXml(rStrm);
3336 if (mpColor)
3337 mpColor->SaveXml(rStrm);
3338 if (mpAlign)
3339 mpAlign->SaveXml(rStrm);
3340 if (mpBorder)
3341 mpBorder->SaveXml(rStrm);
3342 if (mpProt)
3343 mpProt->SaveXml(rStrm);
3344 if (mpCellArea)
3345 mpCellArea->SaveXml(rStrm);
3346 rStyleSheet->endElement( XML_dxf );
3347}
3348
3350{
3351 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
3352 rStyleSheet->startElementNS( XML_x14, XML_dxf );
3353
3354 if (mpFont)
3355 mpFont->SaveXml(rStrm);
3356 if (mpNumberFmt)
3357 mpNumberFmt->SaveXml(rStrm);
3358 if (mpColor)
3359 mpColor->SaveXml(rStrm);
3360 if (mpAlign)
3361 mpAlign->SaveXml(rStrm);
3362 if (mpBorder)
3363 mpBorder->SaveXml(rStrm);
3364 if (mpProt)
3365 mpProt->SaveXml(rStrm);
3366 rStyleSheet->endElementNS( XML_x14, XML_dxf );
3367}
3368
3369
3371 : XclExpRoot( rRoot )
3372{
3373}
3374
3376{
3377 sax_fastparser::FSHelperPtr aStyleSheet = rStrm.CreateOutputStream(
3378 "xl/styles.xml",
3379 u"styles.xml",
3380 rStrm.GetCurrentStream()->getOutputStream(),
3381 "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
3382 oox::getRelationship(Relationship::STYLES));
3383 rStrm.PushStream( aStyleSheet );
3384
3385 aStyleSheet->startElement(XML_styleSheet, XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)));
3386
3387 CreateRecord( EXC_ID_FORMATLIST )->SaveXml( rStrm );
3388 CreateRecord( EXC_ID_FONTLIST )->SaveXml( rStrm );
3389 CreateRecord( EXC_ID_XFLIST )->SaveXml( rStrm );
3390 CreateRecord( EXC_ID_DXFS )->SaveXml( rStrm );
3391 CreateRecord( EXC_ID_PALETTE )->SaveXml( rStrm );
3392
3393 aStyleSheet->endElement( XML_styleSheet );
3394
3395 rStrm.PopStream();
3396}
3397
3398/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::BColor maColor
sal_Int32 mnWeight
bool ScHasPriority(const ::editeng::SvxBorderLine *pThis, const ::editeng::SvxBorderLine *pOther)
General Help Function.
Definition: attrib.cxx:49
OUString maName
sal_uInt8 GetBlue() const
void SetGreen(sal_uInt8 nGreen)
void SetRed(sal_uInt8 nRed)
sal_uInt8 GetRed() const
bool IsTransparent() const
sal_uInt8 GetGreen() const
void SetBlue(sal_uInt8 nBlue)
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
const OUString & GetStyleName() const
Definition: conditio.hxx:514
const OUString & GetStyle() const
Definition: conditio.hxx:473
size_t size() const
Definition: conditio.cxx:2282
std::vector< ScDBData * > GetAllDBsFromTab(SCTAB nTab)
Definition: dbdata.cxx:1620
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
Definition: document.cxx:6045
SC_DLLPUBLIC void GetFilterEntriesArea(SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bCaseSens, ScFilterEntries &rFilterEntries)
Entries for Filter dialog.
Definition: documen3.cxx:1608
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:827
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6055
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
Definition: documen4.cxx:860
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
virtual Type GetType() const =0
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:165
static void fillColor(model::ComplexColor &rComplexColor, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const SfxItemSet *pCondSet=nullptr, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Definition: patattr.cxx:435
static ScDxfFont GetDxfFont(const SfxItemSet &rSet, SvtScriptType nScript)
Definition: patattr.cxx:546
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
static void fillFontOnly(vcl::Font &rFont, const SfxItemSet &rItemSet, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE)
Static helper function to fill a font object from the passed item set.
Definition: patattr.cxx:266
bool GetHideFormula() const
Definition: attrib.hxx:150
bool GetHideCell() const
Definition: attrib.hxx:152
bool GetProtection() const
Definition: attrib.hxx:148
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
static bool CheckItem(const SfxItemSet &rItemSet, sal_uInt16 nWhichId, bool bDeep)
Returns true, if the passed item set contains the item.
Definition: ftools.cxx:200
static bool CheckItems(const SfxItemSet &rItemSet, const sal_uInt16 *pnWhichIds, bool bDeep)
Returns true, if the passed item set contains at least one of the items.
Definition: ftools.cxx:205
static rtl_TextEncoding GetSystemTextEncoding()
Returns system text encoding for byte string conversion.
Definition: ftools.cxx:116
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxItemSet * GetParent() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
const OUString & GetName() const
virtual SfxItemSet & GetItemSet()
virtual SfxStyleSheetBase * Next()
virtual SfxStyleSheetBase * First()
OUString GetFormatStringForExcel(sal_uInt32 nKey, const NfKeywordTable &rKeywords, SvNumberFormatter &rTempFormatter) const
sal_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge=LANGUAGE_DONTKNOW)
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetRight() const
const editeng::SvxBorderLine * GetLeft() const
const editeng::SvxBorderLine * GetBottom() const
const Color & GetColor() const
const model::ComplexColor & getComplexColor() const
const editeng::SvxBorderLine * GetLine() const
Stores all default colors for a specific BIFF version.
Definition: xlstyle.hxx:252
sal_uInt32 GetColorCount() const
Returns the color count in the current palette.
Definition: xlstyle.hxx:257
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
Used as placeholder for font index 4, which is not used in Excel.
Definition: xestyle.hxx:194
virtual bool Equals(const XclFontData &rFontData, sal_uInt32 nHash) const override
Returns always false to never find this font while searching the font list.
Definition: xestyle.cxx:1161
virtual void Save(XclExpStream &rStrm) override
Skips writing this record.
Definition: xestyle.cxx:1166
XclExpBlindFont(const XclExpRoot &rRoot)
Definition: xestyle.cxx:1156
Represents a default XF record.
Definition: xestyle.hxx:536
void SetNumFmt(sal_uInt16 nXclNumFmt)
Sets the Excel number format index.
Definition: xestyle.cxx:2347
void SetFont(sal_uInt16 nXclFont)
Sets the Excel font index.
Definition: xestyle.cxx:2341
XclExpDefaultXF(const XclExpRoot &rRoot, bool bCellXF)
Definition: xestyle.cxx:2336
XclExpDxfFont(const XclExpRoot &rRoot, const SfxItemSet &rItemSet)
Definition: xestyle.cxx:1022
ScDxfFont maDxfData
Definition: xestyle.hxx:189
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:1070
std::unique_ptr< XclExpNumFmt > mpNumberFmt
Definition: xestyle.hxx:752
std::unique_ptr< XclExpCellAlign > mpAlign
Definition: xestyle.hxx:749
std::unique_ptr< XclExpCellProt > mpProt
Definition: xestyle.hxx:753
std::unique_ptr< XclExpCellArea > mpCellArea
Definition: xestyle.hxx:755
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:3327
void SaveXmlExt(XclExpXmlStream &rStrm)
Definition: xestyle.cxx:3349
virtual ~XclExpDxf() override
Definition: xestyle.cxx:3315
std::unique_ptr< XclExpDxfFont > mpFont
Definition: xestyle.hxx:751
XclExpDxf(const XclExpRoot &rRoot, std::unique_ptr< XclExpCellAlign > pAlign, std::unique_ptr< XclExpCellBorder > pBorder, std::unique_ptr< XclExpDxfFont > pFont, std::unique_ptr< XclExpNumFmt > pNumberFmt, std::unique_ptr< XclExpCellProt > pProt, std::unique_ptr< XclExpColor > pColor)
Definition: xestyle.cxx:3296
std::unique_ptr< XclExpCellBorder > mpBorder
Definition: xestyle.hxx:750
void SetFinalColors()
Definition: xestyle.cxx:3319
std::unique_ptr< XclExpColor > mpColor
Definition: xestyle.hxx:754
sal_Int32 GetDxfByColor(Color aColor) const
Definition: xestyle.cxx:3256
void addColor(Color aColor)
Definition: xestyle.cxx:3264
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:3272
XclExpDxfs(const XclExpRoot &rRoot)
Definition: xestyle.cxx:3119
DxfContainer maDxf
Definition: xestyle.hxx:774
std::map< OUString, sal_Int32 > maStyleNameToDxfId
Definition: xestyle.hxx:772
void Finalize()
Definition: xestyle.cxx:3288
std::unique_ptr< NfKeywordTable > mpKeywordTable
Definition: xestyle.hxx:775
sal_Int32 GetDxfId(const OUString &rName) const
Definition: xestyle.cxx:3248
std::map< Color, sal_Int32 > maColorToDxfId
Definition: xestyle.hxx:773
XclExpFontList maFontList
Definition: xestyle.hxx:245
XclExpFontBuffer(const XclExpRoot &rRoot)
Definition: xestyle.cxx:1171
size_t mnXclMaxSize
List of all FONT records.
Definition: xestyle.hxx:246
sal_uInt16 Insert(const XclFontData &rFontData, XclExpColorType eColorType, bool bAppFont=false)
Inserts a new font with the passed font data into the buffer if not present.
Definition: xestyle.cxx:1195
const XclExpFont * GetFont(sal_uInt16 nXclFont) const
Returns the specified font from font list.
Definition: xestyle.cxx:1185
void InitDefaultFonts()
Initializes the default fonts for the current BIFF version.
Definition: xestyle.cxx:1261
size_t Find(const XclFontData &rFontData)
Tries to find the passed font and returns the current list index.
Definition: xestyle.cxx:1307
const XclFontData & GetAppFontData() const
Returns the application font data of this file, needed e.g.
Definition: xestyle.cxx:1190
virtual void Save(XclExpStream &rStrm) override
Writes all FONT records contained in this buffer.
Definition: xestyle.cxx:1241
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:1246
Stores all data of an Excel font and provides export of FONT records.
Definition: xestyle.hxx:156
virtual bool Equals(const XclFontData &rFontData, sal_uInt32 nHash) const
Compares this font with the passed font data.
Definition: xestyle.cxx:977
sal_uInt32 mnHash
Unique color ID for text color.
Definition: xestyle.hxx:178
XclExpFont(const XclExpRoot &rRoot, const XclFontData &rFontData, XclExpColorType eColorType)
Definition: xestyle.cxx:962
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:982
XclFontData maData
Definition: xestyle.hxx:176
sal_uInt32 mnColorId
All font attributes.
Definition: xestyle.hxx:177
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the FONT record.
Definition: xestyle.cxx:993
const XclFontData & GetFontData() const
Returns read-only access to font data.
Definition: xestyle.hxx:162
OUString GetFormatCode(sal_uInt32 nScNumFmt)
Definition: xestyle.cxx:1424
XclExpNumFmtBuffer(const XclExpRoot &rRoot)
Definition: xestyle.cxx:1339
sal_uInt16 Insert(sal_uInt32 nScNumFmt)
Inserts a number format into the format buffer.
Definition: xestyle.cxx:1359
void WriteFormatRecord(XclExpStream &rStrm, sal_uInt16 nXclNumFmt, const OUString &rFormatStr)
Writes the FORMAT record with index nXclIx and format string rFormatStr.
Definition: xestyle.cxx:1397
virtual ~XclExpNumFmtBuffer() override
Definition: xestyle.cxx:1355
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:1383
XclExpNumFmtVec maFormatMap
Special number formatter for conversion.
Definition: xestyle.hxx:297
std::unique_ptr< NfKeywordTable > mpKeywordTable
Maps core formats to Excel indexes.
Definition: xestyle.hxx:298
sal_uInt16 mnXclOffset
Key for standard number format.
Definition: xestyle.hxx:300
virtual void Save(XclExpStream &rStrm) override
Writes all FORMAT records contained in this buffer.
Definition: xestyle.cxx:1377
SvNumberFormatterPtr mxFormatter
Definition: xestyle.hxx:296
XclListColorListRef mxColorList
The default palette for the current BIFF version.
Definition: xestyle.cxx:304
XclExpPaletteImpl(const XclDefaultPalette &rDefPal)
Definition: xestyle.cxx:315
sal_uInt32 GetNearestListColor(const Color &rColor, sal_uInt32 nIgnore) const
Returns the list index of the color nearest to rColor.
Definition: xestyle.cxx:674
bool IsDefaultPalette() const
Returns true, if all colors of the palette are equal to default palette colors.
Definition: xestyle.cxx:471
static sal_uInt16 GetXclIndex(sal_uInt32 nIndex)
Returns the Excel index of a 0-based color index.
Definition: xestyle.cxx:262
void ReduceLeastUsedColor()
Reduction of one color using advanced color merging based on color weighting.
Definition: xestyle.cxx:625
sal_uInt32 GetLeastUsedListColor() const
Finds the least used color and returns its current list index.
Definition: xestyle.cxx:656
std::vector< XclColorIdData > maColorIdDataVec
Working color list.
Definition: xestyle.cxx:306
sal_uInt32 mnLastIdx
Contains resulting colors to export.
Definition: xestyle.cxx:309
sal_Int32 GetNearPaletteColors(sal_uInt32 &rnFirst, sal_uInt32 &rnSecond, const Color &rColor) const
Returns in rnFirst and rnSecond the palette indexes of the two colors nearest to rColor.
Definition: xestyle.cxx:728
Color GetColor(sal_uInt16 nXclIndex) const
Returns the RGB color for a (non-zero-based) Excel palette entry.
Definition: xestyle.cxx:460
void GetMixedColors(sal_uInt16 &rnXclForeIx, sal_uInt16 &rnXclBackIx, sal_uInt8 &rnXclPattern, sal_uInt32 nForeColorId, sal_uInt32 nBackColorId) const
Returns a foreground and background color for the two passed color IDs.
Definition: xestyle.cxx:412
std::vector< XclPaletteColor > maPalette
Data of all CIDs.
Definition: xestyle.cxx:308
const Color & GetOriginalColor(sal_uInt32 nColorId) const
Returns the original inserted color represented by the color ID nColorId.
Definition: xestyle.cxx:500
void RawReducePalette(sal_uInt32 nPass)
Raw and fast reduction of the palette.
Definition: xestyle.cxx:560
std::shared_ptr< XclListColorList > XclListColorListRef
Definition: xestyle.cxx:301
sal_uInt32 InsertColor(const Color &rColor, XclExpColorType eType, sal_uInt16 nAutoDefault=0)
Inserts the color into the list and updates weighting.
Definition: xestyle.cxx:329
sal_uInt16 GetColorIndex(sal_uInt32 nColorId) const
Returns the Excel palette index of the color with passed color ID.
Definition: xestyle.cxx:402
void Finalize()
Reduces the color list to the maximum count of the current BIFF version.
Definition: xestyle.cxx:348
void WriteBody(XclExpStream &rStrm)
Writes the color list (contents of the palette record) to the passed stream.
Definition: xestyle.cxx:479
const XclDefaultPalette & mrDefPal
Definition: xestyle.cxx:303
static sal_uInt32 GetColorIdFromIndex(sal_uInt16 nIndex)
Returns the color ID representing a fixed Excel palette index (i.e.
Definition: xestyle.cxx:343
XclListColor * CreateListEntry(const Color &rColor, sal_uInt32 nIndex)
Creates and inserts a new color list entry at the specified list position.
Definition: xestyle.cxx:553
void SaveXml(XclExpXmlStream &rStrm)
Definition: xestyle.cxx:486
std::vector< std::unique_ptr< XclListColor > > XclListColorList
Definition: xestyle.cxx:300
XclListColor * SearchListEntry(const Color &rColor, sal_uInt32 &rnIndex)
Searches for rColor, returns the ordered insertion index for rColor in rnIndex.
Definition: xestyle.cxx:507
sal_Int32 GetNearestPaletteColor(sal_uInt32 &rnIndex, const Color &rColor) const
Returns in rnIndex the palette index of the color nearest to rColor.
Definition: xestyle.cxx:705
Stores all used colors in the document.
Definition: xestyle.hxx:77
sal_uInt32 InsertColor(const Color &rColor, XclExpColorType eType, sal_uInt16 nAutoDefault=0)
Inserts the color into the list and updates weighting.
Definition: xestyle.cxx:768
sal_uInt16 GetColorIndex(sal_uInt32 nColorId) const
Returns the Excel palette index of the color with passed color ID.
Definition: xestyle.cxx:783
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:806
Color GetColor(sal_uInt16 nXclIndex) const
Returns the color for a (non-zero-based) Excel palette entry.
Definition: xestyle.cxx:795
void Finalize()
Reduces the color list to the maximum count of the current BIFF version.
Definition: xestyle.cxx:778
void GetMixedColors(sal_uInt16 &rnXclForeIx, sal_uInt16 &rnXclBackIx, sal_uInt8 &rnXclPattern, sal_uInt32 nForeColorId, sal_uInt32 nBackColorId) const
Returns a foreground and background color for the two passed color IDs.
Definition: xestyle.cxx:788
static sal_uInt32 GetColorIdFromIndex(sal_uInt16 nIndex)
Returns the color ID representing a fixed Excel palette index (i.e.
Definition: xestyle.cxx:773
virtual void Save(XclExpStream &rStrm) override
Saves the PALETTE record, if it differs from the default palette.
Definition: xestyle.cxx:800
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the PALETTE record.
Definition: xestyle.cxx:812
virtual ~XclExpPalette() override
Definition: xestyle.cxx:764
XclExpPaletteImplRef mxImpl
Definition: xestyle.hxx:117
XclExpPalette(const XclExpRoot &rRoot)
Definition: xestyle.cxx:756
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xerecord.hxx:382
rtl::Reference< XclExpXF > RecordRefType
Definition: xerecord.hxx:324
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
Definition: xerecord.hxx:361
bool HasRecord(size_t nPos) const
Returns true, if the passed index points to an exiting record.
Definition: xerecord.hxx:330
size_t GetSize() const
Definition: xerecord.hxx:327
bool IsEmpty() const
Definition: xerecord.hxx:326
void ReplaceRecord(RecType *pRec, size_t nPos)
Replaces the record at the specified position from the list with the passed record.
Definition: xerecord.hxx:355
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
Definition: xerecord.hxx:375
void AppendRecord(RecType *pRec)
Appends a record to the list.
Definition: xerecord.hxx:348
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Definition: xerecord.hxx:333
Base class for single records with any content.
Definition: xerecord.hxx:143
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: xerecord.cxx:150
void SetRecHeader(sal_uInt16 nRecId, std::size_t nRecSize)
Sets record ID and size with one call.
Definition: xerecord.cxx:140
void SetRecSize(std::size_t nRecSize)
Sets a new record size prediction.
Definition: xerecord.hxx:163
Access to global data from other classes.
Definition: xeroot.hxx:113
XclExpFontBuffer & GetFontBuffer() const
Returns the font buffer.
Definition: xeroot.cxx:112
XclExpNumFmtBuffer & GetNumFmtBuffer() const
Returns the number format buffer.
Definition: xeroot.cxx:118
XclExpRecordRef CreateRecord(sal_uInt16 nRecId) const
Returns the reference to a record (or record list) representing a root object.
Definition: xeroot.cxx:282
XclExpPalette & GetPalette() const
Returns the color buffer.
Definition: xeroot.cxx:106
XclExpXFBuffer & GetXFBuffer() const
Returns the cell formatting attributes buffer.
Definition: xeroot.cxx:124
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xeroot.hxx:118
This class is used to export Excel record streams.
Definition: xestream.hxx:73
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:48
void AssignByte(std::u16string_view rString, rtl_TextEncoding eTextEnc, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Assigns an unformatted string, converts this object to a BIFF2-BIFF7 byte string.
Definition: xestring.cxx:121
void Assign(const OUString &rString, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Assigns an unformatted string, converts this object to a BIFF8 Unicode string.
Definition: xestring.cxx:111
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
Definition: xestring.cxx:249
Represents a STYLE record containing the data of a cell style.
Definition: xestyle.hxx:549
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the STYLE record.
Definition: xestyle.cxx:2376
sal_uInt8 mnStyleId
XF identifier for style formatting.
Definition: xestyle.hxx:566
XclExpXFId maXFId
Name of the cell style.
Definition: xestyle.hxx:565
sal_uInt8 mnLevel
Built-in style identifier.
Definition: xestyle.hxx:567
bool IsBuiltIn() const
Returns true, if this record represents an Excel built-in style.
Definition: xestyle.hxx:555
XclExpStyle(sal_uInt32 nXFId, OUString aStyleName)
Definition: xestyle.cxx:2353
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:2411
OUString maName
Definition: xestyle.hxx:564
Stores all XF records (cell formats and cell styles) in the document.
Definition: xestyle.hxx:586
XclExpXFList maXFList
Definition: xestyle.hxx:720
sal_uInt32 InsertCellXF(const ScPatternAttr *pPattern, sal_Int16 nScript, sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak)
Tries to find the XF record containing the passed format or inserts a new record.
Definition: xestyle.cxx:2864
void Finalize()
Reduces the XF record list to the maximum allowed number of records.
Definition: xestyle.cxx:2569
void AppendXFIndex(sal_uInt32 nXFId)
Appends a XF index to the internal ID<->index maps.
Definition: xestyle.cxx:3096
virtual void Save(XclExpStream &rStrm) override
Writes all XF records contained in this buffer.
Definition: xestyle.cxx:2692
void AddBorderAndFill(const XclExpXF &rXF)
Definition: xestyle.cxx:3106
sal_uInt32 InsertWithNumFmt(const ScPatternAttr *pPattern, sal_Int16 nScript, sal_uInt32 nForceScNumFmt, bool bForceLineBreak)
Finds or creates a cell XF record for the passed item set, with custom number format.
Definition: xestyle.cxx:2544
sal_uInt32 FindXF(const ScPatternAttr &rPattern, sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak) const
Returns the XF ID of the cell XF containing the passed format.
Definition: xestyle.cxx:2790
XclExpXFBuffer(const XclExpRoot &rRoot)
Definition: xestyle.cxx:2522
sal_uInt32 InsertStyleXF(const SfxStyleSheetBase &rStyleSheet)
Inserts the passed cell style.
Definition: xestyle.cxx:2916
XclExpRecordList< XclExpStyle > maStyleList
map of itemset to vector of positions, to speed up find
Definition: xestyle.hxx:724
XclExpXFList maSortedXFList
Maps XF IDs to OOXML Cell indexes.
Definition: xestyle.hxx:729
XclExpFillList maFills
List of borders used by XF records.
Definition: xestyle.hxx:731
ScfUInt16Vec maXFIndexVec
Contained elements describe built-in XFs.
Definition: xestyle.hxx:726
static sal_uInt32 GetXFIdFromIndex(sal_uInt16 nXFIndex)
Returns the XF identifier representing a fixed Excel XF index (e.g.
Definition: xestyle.cxx:2554
sal_uInt32 FindBuiltInXF(sal_uInt8 nStyleId, sal_uInt8 nLevel) const
Returns the XF ID of a built-in style XF, searches by style identifier.
Definition: xestyle.cxx:2848
sal_uInt32 InsertWithFont(const ScPatternAttr *pPattern, sal_Int16 nScript, sal_uInt16 nForceXclFont, bool bForceLineBreak)
Finds or creates a cell XF record for the passed item set.
Definition: xestyle.cxx:2538
ScfUInt16Vec maCellIndexes
Maps XF IDs to OOXML Style indexes.
Definition: xestyle.hxx:728
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:2715
XclExpBuiltInMap maBuiltInMap
List of all STYLE records.
Definition: xestyle.hxx:725
sal_Int32 GetXmlStyleIndex(sal_uInt32 nXFId) const
Definition: xestyle.cxx:2676
XclExpBorderList maBorders
List of XF records in XF index order.
Definition: xestyle.hxx:730
static sal_uInt32 GetDefCellXFId()
Returns the XF identifier representing the default cell XF.
Definition: xestyle.cxx:2559
static FindKey ToFindKey(XclExpXF const &)
Definition: xestyle.cxx:2859
void InsertUserStyles()
Inserts an XF and a STYLE record for all user defined style sheets.
Definition: xestyle.cxx:2987
sal_uInt32 Insert(const ScPatternAttr *pPattern, sal_Int16 nScript)
Finds or creates a cell XF record for the passed item set.
Definition: xestyle.cxx:2533
const XclExpXF * GetXFById(sal_uInt32 nXFId) const
Returns an XF record by its unique identifier.
Definition: xestyle.cxx:2564
void InsertDefaultRecords()
Inserts all default XF and STYLE records.
Definition: xestyle.cxx:3031
XclExpXFList::RecordRefType XclExpXFRef
Definition: xestyle.hxx:643
void SaveXFXml(XclExpXmlStream &rStrm, XclExpXF &rXF)
Definition: xestyle.cxx:2771
ScfUInt16Vec maStyleIndexes
Maps XF IDs to XF indexes.
Definition: xestyle.hxx:727
std::map< FindKey, std::vector< sal_uInt32 > > maXFFindMap
List of all XF records.
Definition: xestyle.hxx:722
sal_uInt16 GetXFIndex(sal_uInt32 nXFId) const
Returns the Excel XF index of the XF record with passed XF ID.
Definition: xestyle.cxx:2666
sal_uInt32 AppendBuiltInXFWithStyle(XclExpXFRef const &xXF, sal_uInt8 nStyleId, sal_uInt8 nLevel=EXC_STYLE_NOLEVEL)
Inserts a built-in XF and STYLE record and returns the XF ID.
Definition: xestyle.cxx:3007
sal_uInt32 InsertStyle(const SfxStyleSheetBase *pStyleSheet)
Inserts the passed cell style.
Definition: xestyle.cxx:2549
void Initialize()
Inserts predefined built-in styles and user-defined styles.
Definition: xestyle.cxx:2527
sal_uInt32 AppendBuiltInXF(XclExpXFRef const &xXF, sal_uInt8 nStyleId, sal_uInt8 nLevel=EXC_STYLE_NOLEVEL)
Inserts a built-in XF record without a STYLE record and returns the XF ID.
Definition: xestyle.cxx:2995
sal_Int32 GetXmlCellIndex(sal_uInt32 nXFId) const
Definition: xestyle.cxx:2684
Represents an XF record which contains all formatting data of a cell or cell style.
Definition: xestyle.hxx:438
sal_uInt32 GetScNumFmt() const
Definition: xestyle.hxx:486
XclExpCellArea maArea
Border line style.
Definition: xestyle.hxx:498
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:2296
bool Equals(const ScPatternAttr &rPattern, sal_uInt32 nScForceNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak) const
Returns true, if this XF record represents the passed cell formatting.
Definition: xestyle.cxx:2140
sal_uInt8 GetUsedFlags() const
Returns the bits specifying the used attributes.
Definition: xestyle.cxx:2229
sal_uInt16 mnXclNumFmt
Excel font index.
Definition: xestyle.hxx:502
sal_uInt16 GetXclFont() const
Definition: xestyle.hxx:487
void Init(const SfxItemSet &rItemSet, sal_Int16 nScript, sal_uInt32 nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak, bool bDefStyle)
Fills all members from the passed item set.
Definition: xestyle.cxx:2178
sal_uInt32 mnScNumFmt
XF ID of parent XF record.
Definition: xestyle.hxx:500
const XclExpCellAlign & GetAlignmentData() const
Returns the alignment settings of this XF.
Definition: xestyle.hxx:456
void WriteBody5(XclExpStream &rStrm)
Definition: xestyle.cxx:2243
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the XF record.
Definition: xestyle.cxx:2277
void SetFinalColors()
Sets the resulting Excel palette index from all used color IDs (border and area).
Definition: xestyle.cxx:2154
void InitDefault()
Initializes with default values.
Definition: xestyle.cxx:2169
void WriteBody8(XclExpStream &rStrm)
Definition: xestyle.cxx:2260
const SfxItemSet * GetItemSet() const
Definition: xestyle.hxx:484
const SfxItemSet * mpItemSet
Definition: xestyle.hxx:493
XclExpCellBorder maBorder
All alignment attributes.
Definition: xestyle.hxx:497
XclExpCellAlign maAlignment
Cell protection flags.
Definition: xestyle.hxx:496
const XclExpCellBorder & GetBorderData() const
Returns the cell border settings of this XF.
Definition: xestyle.hxx:458
const XclExpCellArea & GetAreaData() const
Returns the cell fill settings of this XF.
Definition: xestyle.hxx:460
void SetXmlIds(sal_uInt32 nBorderId, sal_uInt32 nFillId)
Definition: xestyle.cxx:2290
sal_Int32 mnFillId
OOXML Border Index.
Definition: xestyle.hxx:504
XclExpCellProt maProtection
Pointer to the item set (we do not own it).
Definition: xestyle.hxx:495
sal_Int32 mnBorderId
Excel number format index.
Definition: xestyle.hxx:503
XclExpXF(const XclExpRoot &rRoot, const ScPatternAttr &rPattern, sal_Int16 nScript, sal_uInt32 nScForceNumFmt=NUMBERFORMAT_ENTRY_NOT_FOUND, sal_uInt16 nForceXclFont=EXC_FONT_NOTFOUND, bool bForceLineBreak=false)
Constructs a cell XF record from the passed Calc cell formatting.
Definition: xestyle.cxx:2111
sal_uInt16 mnXclFont
Calc number format index.
Definition: xestyle.hxx:501
sal_uInt32 mnParentXFId
Background area style.
Definition: xestyle.hxx:499
const XclExpCellProt & GetProtectionData() const
Returns the cell protection settings of this XF.
Definition: xestyle.hxx:454
sax_fastparser::FSHelperPtr & GetCurrentStream()
Definition: xestream.cxx:923
const XclExpRoot & GetRoot() const
Returns the filter root data.
Definition: xestream.hxx:291
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xestyle.cxx:3375
XclExpXmlStyleSheet(const XclExpRoot &rRoot)
Definition: xestyle.cxx:3370
Access to global data for a filter object (imported or exported document) from other classes.
Definition: xlroot.hxx:128
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:143
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:147
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:322
sal_Int16 GetDefApiScript() const
Returns the default script type, e.g.
Definition: xlroot.hxx:155
tools::Long GetSpaceWidth() const
Definition: xlroot.hxx:158
void SetCharWidth(const XclFontData &rFontData)
Sets the width of the '0' - '9' digit character as well as the ' ' space char (using the default font...
Definition: xlroot.cxx:207
ScStyleSheetPool & GetStyleSheetPool() const
Returns the style sheet pool of the Calc document.
Definition: xlroot.cxx:306
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:141
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
static sal_uInt8 GetXclOrientFromRot(sal_uInt16 nXclRot)
Calculates BIFF2-BIFF5 text orientation from BIFF8 rotation angle.
Definition: xltools.cxx:189
static bool IsBuiltInStyleName(const OUString &rStyleName, sal_uInt8 *pnStyleId=nullptr, sal_Int32 *pnNextChar=nullptr)
Returns true, if the passed string is a name of an Excel built-in style.
Definition: xltools.cxx:577
static sal_uInt8 GetXclRotation(Degree100 nScRot)
Calculates the Excel angle value from an angle in 1/100 of degrees.
Definition: xltools.cxx:162
static bool GetBuiltInStyleId(sal_uInt8 &rnStyleId, sal_uInt8 &rnLevel, const OUString &rStyleName)
Returns the Excel built-in style identifier of a passed style name.
Definition: xltools.cxx:625
static bool IsCondFormatStyleName(const OUString &rStyleName)
Returns true, if the passed string is a name of a conditional format style created by Excel import.
Definition: xltools.cxx:672
static OUString GetXclFontName(const OUString &rFontName)
Returns the matching Excel font name for a passed Calc font name.
Definition: xltools.cxx:455
Contains base members for XF record import/export.
Definition: xlstyle.hxx:563
bool mbBorderUsed
true = alignment used.
Definition: xlstyle.hxx:594
bool IsCellXF() const
Returns true, if this is a hard cell format.
Definition: xlstyle.hxx:579
bool mbAreaUsed
true = border data used.
Definition: xlstyle.hxx:595
bool IsStyleXF() const
Returns true, if this is a cell style.
Definition: xlstyle.hxx:581
bool mbProtUsed
true = cell XF, false = style XF.
Definition: xlstyle.hxx:590
bool mbFmtUsed
true = font index used.
Definition: xlstyle.hxx:592
sal_uInt16 mnParent
Definition: xlstyle.hxx:588
bool mbAlignUsed
true = number format used.
Definition: xlstyle.hxx:593
bool mbCellXF
Index to parent style XF.
Definition: xlstyle.hxx:589
bool Equals(const XclXFBase &rCmp) const
Returns true, if this object is equal to the passed.
Definition: xlstyle.cxx:1740
void SetAllUsedFlags(bool bUsed)
Sets all "attribute used" flags to the passed state.
Definition: xlstyle.cxx:1730
bool mbFontUsed
true = cell protection used.
Definition: xlstyle.hxx:591
static OString ToOString(const Color &rColor)
Definition: xestream.cxx:712
static sax_fastparser::FSHelperPtr WriteFontData(sax_fastparser::FSHelperPtr pStream, const XclFontData &rFontData, sal_Int32 nNameId)
Definition: xestream.cxx:864
ColorType getType() const
Color const & getFinalColor() const
ThemeColorType getSchemeType() const
bool isValidSchemeType() const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
sal_Int16 mnLevel
int nCount
float u
DocumentType eType
FontLineStyle
LINESTYLE_DOUBLEWAVE
LINESTYLE_DOUBLE
LINESTYLE_NONE
LINESTYLE_DONTKNOW
STRIKEOUT_BOLD
STRIKEOUT_DOUBLE
STRIKEOUT_SINGLE
STRIKEOUT_X
STRIKEOUT_SLASH
ITALIC_NORMAL
ITALIC_NONE
ITALIC_OBLIQUE
FontFamily
FAMILY_DECORATIVE
FAMILY_SYSTEM
FAMILY_DONTKNOW
FAMILY_SCRIPT
FAMILY_SWISS
FAMILY_MODERN
FAMILY_ROMAN
WEIGHT_BOLD
WEIGHT_NORMAL
OUString sName
void insert_value(Type &rnBitField, InsertType nValue, sal_uInt8 nStartBit, sal_uInt8 nBitCount)
Inserts a value into a bitfield.
Definition: ftools.hxx:102
void set_flag(Type &rnBitField, Type nMask, bool bSet=true)
Sets or clears (according to bSet) all set bits of nMask in rnBitField.
Definition: ftools.hxx:95
::std::vector< sal_uInt32 > ScfUInt32Vec
Definition: ftools.hxx:257
sal_Int32 nIndex
#define LANGUAGE_SYSTEM
#define LANGUAGE_ENGLISH_US
SvtScriptType
sal_uInt16 nPos
std::vector< sal_Int8, boost::noinit_adaptor< std::allocator< sal_Int8 > > > maData
std::unique_ptr< sal_Int32[]> pData
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
SvtScriptType FromI18NToSvtScriptType(sal_Int16 nI18NType)
ScDxfFont GetDxfFontFromItemSet(const XclExpRoot &rRoot, const SfxItemSet &rSet)
Get a dxf related font object from the item set.
Definition: xestyle.cxx:900
vcl::Font GetFontFromItemSet(const XclExpRoot &rRoot, const SfxItemSet &rItemSet, sal_Int16 nScript)
Returns a VCL font object filled from the passed item set.
Definition: xestyle.cxx:885
bool CheckItems(const XclExpRoot &rRoot, const SfxItemSet &rItemSet, sal_Int16 nScript, bool bDeep)
Returns true, if at least one font related item is set in the passed item set.
Definition: xestyle.cxx:909
sal_Int16 GetFirstUsedScript(const XclExpRoot &rRoot, const SfxItemSet &rItemSet)
Returns the script type of the first font item found in the item set and its parents.
Definition: xestyle.cxx:834
tools::Long const nBorder
size
Reference< XComponentContext > getProcessComponentContext()
int i
void SvStream & rStrm
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::enable_if_t<(sizeof(N)==4)> hash_combine(N &nSeed, T const *pValue, size_t nCount)
std::shared_ptr< T > make_shared(Args &&... args)
OUString getRelationship(Relationship eRelationship)
static double convertColorTransformsToTintOrShade(model::ComplexColor const &rComplexColor)
static sal_Int32 convertThemeColorTypeToExcelThemeNumber(model::ThemeColorType eType)
const char * UseIf(const char *s, bool bUse)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
long Long
::std::array< OUString, NF_KEYWORD_ENTRIES_COUNT > NfKeywordTable
std::optional< vcl::Font > mpFont
sal_Int16 nId
const char GetValue[]
@ Raw
COL_AUTO is returned.
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< ScIndentItem > ATTR_INDENT(131)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxFontItem > ATTR_CJK_FONT(111)
constexpr TypedWhichId< SvxPostureItem > ATTR_CTL_FONT_POSTURE(119)
constexpr TypedWhichId< SvxFontItem > ATTR_CTL_FONT(116)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CJK_FONT_HEIGHT(112)
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxWeightItem > ATTR_CJK_FONT_WEIGHT(113)
constexpr TypedWhichId< ScShrinkToFitCell > ATTR_SHRINKTOFIT(140)
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_TLBR(141)
constexpr TypedWhichId< SvxShadowedItem > ATTR_FONT_SHADOWED(108)
constexpr TypedWhichId< SvxContourItem > ATTR_FONT_CONTOUR(107)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
constexpr TypedWhichId< ScRotateValueItem > ATTR_ROTATE_VALUE(135)
constexpr TypedWhichId< SvxJustifyMethodItem > ATTR_VER_JUSTIFY_METHOD(133)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
constexpr TypedWhichId< SvxJustifyMethodItem > ATTR_HOR_JUSTIFY_METHOD(130)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SvxFrameDirectionItem > ATTR_WRITINGDIR(138)
constexpr TypedWhichId< SvxCrossedOutItem > ATTR_FONT_CROSSEDOUT(106)
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_BLTR(142)
constexpr TypedWhichId< ScVerticalStackCell > ATTR_STACKED(134)
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
constexpr TypedWhichId< SvxWeightItem > ATTR_CTL_FONT_WEIGHT(118)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
constexpr TypedWhichId< SvxPostureItem > ATTR_CJK_FONT_POSTURE(114)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CTL_FONT_HEIGHT(117)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
static SfxItemSet & rSet
std::optional< bool > bShadow
Definition: fonthelper.hxx:32
std::optional< const SvxFontItem * > pFontAttr
Definition: fonthelper.hxx:23
std::optional< bool > bOutline
Definition: fonthelper.hxx:31
std::optional< FontLineStyle > eUnder
Definition: fonthelper.hxx:27
std::optional< FontItalic > eItalic
Definition: fonthelper.hxx:26
std::optional< FontStrikeout > eStrike
Definition: fonthelper.hxx:30
std::optional< sal_uInt32 > nFontHeight
Definition: fonthelper.hxx:24
bool isEmpty() const
Definition: fonthelper.hxx:38
std::optional< FontWeight > eWeight
Definition: fonthelper.hxx:25
std::optional< Color > aColor
Definition: fonthelper.hxx:35
std::set< Color > & getTextColors()
std::set< Color > & getBackgroundColors()
sal_uInt8 mnTextDir
Text orientation.
Definition: xlstyle.hxx:492
void SetScFrameDir(SvxFrameDirection eFrameDir)
Sets the Calc frame direction.
Definition: xlstyle.cxx:1645
sal_uInt8 mnOrient
Vertical alignment.
Definition: xlstyle.hxx:491
sal_uInt8 mnVerAlign
Horizontal alignment.
Definition: xlstyle.hxx:490
sal_uInt8 mnIndent
Text rotation angle.
Definition: xlstyle.hxx:494
void SetScHorAlign(SvxCellHorJustify eHorJust)
Sets the Calc horizontal alignment.
Definition: xlstyle.cxx:1617
void SetScVerAlign(SvxCellVerJustify eVerJust)
Sets the Calc vertical alignment.
Definition: xlstyle.cxx:1632
sal_uInt8 mnRotation
CTL text direction.
Definition: xlstyle.hxx:493
sal_uInt8 mnHorAlign
Definition: xlstyle.hxx:489
bool mbLineBreak
Indentation.
Definition: xlstyle.hxx:495
bool mbShrink
true = Multi-line text.
Definition: xlstyle.hxx:496
Contains background colors and pattern for a cell.
Definition: xlstyle.hxx:544
sal_uInt16 mnBackColor
Palette index to foreground color.
Definition: xlstyle.hxx:546
bool IsTransparent() const
Returns true, if the area represents transparent state.
Definition: xlstyle.cxx:1707
sal_uInt8 mnPattern
Palette index to background color.
Definition: xlstyle.hxx:547
sal_uInt16 mnForeColor
Definition: xlstyle.hxx:545
sal_uInt8 mnRightLine
Style of left line.
Definition: xlstyle.hxx:530
sal_uInt8 mnDiagLine
Style of bottom line.
Definition: xlstyle.hxx:533
sal_uInt16 mnDiagColor
Palette index for bottom line.
Definition: xlstyle.hxx:528
bool mbDiagTLtoBR
Style of diagonal line(s).
Definition: xlstyle.hxx:534
sal_uInt8 mnTopLine
Style of right line.
Definition: xlstyle.hxx:531
sal_uInt16 mnLeftColor
Definition: xlstyle.hxx:524
sal_uInt8 mnLeftLine
Palette index for diagonal line(s).
Definition: xlstyle.hxx:529
sal_uInt16 mnTopColor
Palette index for right line.
Definition: xlstyle.hxx:526
sal_uInt16 mnRightColor
Palette index for left line.
Definition: xlstyle.hxx:525
sal_uInt16 mnBottomColor
Palette index for top line.
Definition: xlstyle.hxx:527
bool mbDiagBLtoTR
true = Top-left to bottom-right on.
Definition: xlstyle.hxx:535
sal_uInt8 mnBottomLine
Style of top line.
Definition: xlstyle.hxx:532
bool mbLocked
Definition: xlstyle.hxx:478
bool mbHidden
true = Locked against editing.
Definition: xlstyle.hxx:479
Extends the XclCellAlign struct for export.
Definition: xestyle.hxx:322
bool FillFromItemSet(const XclRoot &rRoot, const SfxItemSet &rItemSet, bool bForceLineBreak, XclBiff eBiff, bool bStyle=false)
Fills the alignment attributes from the passed item set.
Definition: xestyle.cxx:1452
void SaveXml(XclExpXmlStream &rStrm) const
Definition: xestyle.cxx:1598
void FillToXF8(sal_uInt16 &rnAlign, sal_uInt16 &rnMiscAttrib) const
Fills the data to the passed fields of a BIFF8 XF record.
Definition: xestyle.cxx:1558
void FillToXF5(sal_uInt16 &rnAlign) const
Fills the data to the passed fields of a BIFF5/BIFF7 XF record.
Definition: xestyle.cxx:1550
Extends the XclCellArea struct for export.
Definition: xestyle.hxx:378
sal_uInt32 mnForeColorId
Definition: xestyle.hxx:379
Color maForeColor
Background color ID.
Definition: xestyle.hxx:382
void SaveXml(XclExpXmlStream &rStrm) const
Definition: xestyle.cxx:1986
sal_uInt32 mnBackColorId
Foreground color ID.
Definition: xestyle.hxx:380
void FillToCF8(sal_uInt16 &rnPattern, sal_uInt16 &rnColor) const
Fills the data to the passed fields of a BIFF8 CF (conditional format) record.
Definition: xestyle.cxx:1959
void FillToXF5(sal_uInt32 &rnArea) const
Fills the data to the passed fields of a BIFF5/BIFF7 XF record.
Definition: xestyle.cxx:1945
void SetFinalColors(const XclExpPalette &rPalette)
Fills the mn***Color base members from the mn***ColorId members.
Definition: xestyle.cxx:1940
model::ComplexColor maForegroundComplexColor
Definition: xestyle.hxx:385
bool FillFromItemSet(const SfxItemSet &rItemSet, XclExpPalette &rPalette, bool bStyle)
Fills the area attributes from the passed item set.
Definition: xestyle.cxx:1918
Color maBackColor
Definition: xestyle.hxx:383
model::ComplexColor maBackgroundComplexColor
Definition: xestyle.hxx:386
void FillToXF8(sal_uInt32 &rnBorder2, sal_uInt16 &rnArea) const
Fills the data to the passed fields of a BIFF8 XF record.
Definition: xestyle.cxx:1952
Extends the XclCellBorder struct for export.
Definition: xestyle.hxx:341
sal_uInt32 mnLeftColorId
Definition: xestyle.hxx:342
sal_uInt32 mnDiagColorId
Color ID for bottom line.
Definition: xestyle.hxx:346
model::ComplexColor maComplexColorLeft
Color ID for diagonal line(s).
Definition: xestyle.hxx:348
model::ComplexColor maComplexColorTop
Definition: xestyle.hxx:350
void SetFinalColors(const XclExpPalette &rPalette)
Fills the mn***Color base members from the mn***ColorId members.
Definition: xestyle.cxx:1777
bool FillFromItemSet(const SfxItemSet &rItemSet, XclExpPalette &rPalette, XclBiff eBiff, bool bStyle=false)
Fills the border attributes from the passed item set.
Definition: xestyle.cxx:1715
sal_uInt32 mnRightColorId
Color ID for left line.
Definition: xestyle.hxx:343
sal_uInt32 mnBottomColorId
Color ID for top line.
Definition: xestyle.hxx:345
model::ComplexColor maComplexColorRight
Definition: xestyle.hxx:349
model::ComplexColor maComplexColorDiagonal
Definition: xestyle.hxx:352
void FillToXF8(sal_uInt32 &rnBorder1, sal_uInt32 &rnBorder2) const
Fills the data to the passed fields of a BIFF8 XF record.
Definition: xestyle.cxx:1798
void FillToCF8(sal_uInt16 &rnLine, sal_uInt32 &rnColor) const
Fills the data to the passed fields of a BIFF8 CF (conditional format) record.
Definition: xestyle.cxx:1814
void SaveXml(XclExpXmlStream &rStrm) const
Definition: xestyle.cxx:1879
model::ComplexColor maComplexColorBottom
Definition: xestyle.hxx:351
void FillToXF5(sal_uInt32 &rnBorder, sal_uInt32 &rnArea) const
Fills the data to the passed fields of a BIFF5/BIFF7 XF record.
Definition: xestyle.cxx:1786
sal_uInt32 mnTopColorId
Color ID for right line.
Definition: xestyle.hxx:344
Extends the XclCellProt struct for export.
Definition: xestyle.hxx:308
bool FillFromItemSet(const SfxItemSet &rItemSet, bool bStyle=false)
Fills the protection attributes from the passed item set.
Definition: xestyle.cxx:1431
void SaveXml(XclExpXmlStream &rStrm) const
Definition: xestyle.cxx:1445
void FillToXF3(sal_uInt16 &rnProt) const
Fills the data to the passed fields of a BIFF3-BIFF8 XF record.
Definition: xestyle.cxx:1439
void SaveXml(XclExpXmlStream &rStrm) const
Definition: xestyle.cxx:2080
Color maColor
Definition: xestyle.hxx:412
model::ComplexColor maComplexColor
Definition: xestyle.hxx:413
bool FillFromItemSet(const SfxItemSet &rItemSet)
Definition: xestyle.cxx:2068
Stores a core number format index with corresponding Excel format index.
Definition: xestyle.hxx:253
void SaveXml(XclExpXmlStream &rStrm)
Definition: xestyle.cxx:1331
sal_uInt32 mnScNumFmt
Definition: xestyle.hxx:254
sal_uInt16 mnXclNumFmt
Core index of the number format.
Definition: xestyle.hxx:255
OUString maNumFmtString
Resulting Excel format index.
Definition: xestyle.hxx:256
composite key for the find-map, so we can do partial key searching
Definition: xestyle.hxx:701
Extended info about a built-in XF.
Definition: xestyle.hxx:688
XclExpBuiltInInfo()
true = STYLE record created.
Definition: xestyle.cxx:2457
sal_uInt8 mnLevel
Built-in style identifier.
Definition: xestyle.hxx:690
bool mbPredefined
Level for RowLevel/ColLevel styles.
Definition: xestyle.hxx:691
A combination of unique XF identifier with real Excel XF index.
Definition: xestyle.hxx:422
sal_uInt16 mnXFIndex
Temporary XF identifier.
Definition: xestyle.hxx:424
void ConvertXFIndex(const XclExpRoot &rRoot)
Converts the XF identifier in mnXFId to an Excel XF index and stores it in mnXFIndex.
Definition: xestyle.cxx:2106
sal_uInt32 mnXFId
Definition: xestyle.hxx:423
XclExpXFId()
Real Excel XF index.
Definition: xestyle.cxx:2100
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:285
sal_uInt8 mnCharSet
Windows font family.
Definition: xlstyle.hxx:292
void SetScHeight(sal_Int32 nTwips)
Sets the Calc font height (in twips).
Definition: xlstyle.cxx:307
sal_uInt16 mnHeight
String with styles (bold, italic).
Definition: xlstyle.hxx:288
void SetFontEncoding(rtl_TextEncoding eFontEnc)
Sets the font text encoding.
Definition: xlstyle.cxx:329
bool mbOutline
true = Struck out.
Definition: xlstyle.hxx:296
void SetScFamily(FontFamily eScFamily)
Sets the Calc font family.
Definition: xlstyle.cxx:312
sal_uInt16 mnWeight
Font height in twips (1/20 of a point).
Definition: xlstyle.hxx:289
void SetScPosture(FontItalic eScPosture)
Sets the Calc font posture.
Definition: xlstyle.cxx:335
bool mbItalic
Underline style.
Definition: xlstyle.hxx:294
sal_uInt8 mnUnderline
Windows character set.
Definition: xlstyle.hxx:293
bool mbStrikeout
true = Italic.
Definition: xlstyle.hxx:295
void SetScWeight(FontWeight eScWeight)
Sets the Calc font weight.
Definition: xlstyle.cxx:340
sal_uInt8 mnFamily
Escapement type.
Definition: xlstyle.hxx:291
sal_uInt16 mnEscapem
Boldness: 400=normal, 700=bold.
Definition: xlstyle.hxx:290
bool mbShadow
true = Outlined.
Definition: xlstyle.hxx:297
model::ComplexColor maComplexColor
true = Shadowed.
Definition: xlstyle.hxx:299
OUString maName
Definition: xlstyle.hxx:286
sal_uInt32 mnIndex
SvxCellJustifyMethod
SvxCellHorJustify
SvxCellVerJustify
SvxBoxItem & rBoxItem
unsigned char sal_uInt8
#define SAL_MAX_INT32
#define SAL_MAX_UINT32
sal_Int16 SCTAB
Definition: types.hxx:22
const sal_uInt32 EXC_PAL_MAXRAWSIZE
Definition: xestyle.cxx:313
static const char * lcl_StyleNameFromId(sal_Int32 nStyleId)
Definition: xestyle.cxx:2397
static const char * ToVerticalAlignment(sal_uInt8 nVerAlign)
Definition: xestyle.cxx:1585
static void lcl_GetCellCounts(const XclExpRecordList< XclExpXF > &rXFList, sal_Int32 &rCells, sal_Int32 &rStyles)
Definition: xestyle.cxx:2700
static void lcl_WriteBorder(XclExpXmlStream &rStrm, sal_Int32 nElement, sal_uInt8 nLineStyle, const Color &rColor, model::ComplexColor const &rComplexColor)
Definition: xestyle.cxx:1848
static const char * ToHorizontalAlignment(sal_uInt8 nHorAlign)
Definition: xestyle.cxx:1569
static XclExpCellArea lcl_GetPatternFill_None()
Definition: xestyle.cxx:3015
static XclExpCellArea lcl_GetPatternFill_Gray125()
Definition: xestyle.cxx:3022
static const char * ToPatternType(sal_uInt8 nPattern)
Definition: xestyle.cxx:1971
const sal_uInt32 EXC_PAL_INDEXBASE
Definition: xestyle.cxx:312
static const char * ToLineStyle(sal_uInt8 nLineStyle)
Definition: xestyle.cxx:1826
const sal_uInt16 EXC_ID_FONTLIST
Definition: xestyle.hxx:39
const sal_uInt16 EXC_ID_XFLIST
For internal use only.
Definition: xestyle.hxx:41
XclExpColorType
For internal use only. TODO:moggi: find a better/correct value.
Definition: xestyle.hxx:48
@ EXC_COLOR_CHARTAREA
Line in a chart.
Definition: xestyle.hxx:54
@ EXC_COLOR_GRID
Text color in a form control.
Definition: xestyle.hxx:56
@ EXC_COLOR_CELLBORDER
Text in a cell.
Definition: xestyle.hxx:50
@ EXC_COLOR_CTRLTEXT
Area in a chart.
Definition: xestyle.hxx:55
@ EXC_COLOR_CHARTTEXT
Background area of a cell.
Definition: xestyle.hxx:52
@ EXC_COLOR_CELLAREA
Border of a cell.
Definition: xestyle.hxx:51
@ EXC_COLOR_CELLTEXT
Definition: xestyle.hxx:49
@ EXC_COLOR_CHARTLINE
Text color in a chart.
Definition: xestyle.hxx:53
@ EXC_COLOR_TABBG
Spreadsheet grid color.
Definition: xestyle.hxx:57
const sal_uInt16 EXC_ID_FORMATLIST
For internal use only.
Definition: xestyle.hxx:40
const sal_uInt16 EXC_ID_DXFS
For internal use only.
Definition: xestyle.hxx:42
const size_t EXC_FONTLIST_NOTFOUND
Definition: xestyle.hxx:122
::std::unique_ptr< SvNumberFormatter > SvNumberFormatterPtr
Definition: xestyle.hxx:264
const sal_uInt16 EXC_BORDER_THICK
Definition: xlconst.hxx:248
const sal_uInt16 EXC_BORDER_MEDIUM
Definition: xlconst.hxx:249
const sal_uInt16 EXC_BORDER_THIN
Definition: xlconst.hxx:250
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:30
@ EXC_BIFF5
MS Excel 4.0.
Definition: xlconst.hxx:34
@ EXC_BIFF4
MS Excel 3.0.
Definition: xlconst.hxx:33
@ EXC_BIFF2
Definition: xlconst.hxx:31
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35
@ EXC_BIFF3
MS Excel 2.1.
Definition: xlconst.hxx:32
@ EXC_OUTPUT_BINARY
Definition: xlconst.hxx:42
const sal_uInt8 EXC_ROT_STACKED
Text rotation: 90 deg clockwise.
Definition: xlconst.hxx:141
const sal_uInt16 EXC_BORDER_HAIR
Definition: xlconst.hxx:251
@ EightBitLength
Always use UCS-2 characters (default: try to compress). BIFF8 only.
@ ForceUnicode
Default string settings.
const sal_uInt8 EXC_STYLE_CURRENCY_0
"Comma [0]" style.
Definition: xlstyle.hxx:232
const sal_uInt16 EXC_XF_DEFAULTSTYLE
Arbitrary maximum number of style XFs.
Definition: xlstyle.hxx:139
const size_t EXC_FONT_MAXCOUNT5
Definition: xlstyle.hxx:81
const sal_uInt16 EXC_COLOR_WINDOWBACK
System window text color (>=BIFF5).
Definition: xlstyle.hxx:209
const sal_uInt16 EXC_FONT_NOTFOUND
Application font index.
Definition: xlstyle.hxx:78
const sal_uInt8 EXC_XF_HOR_GENERAL
Definition: xlstyle.hxx:159
const sal_uInt8 EXC_XF_HOR_DISTRIB
Definition: xlstyle.hxx:166
const sal_uInt8 EXC_STYLE_CURRENCY
"Comma" style.
Definition: xlstyle.hxx:229
const sal_uInt8 EXC_LINE_HAIR
Definition: xlstyle.hxx:45
const sal_uInt16 EXC_FONTATTR_SHADOW
Definition: xlstyle.hxx:103
const sal_uInt8 EXC_LINE_DOTTED
Definition: xlstyle.hxx:42
const sal_uInt16 EXC_FORMAT_OFFSET8
Definition: xlstyle.hxx:69
const sal_uInt8 EXC_PATT_50_PERC
Definition: xlstyle.hxx:57
const sal_uInt8 EXC_STYLE_COLLEVEL
"RowLevel_*" styles.
Definition: xlstyle.hxx:227
const sal_uInt8 EXC_LINE_MEDIUM_DASHDOTDOT
Definition: xlstyle.hxx:50
const sal_uInt16 EXC_FONT_APP
Definition: xlstyle.hxx:77
const sal_uInt8 EXC_XF_DIFF_BORDER
Definition: xlstyle.hxx:155
const sal_uInt32 EXC_XF_MAXSTYLECOUNT
Maximum number of all XF records.
Definition: xlstyle.hxx:138
const sal_uInt8 EXC_PATT_6_25_PERC
Definition: xlstyle.hxx:61
const sal_uInt16 EXC_COLOR_FONTAUTO
Note text color.
Definition: xlstyle.hxx:216
const sal_uInt16 EXC_FONTATTR_UNDERLINE
Definition: xlstyle.hxx:100
const sal_uInt16 EXC_COLOR_USEROFFSET
Definition: xlstyle.hxx:205
const sal_uInt8 EXC_XF_HOR_CENTER_AS
Definition: xlstyle.hxx:165
const sal_uInt8 EXC_STYLE_PERCENT
"Currency" style.
Definition: xlstyle.hxx:230
const sal_uInt8 EXC_XF_HOR_CENTER
Definition: xlstyle.hxx:161
const size_t EXC_FONT_MAXCOUNT8
Definition: xlstyle.hxx:82
const sal_uInt8 EXC_STYLE_LEVELCOUNT
No built-in style.
Definition: xlstyle.hxx:237
const sal_uInt8 EXC_XF_DIFF_FONT
Definition: xlstyle.hxx:153
const sal_uInt8 EXC_LINE_DASHED
Definition: xlstyle.hxx:41
const sal_uInt8 EXC_LINE_THIN
Definition: xlstyle.hxx:39
const sal_uInt8 EXC_STYLE_ROWLEVEL
"Normal" style.
Definition: xlstyle.hxx:226
const sal_uInt16 EXC_ID4_FORMAT
Definition: xlstyle.hxx:66
const sal_uInt8 EXC_LINE_MEDIUM_DASHED
Definition: xlstyle.hxx:46
const sal_uInt16 EXC_FONTATTR_STRIKEOUT
Definition: xlstyle.hxx:101
const sal_uInt8 EXC_LINE_NONE
Definition: xlstyle.hxx:38
const sal_uInt16 EXC_COLOR_WINDOWTEXT
System window background color (BIFF3-BIFF4).
Definition: xlstyle.hxx:208
const sal_uInt16 EXC_XF_NOTFOUND
Excel index to default cell XF.
Definition: xlstyle.hxx:141
const sal_uInt16 EXC_ID2_FONT
Definition: xlstyle.hxx:74
const sal_uInt8 EXC_XF_DIFF_VALFMT
Shrink to fit into cell.
Definition: xlstyle.hxx:152
const sal_uInt8 EXC_XF_VER_TOP
Definition: xlstyle.hxx:168
const sal_uInt8 EXC_LINE_THIN_DASHDOTDOT
Definition: xlstyle.hxx:49
const sal_uInt8 EXC_STYLE_NOLEVEL
Number of outline level styles.
Definition: xlstyle.hxx:238
const sal_uInt16 EXC_FONTATTR_ITALIC
Definition: xlstyle.hxx:99
const sal_uInt16 EXC_XF_STYLE
Definition: xlstyle.hxx:147
const sal_uInt16 EXC_ID_PALETTE
Definition: xlstyle.hxx:200
const sal_uInt16 EXC_XF_LOCKED
Definition: xlstyle.hxx:145
const sal_uInt8 EXC_XF_VER_JUSTIFY
Definition: xlstyle.hxx:171
const sal_uInt16 EXC_XF_STYLEPARENT
Definition: xlstyle.hxx:148
const sal_uInt16 EXC_STYLE_BUILTIN
Definition: xlstyle.hxx:222
const sal_uInt16 EXC_FONTATTR_NONE
Definition: xlstyle.hxx:97
const sal_uInt16 EXC_ID_STYLE
Font auto color (system window text color).
Definition: xlstyle.hxx:220
const sal_uInt8 EXC_XF_VER_BOTTOM
Definition: xlstyle.hxx:170
const sal_uInt8 EXC_PATT_NONE
Definition: xlstyle.hxx:55
const sal_uInt8 EXC_XF_VER_CENTER
Definition: xlstyle.hxx:169
const sal_uInt8 EXC_LINE_MEDIUM_SLANT_DASHDOT
Definition: xlstyle.hxx:51
const sal_uInt8 EXC_LINE_THIN_DASHDOT
Definition: xlstyle.hxx:47
const sal_uInt16 EXC_XF_HIDDEN
Definition: xlstyle.hxx:146
const sal_uInt8 EXC_XF_HOR_FILL
Definition: xlstyle.hxx:163
const sal_uInt8 EXC_STYLE_COMMA_0
"Percent" style.
Definition: xlstyle.hxx:231
const sal_uInt8 EXC_PATT_SOLID
Definition: xlstyle.hxx:56
const sal_uInt32 EXC_XF_MAXCOUNT
Definition: xlstyle.hxx:137
const sal_uInt8 EXC_PATT_75_PERC
Definition: xlstyle.hxx:58
const sal_uInt8 EXC_LINE_MEDIUM
Definition: xlstyle.hxx:40
const sal_uInt16 EXC_XF_LINEBREAK
Styles don't have a parent.
Definition: xlstyle.hxx:149
const sal_uInt32 EXC_XF_DIAGONAL_BL_TO_TR
Top-left to bottom-right.
Definition: xlstyle.hxx:191
const sal_uInt8 EXC_PATT_12_5_PERC
Definition: xlstyle.hxx:60
const sal_uInt8 EXC_XF_HOR_RIGHT
Definition: xlstyle.hxx:162
const sal_uInt8 EXC_XF_HOR_JUSTIFY
Definition: xlstyle.hxx:164
const sal_uInt16 EXC_ID5_XF
Definition: xlstyle.hxx:135
const sal_uInt8 EXC_XF_VER_DISTRIB
Definition: xlstyle.hxx:172
const sal_uInt32 EXC_XFID_NOTFOUND
Special index for "not found" state.
Definition: xlstyle.hxx:143
const sal_uInt8 EXC_LINE_THICK
Definition: xlstyle.hxx:43
const size_t EXC_FONT_MAXCOUNT4
Definition: xlstyle.hxx:80
const sal_uInt32 EXC_XF_DIAGONAL_TL_TO_BR
Definition: xlstyle.hxx:190
const sal_uInt8 EXC_XF_HOR_LEFT
Definition: xlstyle.hxx:160
const sal_uInt8 EXC_XF_DIFF_ALIGN
Definition: xlstyle.hxx:154
const sal_uInt8 EXC_PATT_25_PERC
Definition: xlstyle.hxx:59
const sal_uInt8 EXC_STYLE_COMMA
"ColLevel_*" styles.
Definition: xlstyle.hxx:228
const sal_uInt8 EXC_XF_DIFF_AREA
Definition: xlstyle.hxx:156
const sal_uInt8 EXC_LINE_DOUBLE
Definition: xlstyle.hxx:44
const sal_uInt8 EXC_LINE_MEDIUM_DASHDOT
Definition: xlstyle.hxx:48
const sal_uInt16 EXC_FONTATTR_OUTLINE
Definition: xlstyle.hxx:102
const sal_uInt16 EXC_XF_DEFAULTCELL
Excel index to default style XF.
Definition: xlstyle.hxx:140
const sal_uInt8 EXC_XF_TEXTDIR_CONTEXT
Definition: xlstyle.hxx:174
const sal_uInt16 EXC_FORMAT_OFFSET5
Definition: xlstyle.hxx:68
const sal_uInt8 EXC_STYLE_NORMAL
Definition: xlstyle.hxx:225
const sal_uInt8 EXC_STYLE_USERDEF
"Followed_Hyperlink" style.
Definition: xlstyle.hxx:235
const sal_uInt16 EXC_XF8_SHRINK
Definition: xlstyle.hxx:187
const sal_uInt8 EXC_XF_DIFF_PROT
Definition: xlstyle.hxx:157
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:33
#define SV_COUNTRY_LANGUAGE_OFFSET
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND