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