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