LibreOffice Module sc (master) 1
xecontent.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 <xecontent.hxx>
23
24#include <vector>
25#include <algorithm>
26#include <string_view>
27
28#include <com/sun/star/frame/XModel.hpp>
29#include <com/sun/star/sheet/XAreaLinks.hpp>
30#include <com/sun/star/sheet/XAreaLink.hpp>
31#include <com/sun/star/sheet/TableValidationVisibility.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <sfx2/objsh.hxx>
34#include <tools/urlobj.hxx>
35#include <formula/grammar.hxx>
36#include <scitems.hxx>
37#include <editeng/flditem.hxx>
38#include <document.hxx>
39#include <validat.hxx>
40#include <unonames.hxx>
41#include <convuno.hxx>
42#include <rangenam.hxx>
43#include <tokenarray.hxx>
44#include <stlpool.hxx>
45#include <patattr.hxx>
46#include <fapihelper.hxx>
47#include <xehelper.hxx>
48#include <xestyle.hxx>
49#include <xename.hxx>
50#include <xlcontent.hxx>
51#include <xltools.hxx>
52#include <xeformula.hxx>
53#include <rtl/uuid.h>
54#include <sal/log.hxx>
55#include <oox/export/utils.hxx>
56#include <oox/token/namespaces.hxx>
58#include <comphelper/string.hxx>
59#include <o3tl/string_view.hxx>
60
61using namespace ::oox;
62
63using ::com::sun::star::uno::Reference;
64using ::com::sun::star::uno::UNO_QUERY;
65using ::com::sun::star::table::CellRangeAddress;
66using ::com::sun::star::sheet::XAreaLinks;
67using ::com::sun::star::sheet::XAreaLink;
68
69// Shared string table ========================================================
70
71namespace {
72
74struct XclExpHashEntry
75{
76 const XclExpString* mpString;
77 sal_uInt32 mnSstIndex;
78 explicit XclExpHashEntry( const XclExpString* pString, sal_uInt32 nSstIndex ) :
79 mpString( pString ), mnSstIndex( nSstIndex ) {}
80};
81
83struct XclExpHashEntrySWO
84{
85 bool operator()( const XclExpHashEntry& rLeft, const XclExpHashEntry& rRight ) const
86 { return *rLeft.mpString < *rRight.mpString; }
87};
88
89}
90
95{
96public:
97 explicit XclExpSstImpl();
98
100 sal_uInt32 Insert( XclExpStringRef xString );
101
103 void Save( XclExpStream& rStrm );
105
106private:
107 typedef ::std::vector< XclExpHashEntry > XclExpHashVec;
108
109 std::vector< XclExpStringRef > maStringVector;
110 std::vector< XclExpHashVec >
112 sal_uInt32 mnTotal;
113 sal_uInt32 mnSize;
114};
115
116const sal_uInt32 EXC_SST_HASHTABLE_SIZE = 2048;
117
119 maHashTab( EXC_SST_HASHTABLE_SIZE ),
120 mnTotal( 0 ),
121 mnSize( 0 )
122{
123}
124
126{
127 OSL_ENSURE( xString, "XclExpSstImpl::Insert - empty pointer not allowed" );
128 if( !xString )
129 xString.reset( new XclExpString );
130
131 ++mnTotal;
132 sal_uInt32 nSstIndex = 0;
133
134 // calculate hash value in range [0,EXC_SST_HASHTABLE_SIZE)
135 sal_uInt16 nHash = xString->GetHash();
136 nHash = (nHash ^ (nHash / EXC_SST_HASHTABLE_SIZE)) % EXC_SST_HASHTABLE_SIZE;
137
138 XclExpHashVec& rVec = maHashTab[ nHash ];
139 XclExpHashEntry aEntry( xString.get(), mnSize );
140 XclExpHashVec::iterator aIt = ::std::lower_bound( rVec.begin(), rVec.end(), aEntry, XclExpHashEntrySWO() );
141 if( (aIt == rVec.end()) || (*aIt->mpString != *xString) )
142 {
143 nSstIndex = mnSize;
144 maStringVector.push_back( xString );
145 rVec.insert( aIt, aEntry );
146 ++mnSize;
147 }
148 else
149 {
150 nSstIndex = aIt->mnSstIndex;
151 }
152
153 return nSstIndex;
154}
155
157{
158 if( maStringVector.empty() )
159 return;
160
161 SvMemoryStream aExtSst( 8192 );
162
163 sal_uInt32 nBucket = mnSize;
164 while( nBucket > 0x0100 )
165 nBucket /= 2;
166
167 sal_uInt16 nPerBucket = llimit_cast< sal_uInt16 >( nBucket, 8 );
168 sal_uInt16 nBucketIndex = 0;
169
170 // *** write the SST record ***
171
172 rStrm.StartRecord( EXC_ID_SST, 8 );
173
174 rStrm << mnTotal << mnSize;
175 for (auto const& elem : maStringVector)
176 {
177 if( !nBucketIndex )
178 {
179 // write bucket info before string to get correct record position
180 sal_uInt32 nStrmPos = static_cast< sal_uInt32 >( rStrm.GetSvStreamPos() );
181 sal_uInt16 nRecPos = rStrm.GetRawRecPos() + 4;
182 aExtSst.WriteUInt32( nStrmPos ) // stream position
183 .WriteUInt16( nRecPos ) // position from start of SST or CONTINUE
184 .WriteUInt16( 0 ); // reserved
185 }
186
187 rStrm << *elem;
188
189 if( ++nBucketIndex == nPerBucket )
190 nBucketIndex = 0;
191 }
192
193 rStrm.EndRecord();
194
195 // *** write the EXTSST record ***
196
197 rStrm.StartRecord( EXC_ID_EXTSST, 0 );
198
199 rStrm << nPerBucket;
200 rStrm.SetSliceSize( 8 ); // size of one bucket info
201 aExtSst.Seek( STREAM_SEEK_TO_BEGIN );
202 rStrm.CopyFromStream( aExtSst );
203
204 rStrm.EndRecord();
205}
206
208{
209 if( maStringVector.empty() )
210 return;
211
212 sax_fastparser::FSHelperPtr pSst = rStrm.CreateOutputStream(
213 "xl/sharedStrings.xml",
214 u"sharedStrings.xml",
215 rStrm.GetCurrentStream()->getOutputStream(),
216 "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",
217 oox::getRelationship(Relationship::SHAREDSTRINGS));
218 rStrm.PushStream( pSst );
219
220 pSst->startElement( XML_sst,
221 XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)),
222 XML_count, OString::number(mnTotal),
223 XML_uniqueCount, OString::number(mnSize) );
224
225 for (auto const& elem : maStringVector)
226 {
227 pSst->startElement(XML_si);
228 elem->WriteXml( rStrm );
229 pSst->endElement( XML_si );
230 }
231
232 pSst->endElement( XML_sst );
233
234 rStrm.PopStream();
235}
236
238 mxImpl( new XclExpSstImpl )
239{
240}
241
243{
244}
245
246sal_uInt32 XclExpSst::Insert( const XclExpStringRef& xString )
247{
248 return mxImpl->Insert( xString );
249}
250
252{
253 mxImpl->Save( rStrm );
254}
255
257{
258 mxImpl->SaveXml( rStrm );
259}
260
261// Merged cells ===============================================================
262
264 XclExpRoot( rRoot )
265{
266}
267
268void XclExpMergedcells::AppendRange( const ScRange& rRange, sal_uInt32 nBaseXFId )
269{
270 if( GetBiff() == EXC_BIFF8 )
271 {
272 maMergedRanges.push_back( rRange );
273 maBaseXFIds.push_back( nBaseXFId );
274 }
275}
276
277sal_uInt32 XclExpMergedcells::GetBaseXFId( const ScAddress& rPos ) const
278{
279 OSL_ENSURE( maBaseXFIds.size() == maMergedRanges.size(), "XclExpMergedcells::GetBaseXFId - invalid lists" );
280 ScfUInt32Vec::const_iterator aIt = maBaseXFIds.begin();
281 ScRangeList& rNCRanges = const_cast< ScRangeList& >( maMergedRanges );
282 for ( size_t i = 0, nRanges = rNCRanges.size(); i < nRanges; ++i, ++aIt )
283 {
284 const ScRange & rScRange = rNCRanges[ i ];
285 if( rScRange.Contains( rPos ) )
286 return *aIt;
287 }
288 return EXC_XFID_NOTFOUND;
289}
290
292{
293 if( GetBiff() != EXC_BIFF8 )
294 return;
295
296 XclRangeList aXclRanges;
298 size_t nFirstRange = 0;
299 size_t nRemainingRanges = aXclRanges.size();
300 while( nRemainingRanges > 0 )
301 {
302 size_t nRangeCount = ::std::min< size_t >( nRemainingRanges, EXC_MERGEDCELLS_MAXCOUNT );
303 rStrm.StartRecord( EXC_ID_MERGEDCELLS, 2 + 8 * nRangeCount );
304 aXclRanges.WriteSubList( rStrm, nFirstRange, nRangeCount );
305 rStrm.EndRecord();
306 nFirstRange += nRangeCount;
307 nRemainingRanges -= nRangeCount;
308 }
309}
310
312{
313 size_t nCount = maMergedRanges.size();
314 if( !nCount )
315 return;
316 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
317 rWorksheet->startElement(XML_mergeCells, XML_count, OString::number(nCount));
318 for( size_t i = 0; i < nCount; ++i )
319 {
320 const ScRange & rRange = maMergedRanges[ i ];
321 rWorksheet->singleElement(XML_mergeCell, XML_ref,
322 XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), rRange));
323 }
324 rWorksheet->endElement( XML_mergeCells );
325}
326
327// Hyperlinks =================================================================
328
329XclExpHyperlink::XclExpHyperlink( const XclExpRoot& rRoot, const SvxURLField& rUrlField, const ScAddress& rScPos ) :
331 maScPos( rScPos ),
332 mxVarData( new SvMemoryStream ),
333 mnFlags( 0 )
334{
335 const OUString& rUrl = rUrlField.GetURL();
336 const OUString& rRepr = rUrlField.GetRepresentation();
337 INetURLObject aUrlObj( rUrl );
338 const INetProtocol eProtocol = aUrlObj.GetProtocol();
339 bool bWithRepr = !rRepr.isEmpty();
340 XclExpStream aXclStrm( *mxVarData, rRoot ); // using in raw write mode.
341
342 // description
343 if( bWithRepr )
344 {
345 XclExpString aDescr( rRepr, XclStrFlags::ForceUnicode, 255 );
346 aXclStrm << sal_uInt32( aDescr.Len() + 1 ); // string length + 1 trailing zero word
347 aDescr.WriteBuffer( aXclStrm ); // NO flags
348 aXclStrm << sal_uInt16( 0 );
349
351 m_Repr = rRepr;
352 }
353
354 // file link or URL
355 if( eProtocol == INetProtocol::File || eProtocol == INetProtocol::Smb )
356 {
357 sal_uInt16 nLevel;
358 bool bRel;
359 OUString aFileName(
360 BuildFileName(nLevel, bRel, rUrl, rRoot, rRoot.GetOutput() == EXC_OUTPUT_XML_2007));
361
362 if( eProtocol == INetProtocol::Smb )
363 {
364 // #n382718# (and #n261623#) Convert smb notation to '\\'
366 aFileName = aFileName.copy(4); // skip the 'smb:' part
367 aFileName = aFileName.replace('/', '\\');
368 }
369
370 if( !bRel )
373
374 OString aAsciiLink(OUStringToOString(aFileName,
375 rRoot.GetTextEncoding()));
376 XclExpString aLink( aFileName, XclStrFlags::ForceUnicode, 255 );
378 << nLevel
379 << sal_uInt32( aAsciiLink.getLength() + 1 ); // string length + 1 trailing zero byte
380 aXclStrm.Write( aAsciiLink.getStr(), aAsciiLink.getLength() );
381 aXclStrm << sal_uInt8( 0 )
382 << sal_uInt32( 0xDEADFFFF );
383 aXclStrm.WriteZeroBytes( 20 );
384 aXclStrm << sal_uInt32( aLink.GetBufferSize() + 6 )
385 << sal_uInt32( aLink.GetBufferSize() ) // byte count, not string length
386 << sal_uInt16( 0x0003 );
387 aLink.WriteBuffer( aXclStrm ); // NO flags
388
389 if (m_Repr.isEmpty())
390 m_Repr = aFileName;
391
393
394 if( bRel )
395 {
396 for( int i = 0; i < nLevel; ++i )
397 msTarget = "../" + msTarget;
398 }
399 else if (rRoot.GetOutput() != EXC_OUTPUT_XML_2007)
400 {
401 // xls expects the file:/// part appended ( or at least
402 // ms2007 does, ms2010 is more tolerant )
403 msTarget = "file:///" + msTarget;
404 }
405 }
406 else if( eProtocol != INetProtocol::NotValid )
407 {
410 << sal_uInt32( aUrl.GetBufferSize() + 2 ); // byte count + 1 trailing zero word
411 aUrl.WriteBuffer( aXclStrm ); // NO flags
412 aXclStrm << sal_uInt16( 0 );
413
415 if (m_Repr.isEmpty())
416 m_Repr = rUrl;
417
419 }
420 else if( !rUrl.isEmpty() && rUrl[0] == '#' ) // hack for #89066#
421 {
422 OUString aTextMark( rUrl.copy( 1 ) );
423
424 sal_Int32 nSepPos = aTextMark.lastIndexOf( '!' );
425 sal_Int32 nPointPos = aTextMark.lastIndexOf( '.' );
426 // last dot is the separator, if there is no ! after it
427 if(nSepPos < nPointPos)
428 {
429 nSepPos = nPointPos;
430 aTextMark = aTextMark.replaceAt( nSepPos, 1, u"!" );
431 }
432
433 if (nSepPos != -1)
434 {
435 std::u16string_view aSheetName(aTextMark.subView(0, nSepPos));
436
437 if (aSheetName.find(' ') != std::u16string_view::npos && aSheetName[0] != '\'')
438 {
439 aTextMark = "'" + aTextMark.replaceAt(nSepPos, 0, u"'");
440 }
441 }
442 else
443 {
444 SCTAB nTab;
445 if (rRoot.GetDoc().GetTable(aTextMark, nTab))
446 aTextMark += "!A1"; // tdf#143220 link to sheet not valid without cell reference
447 }
448
449 mxTextMark.reset( new XclExpString( aTextMark, XclStrFlags::ForceUnicode, 255 ) );
450 }
451
452 // text mark
453 if( !mxTextMark && aUrlObj.HasMark() )
454 mxTextMark.reset( new XclExpString( aUrlObj.GetMark(), XclStrFlags::ForceUnicode, 255 ) );
455
456 if( mxTextMark )
457 {
458 aXclStrm << sal_uInt32( mxTextMark->Len() + 1 ); // string length + 1 trailing zero word
459 mxTextMark->WriteBuffer( aXclStrm ); // NO flags
460 aXclStrm << sal_uInt16( 0 );
461
463
464 OUString location = XclXmlUtils::ToOUString(*mxTextMark);
465 if (!location.isEmpty() && msTarget.endsWith(Concat2View("#" + location)))
466 msTarget = msTarget.copy(0, msTarget.getLength() - location.getLength() - 1);
467 }
468
469 SetRecSize( 32 + mxVarData->Tell() );
470}
471
473{
474}
475
477 sal_uInt16& rnLevel, bool& rbRel, const OUString& rUrl, const XclExpRoot& rRoot, bool bEncoded )
478{
479 INetURLObject aURLObject( rUrl );
480 OUString aDosName(bEncoded ? aURLObject.GetMainURL(INetURLObject::DecodeMechanism::ToIUri)
481 : aURLObject.getFSysPath(FSysStyle::Dos));
482 rnLevel = 0;
483 rbRel = rRoot.IsRelUrl();
484
485 if( rbRel )
486 {
487 // try to convert to relative file name
488 OUString aTmpName( aDosName );
489 aDosName = INetURLObject::GetRelURL( rRoot.GetBasePath(), rUrl,
492
493 if (aDosName.startsWith(INET_FILE_SCHEME))
494 {
495 // not converted to rel -> back to old, return absolute flag
496 aDosName = aTmpName;
497 rbRel = false;
498 }
499 else if (aDosName.startsWith("./"))
500 {
501 aDosName = aDosName.copy(2);
502 }
503 else
504 {
505 while (aDosName.startsWith("../"))
506 {
507 aDosName = aDosName.copy(3);
508 ++rnLevel;
509 }
510 }
511 }
512 return aDosName;
513}
514
516{
517 sal_uInt16 nXclCol = static_cast< sal_uInt16 >( maScPos.Col() );
518 sal_uInt16 nXclRow = static_cast< sal_uInt16 >( maScPos.Row() );
519 rStrm << nXclRow << nXclRow << nXclCol << nXclCol;
521}
522
524{
526 << sal_uInt32( 2 )
527 << mnFlags;
528
530 rStrm.CopyFromStream( *mxVarData );
531}
532
534{
535 OUString sId = !msTarget.isEmpty() ? rStrm.addRelation( rStrm.GetCurrentStream()->getOutputStream(),
536 oox::getRelationship(Relationship::HYPERLINK),
537 msTarget, true ) : OUString();
538 std::optional<OString> sTextMark;
539 if (mxTextMark)
541 rStrm.GetCurrentStream()->singleElement( XML_hyperlink,
542 XML_ref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), maScPos),
543 FSNS( XML_r, XML_id ), sax_fastparser::UseIf(sId, !sId.isEmpty()),
544 XML_location, sTextMark,
545 // OOXTODO: XML_tooltip, from record HLinkTooltip 800h wzTooltip
546 XML_display, m_Repr );
547}
548
549// Label ranges ===============================================================
550
552 XclExpRoot( rRoot )
553{
554 SCTAB nScTab = GetCurrScTab();
555 // row label ranges
557 // row labels only over 1 column (restriction of Excel97/2000/XP)
558 for ( size_t i = 0, nRanges = maRowRanges.size(); i < nRanges; ++i )
559 {
560 ScRange & rScRange = maRowRanges[ i ];
561 if( rScRange.aStart.Col() != rScRange.aEnd.Col() )
562 rScRange.aEnd.SetCol( rScRange.aStart.Col() );
563 }
564 // col label ranges
566}
567
569 const ScRangePairListRef& xLabelRangesRef, SCTAB nScTab )
570{
571 for ( size_t i = 0, nPairs = xLabelRangesRef->size(); i < nPairs; ++i )
572 {
573 const ScRangePair & rRangePair = (*xLabelRangesRef)[i];
574 const ScRange& rScRange = rRangePair.GetRange( 0 );
575 if( rScRange.aStart.Tab() == nScTab )
576 rScRanges.push_back( rScRange );
577 }
578}
579
581{
583 XclRangeList aRowXclRanges, aColXclRanges;
584 rAddrConv.ConvertRangeList( aRowXclRanges, maRowRanges, false );
585 rAddrConv.ConvertRangeList( aColXclRanges, maColRanges, false );
586 if( !aRowXclRanges.empty() || !aColXclRanges.empty() )
587 {
588 rStrm.StartRecord( EXC_ID_LABELRANGES, 4 + 8 * (aRowXclRanges.size() + aColXclRanges.size()) );
589 rStrm << aRowXclRanges << aColXclRanges;
590 rStrm.EndRecord();
591 }
592}
593
594// Conditional formatting ====================================================
595
597class XclExpCFImpl : protected XclExpRoot
598{
599public:
600 explicit XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin );
601
605
606private:
614 sal_uInt32 mnFontColorId;
617 sal_Int32 mnPriority;
628};
629
630XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin ) :
631 XclExpRoot( rRoot ),
632 mrFormatEntry( rFormatEntry ),
633 maOrigin( aOrigin ),
634 mnFontColorId( 0 ),
636 mnOperator( EXC_CF_CMP_NONE ),
637 mnPriority( nPriority ),
638 mbFontUsed( false ),
639 mbHeightUsed( false ),
640 mbWeightUsed( false ),
641 mbColorUsed( false ),
642 mbUnderlUsed( false ),
643 mbItalicUsed( false ),
644 mbStrikeUsed( false ),
645 mbBorderUsed( false ),
646 mbPattUsed( false ),
647 mbFormula2(false)
648{
649 // Set correct tab for maOrigin from GetValidSrcPos() of the format-entry.
650 ScAddress aValidSrcPos = mrFormatEntry.GetValidSrcPos();
651 maOrigin.SetTab(aValidSrcPos.Tab());
652
653 /* Get formatting attributes here, and not in WriteBody(). This is needed to
654 correctly insert all colors into the palette. */
655
656 if( SfxStyleSheetBase* pStyleSheet = GetDoc().GetStyleSheetPool()->Find( mrFormatEntry.GetStyle(), SfxStyleFamily::Para ) )
657 {
658 const SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
659
660 // font
668 if( mbFontUsed )
669 {
670 vcl::Font aFont;
671 ScPatternAttr::GetFont( aFont, rItemSet, SC_AUTOCOL_RAW );
674 }
675
676 // border
677 mbBorderUsed = ScfTools::CheckItem( rItemSet, ATTR_BORDER, true );
678 if( mbBorderUsed )
679 maBorder.FillFromItemSet( rItemSet, GetPalette(), GetBiff() );
680
681 // pattern
683 if( mbPattUsed )
684 maArea.FillFromItemSet( rItemSet, GetPalette(), true );
685 }
686
687 // *** mode and comparison operator ***
688
689 switch( rFormatEntry.GetOperation() )
690 {
693 break;
696 mbFormula2 = true;
697 break;
700 mbFormula2 = true;
701 break;
704 break;
707 break;
710 break;
713 break;
716 break;
719 break;
722 break;
723 default:
725 OSL_FAIL( "XclExpCF::WriteBody - unknown condition type" );
726 }
727}
728
730{
731
732 // *** formulas ***
733
735
736 std::unique_ptr< ScTokenArray > xScTokArr( mrFormatEntry.CreateFlatCopiedTokenArray( 0 ) );
737 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_CONDFMT, *xScTokArr );
738
739 if (mbFormula2)
740 {
742 mxTokArr2 = rFmlaComp.CreateFormula( EXC_FMLATYPE_CONDFMT, *xScTokArr );
743 }
744
745 // *** mode and comparison operator ***
746
747 rStrm << mnType << mnOperator;
748
749 // *** formula sizes ***
750
751 sal_uInt16 nFmlaSize1 = mxTokArr1 ? mxTokArr1->GetSize() : 0;
752 sal_uInt16 nFmlaSize2 = mxTokArr2 ? mxTokArr2->GetSize() : 0;
753 rStrm << nFmlaSize1 << nFmlaSize2;
754
755 // *** formatting blocks ***
756
758 {
759 sal_uInt32 nFlags = EXC_CF_ALLDEFAULT;
760
764
765 // attributes used -> set flags to 0.
768
769 rStrm << nFlags << sal_uInt16( 0 );
770
771 if( mbFontUsed )
772 {
773 // font height, 0xFFFFFFFF indicates unused
774 sal_uInt32 nHeight = mbHeightUsed ? maFontData.mnHeight : 0xFFFFFFFF;
775 // font style: italic and strikeout
776 sal_uInt32 nStyle = 0;
779 // font color, 0xFFFFFFFF indicates unused
780 sal_uInt32 nColor = mbColorUsed ? GetPalette().GetColorIndex( mnFontColorId ) : 0xFFFFFFFF;
781 // font used flags for italic, weight, and strikeout -> 0 = used, 1 = default
782 sal_uInt32 nFontFlags1 = EXC_CF_FONT_ALLDEFAULT;
785 // font used flag for underline -> 0 = used, 1 = default
786 sal_uInt32 nFontFlags3 = mbUnderlUsed ? 0 : EXC_CF_FONT_UNDERL;
787
788 rStrm.WriteZeroBytesToRecord( 64 );
789 rStrm << nHeight
790 << nStyle
794 rStrm.WriteZeroBytesToRecord( 3 );
795 rStrm << nColor
796 << sal_uInt32( 0 )
797 << nFontFlags1
798 << EXC_CF_FONT_ESCAPEM // escapement never used -> set the flag
799 << nFontFlags3;
800 rStrm.WriteZeroBytesToRecord( 16 );
801 rStrm << sal_uInt16( 1 ); // must be 1
802 }
803
804 if( mbBorderUsed )
805 {
806 sal_uInt16 nLineStyle = 0;
807 sal_uInt32 nLineColor = 0;
809 maBorder.FillToCF8( nLineStyle, nLineColor );
810 rStrm << nLineStyle << nLineColor << sal_uInt16( 0 );
811 }
812
813 if( mbPattUsed )
814 {
815 sal_uInt16 nPattern = 0, nColor = 0;
817 maArea.FillToCF8( nPattern, nColor );
818 rStrm << nPattern << nColor;
819 }
820 }
821 else
822 {
823 // no data blocks at all
824 rStrm << sal_uInt32( 0 ) << sal_uInt16( 0 );
825 }
826
827 // *** formulas ***
828
829 if( mxTokArr1 )
830 mxTokArr1->WriteArray( rStrm );
831 if( mxTokArr2 )
832 mxTokArr2->WriteArray( rStrm );
833}
834
835namespace {
836
837const char* GetOperatorString(ScConditionMode eMode, bool& bFrmla2)
838{
839 const char *pRet = nullptr;
840 switch(eMode)
841 {
843 pRet = "equal";
844 break;
846 pRet = "lessThan";
847 break;
849 pRet = "greaterThan";
850 break;
852 pRet = "lessThanOrEqual";
853 break;
855 pRet = "greaterThanOrEqual";
856 break;
858 pRet = "notEqual";
859 break;
861 bFrmla2 = true;
862 pRet = "between";
863 break;
865 bFrmla2 = true;
866 pRet = "notBetween";
867 break;
869 pRet = nullptr;
870 break;
872 pRet = nullptr;
873 break;
875 pRet = "beginsWith";
876 break;
878 pRet = "endsWith";
879 break;
881 pRet = "containsText";
882 break;
884 pRet = "notContains";
885 break;
887 break;
889 default:
890 break;
891 }
892 return pRet;
893}
894
895const char* GetTypeString(ScConditionMode eMode)
896{
897 switch(eMode)
898 {
900 return "expression";
905 return "top10";
910 return "aboveAverage";
912 return "uniqueValues";
914 return "duplicateValues";
916 return "containsErrors";
918 return "notContainsErrors";
920 return "beginsWith";
922 return "endsWith";
924 return "containsText";
926 return "notContainsText";
927 default:
928 return "cellIs";
929 }
930}
931
932bool IsTopBottomRule(ScConditionMode eMode)
933{
934 switch(eMode)
935 {
940 return true;
941 default:
942 break;
943 }
944
945 return false;
946}
947
948bool IsTextRule(ScConditionMode eMode)
949{
950 switch(eMode)
951 {
956 return true;
957 default:
958 break;
959 }
960
961 return false;
962}
963
964bool RequiresFormula(ScConditionMode eMode)
965{
966 if (IsTopBottomRule(eMode))
967 return false;
968 else if (IsTextRule(eMode))
969 return false;
970
971 switch (eMode)
972 {
977 return false;
978 default:
979 break;
980 }
981
982 return true;
983}
984
985bool RequiresFixedFormula(ScConditionMode eMode)
986{
987 switch(eMode)
988 {
995 return true;
996 default:
997 break;
998 }
999
1000 return false;
1001}
1002
1003OString GetFixedFormula(ScConditionMode eMode, const ScAddress& rAddress, std::string_view rText)
1004{
1005 OStringBuffer aBuffer;
1006 XclXmlUtils::ToOString(aBuffer, rAddress);
1007 OString aPos = aBuffer.makeStringAndClear();
1008 switch (eMode)
1009 {
1011 return OString("ISERROR(" + aPos + ")") ;
1013 return OString("NOT(ISERROR(" + aPos + "))") ;
1015 return OString("LEFT(" + aPos + ",LEN(\"" + rText + "\"))=\"" + rText + "\"");
1017 return OString("RIGHT(" + aPos +",LEN(\"" + rText + "\"))=\"" + rText + "\"");
1019 return OString(OString::Concat("NOT(ISERROR(SEARCH(\"") + rText + "\"," + aPos + ")))");
1021 return OString(OString::Concat("ISERROR(SEARCH(\"") + rText + "\"," + aPos + "))");
1022 default:
1023 break;
1024 }
1025
1026 return "";
1027}
1028
1029}
1030
1032{
1033 bool bFmla2 = false;
1035 bool bAboveAverage = eOperation == ScConditionMode::AboveAverage ||
1037 bool bEqualAverage = eOperation == ScConditionMode::AboveEqualAverage ||
1039 bool bBottom = eOperation == ScConditionMode::Bottom10
1040 || eOperation == ScConditionMode::BottomPercent;
1041 bool bPercent = eOperation == ScConditionMode::TopPercent ||
1042 eOperation == ScConditionMode::BottomPercent;
1043 OUString aRank("0");
1044 if(IsTopBottomRule(eOperation))
1045 {
1046 // position and formula grammar are not important
1047 // we only store a number there
1048 aRank = mrFormatEntry.GetExpression(ScAddress(0,0,0), 0);
1049 }
1050 OString aText;
1051 if(IsTextRule(eOperation))
1052 {
1053 // we need to write the text without quotes
1054 // we have to actually get the string from
1055 // the token array for that
1056 std::unique_ptr<ScTokenArray> pTokenArray(mrFormatEntry.CreateFlatCopiedTokenArray(0));
1057 if(pTokenArray->GetLen())
1058 aText = pTokenArray->FirstToken()->GetString().getString().toUtf8();
1059 }
1060
1061 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1062 rWorksheet->startElement( XML_cfRule,
1063 XML_type, GetTypeString( mrFormatEntry.GetOperation() ),
1064 XML_priority, OString::number(mnPriority + 1),
1065 XML_operator, GetOperatorString( mrFormatEntry.GetOperation(), bFmla2 ),
1066 XML_aboveAverage, ToPsz10(bAboveAverage),
1067 XML_equalAverage, ToPsz10(bEqualAverage),
1068 XML_bottom, ToPsz10(bBottom),
1069 XML_percent, ToPsz10(bPercent),
1070 XML_rank, aRank,
1071 XML_text, aText,
1072 XML_dxfId, OString::number(GetDxfs().GetDxfId(mrFormatEntry.GetStyle())) );
1073
1074 if (RequiresFixedFormula(eOperation))
1075 {
1076 rWorksheet->startElement(XML_formula);
1077 OString aFormula = GetFixedFormula(eOperation, maOrigin, aText);
1078 rWorksheet->writeEscaped(aFormula.getStr());
1079 rWorksheet->endElement( XML_formula );
1080 }
1081 else if(RequiresFormula(eOperation))
1082 {
1083 rWorksheet->startElement(XML_formula);
1084 std::unique_ptr<ScTokenArray> pTokenArray(mrFormatEntry.CreateFlatCopiedTokenArray(0));
1086 pTokenArray.get()));
1087 rWorksheet->endElement( XML_formula );
1088 if (bFmla2)
1089 {
1090 rWorksheet->startElement(XML_formula);
1091 std::unique_ptr<ScTokenArray> pTokenArray2(mrFormatEntry.CreateFlatCopiedTokenArray(1));
1093 pTokenArray2.get()));
1094 rWorksheet->endElement( XML_formula );
1095 }
1096 }
1097 // OOXTODO: XML_extLst
1098 rWorksheet->endElement( XML_cfRule );
1099}
1100
1101XclExpCF::XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin ) :
1103 XclExpRoot( rRoot ),
1104 mxImpl( new XclExpCFImpl( rRoot, rFormatEntry, nPriority, aOrigin ) )
1105{
1106}
1107
1109{
1110}
1111
1113{
1114 mxImpl->WriteBody( rStrm );
1115}
1116
1118{
1119 mxImpl->SaveXml( rStrm );
1120}
1121
1122XclExpDateFormat::XclExpDateFormat( const XclExpRoot& rRoot, const ScCondDateFormatEntry& rFormatEntry, sal_Int32 nPriority ):
1124 XclExpRoot( rRoot ),
1125 mrFormatEntry(rFormatEntry),
1126 mnPriority(nPriority)
1127{
1128}
1129
1131{
1132}
1133
1134namespace {
1135
1136const char* getTimePeriodString( condformat::ScCondFormatDateType eType )
1137{
1138 switch(eType)
1139 {
1140 case condformat::TODAY:
1141 return "today";
1143 return "yesterday";
1145 return "yesterday";
1147 return "thisWeek";
1149 return "lastWeek";
1151 return "nextWeek";
1153 return "thisMonth";
1155 return "lastMonth";
1157 return "nextMonth";
1159 return "last7Days";
1160 default:
1161 break;
1162 }
1163 return nullptr;
1164}
1165
1166}
1167
1169{
1170 // only write the supported entries into OOXML
1171 const char* sTimePeriod = getTimePeriodString(mrFormatEntry.GetDateType());
1172 if(!sTimePeriod)
1173 return;
1174
1175 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1176 rWorksheet->startElement( XML_cfRule,
1177 XML_type, "timePeriod",
1178 XML_priority, OString::number(mnPriority + 1),
1179 XML_timePeriod, sTimePeriod,
1180 XML_dxfId, OString::number(GetDxfs().GetDxfId(mrFormatEntry.GetStyleName())) );
1181 rWorksheet->endElement( XML_cfRule);
1182}
1183
1184XclExpCfvo::XclExpCfvo(const XclExpRoot& rRoot, const ScColorScaleEntry& rEntry, const ScAddress& rAddr, bool bFirst):
1185 XclExpRoot( rRoot ),
1186 mrEntry(rEntry),
1187 maSrcPos(rAddr),
1188 mbFirst(bFirst)
1189{
1190}
1191
1192namespace {
1193
1194OString getColorScaleType( const ScColorScaleEntry& rEntry, bool bFirst )
1195{
1196 switch(rEntry.GetType())
1197 {
1198 case COLORSCALE_MIN:
1199 return "min";
1200 case COLORSCALE_MAX:
1201 return "max";
1202 case COLORSCALE_PERCENT:
1203 return "percent";
1204 case COLORSCALE_FORMULA:
1205 return "formula";
1206 case COLORSCALE_AUTO:
1207 if(bFirst)
1208 return "min";
1209 else
1210 return "max";
1212 return "percentile";
1213 default:
1214 break;
1215 }
1216
1217 return "num";
1218}
1219
1220}
1221
1223{
1224 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1225
1226 OString aValue;
1228 {
1231 aValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
1232 }
1233 else
1234 {
1235 aValue = OString::number( mrEntry.GetValue() );
1236 }
1237
1238 rWorksheet->startElement( XML_cfvo,
1239 XML_type, getColorScaleType(mrEntry, mbFirst),
1240 XML_val, aValue );
1241
1242 rWorksheet->endElement( XML_cfvo );
1243}
1244
1246 XclExpRoot( rRoot ),
1247 mrColor( rColor )
1248{
1249}
1250
1252{
1253}
1254
1256{
1257 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1258
1259 rWorksheet->startElement(XML_color, XML_rgb, XclXmlUtils::ToOString(mrColor));
1260
1261 rWorksheet->endElement( XML_color );
1262}
1263
1264namespace {
1265
1266OString createHexStringFromDigit(sal_uInt8 nDigit)
1267{
1268 OString aString = OString::number( nDigit, 16 );
1269 if(aString.getLength() == 1)
1270 aString += OString::number(0);
1271 return aString;
1272}
1273
1274OString createGuidStringFromInt(sal_uInt8 nGuid[16])
1275{
1276 OStringBuffer aBuffer;
1277 aBuffer.append('{');
1278 for(size_t i = 0; i < 16; ++i)
1279 {
1280 aBuffer.append(createHexStringFromDigit(nGuid[i]));
1281 if(i == 3|| i == 5 || i == 7 || i == 9 )
1282 aBuffer.append('-');
1283 }
1284 aBuffer.append('}');
1285 OString aString = aBuffer.makeStringAndClear();
1286 return aString.toAsciiUpperCase();
1287}
1288
1289OString generateGUIDString()
1290{
1291 sal_uInt8 nGuid[16];
1292 rtl_createUuid(nGuid, nullptr, true);
1293 return createGuidStringFromInt(nGuid);
1294}
1295
1296}
1297
1298XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, const XclExtLstRef& xExtLst, sal_Int32& rIndex ) :
1300 XclExpRoot( rRoot )
1301{
1302 const ScRangeList& aScRanges = rCondFormat.GetRange();
1303 GetAddressConverter().ConvertRangeList( maXclRanges, aScRanges, true );
1304 if( maXclRanges.empty() )
1305 return;
1306
1307 std::vector<XclExpExtCondFormatData> aExtEntries;
1308 ScAddress aOrigin = aScRanges.Combine().aStart;
1309 for( size_t nIndex = 0, nCount = rCondFormat.size(); nIndex < nCount; ++nIndex )
1310 if( const ScFormatEntry* pFormatEntry = rCondFormat.GetEntry( nIndex ) )
1311 {
1312 if(pFormatEntry->GetType() == ScFormatEntry::Type::Condition)
1313 maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), ++rIndex, aOrigin ) );
1314 else if(pFormatEntry->GetType() == ScFormatEntry::Type::ExtCondition)
1315 {
1316 const ScCondFormatEntry& rFormat = static_cast<const ScCondFormatEntry&>(*pFormatEntry);
1317 XclExpExtCondFormatData aExtEntry;
1318 aExtEntry.nPriority = ++rIndex;
1319 aExtEntry.aGUID = generateGUIDString();
1320 aExtEntry.pEntry = &rFormat;
1321 aExtEntries.push_back(aExtEntry);
1322 }
1323 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Colorscale)
1324 maCFList.AppendNewRecord( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*pFormatEntry), ++rIndex ) );
1325 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Databar)
1326 {
1327 const ScDataBarFormat& rFormat = static_cast<const ScDataBarFormat&>(*pFormatEntry);
1328 XclExpExtCondFormatData aExtEntry;
1329 aExtEntry.nPriority = -1;
1330 aExtEntry.aGUID = generateGUIDString();
1331 aExtEntry.pEntry = &rFormat;
1332 aExtEntries.push_back(aExtEntry);
1333
1334 maCFList.AppendNewRecord( new XclExpDataBar( GetRoot(), rFormat, ++rIndex, aExtEntry.aGUID));
1335 }
1336 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Iconset)
1337 {
1338 // don't export iconSet entries that are not in OOXML
1339 const ScIconSetFormat& rIconSet = static_cast<const ScIconSetFormat&>(*pFormatEntry);
1340 bool bNeedsExt = false;
1341 switch (rIconSet.GetIconSetData()->eIconSetType)
1342 {
1343 case IconSet_3Smilies:
1345 case IconSet_3Stars:
1346 case IconSet_3Triangles:
1347 case IconSet_5Boxes:
1348 {
1349 bNeedsExt = true;
1350 }
1351 break;
1352 default:
1353 break;
1354 }
1355
1356 bNeedsExt |= rIconSet.GetIconSetData()->mbCustom;
1357
1358 if (bNeedsExt)
1359 {
1360 XclExpExtCondFormatData aExtEntry;
1361 aExtEntry.nPriority = ++rIndex;
1362 aExtEntry.aGUID = generateGUIDString();
1363 aExtEntry.pEntry = &rIconSet;
1364 aExtEntries.push_back(aExtEntry);
1365 }
1366 else
1367 maCFList.AppendNewRecord( new XclExpIconSet( GetRoot(), rIconSet, ++rIndex ) );
1368 }
1369 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Date)
1370 maCFList.AppendNewRecord( new XclExpDateFormat( GetRoot(), static_cast<const ScCondDateFormatEntry&>(*pFormatEntry), ++rIndex ) );
1371 }
1373
1374 if(!aExtEntries.empty() && xExtLst)
1375 {
1376 XclExpExt* pParent = xExtLst->GetItem( XclExpExtDataBarType );
1377 if( !pParent )
1378 {
1379 xExtLst->AddRecord( new XclExpExtCondFormat( *xExtLst ) );
1380 pParent = xExtLst->GetItem( XclExpExtDataBarType );
1381 }
1382 static_cast<XclExpExtCondFormat*>(xExtLst->GetItem( XclExpExtDataBarType ))->AddRecord(
1383 new XclExpExtConditionalFormatting( *pParent, aExtEntries, aScRanges));
1384 }
1385}
1386
1388{
1389}
1390
1392{
1393 // ccf (2 bytes): An unsigned integer that specifies the count of CF records that follow this
1394 // record. MUST be greater than or equal to 0x0001, and less than or equal to 0x0003.
1395
1396 SAL_WARN_IF( maCFList.GetSize() > 3, "sc.filter", "More than 3 conditional filters for cell(s), won't export");
1397
1398 return !maCFList.IsEmpty() && maCFList.GetSize() <= 3 && !maXclRanges.empty();
1399}
1400
1402{
1403 return !maCFList.IsEmpty() && !maXclRanges.empty();
1404}
1405
1407{
1408 if( IsValidForBinary() )
1409 {
1411 maCFList.Save( rStrm );
1412 }
1413}
1414
1416{
1417 OSL_ENSURE( !maCFList.IsEmpty(), "XclExpCondfmt::WriteBody - no CF records to write" );
1418 OSL_ENSURE( !maXclRanges.empty(), "XclExpCondfmt::WriteBody - no cell ranges found" );
1419
1420 rStrm << static_cast< sal_uInt16 >( maCFList.GetSize() )
1421 << sal_uInt16( 1 )
1423 << maXclRanges;
1424}
1425
1427{
1428 if( !IsValidForXml() )
1429 return;
1430
1431 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1432 rWorksheet->startElement( XML_conditionalFormatting,
1433 XML_sqref, msSeqRef
1434 // OOXTODO: XML_pivot
1435 );
1436
1438
1439 rWorksheet->endElement( XML_conditionalFormatting );
1440}
1441
1442XclExpColorScale::XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat, sal_Int32 nPriority ):
1443 XclExpRoot( rRoot ),
1444 mnPriority( nPriority )
1445{
1446 const ScRange & rRange = rFormat.GetRange().front();
1447 ScAddress aAddr = rRange.aStart;
1448 for(const auto& rxColorScaleEntry : rFormat)
1449 {
1450 // exact position is not important, we allow only absolute refs
1451
1452 XclExpCfvoList::RecordRefType xCfvo( new XclExpCfvo( GetRoot(), *rxColorScaleEntry, aAddr ) );
1453 maCfvoList.AppendRecord( xCfvo );
1454 XclExpColScaleColList::RecordRefType xClo( new XclExpColScaleCol( GetRoot(), rxColorScaleEntry->GetColor() ) );
1455 maColList.AppendRecord( xClo );
1456 }
1457}
1458
1460{
1461 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1462
1463 rWorksheet->startElement( XML_cfRule,
1464 XML_type, "colorScale",
1465 XML_priority, OString::number(mnPriority + 1) );
1466
1467 rWorksheet->startElement(XML_colorScale);
1468
1471
1472 rWorksheet->endElement( XML_colorScale );
1473
1474 rWorksheet->endElement( XML_cfRule );
1475}
1476
1477XclExpDataBar::XclExpDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, sal_Int32 nPriority, OString aGUID):
1478 XclExpRoot( rRoot ),
1479 mrFormat( rFormat ),
1480 mnPriority( nPriority ),
1481 maGUID(std::move(aGUID))
1482{
1483 const ScRange & rRange = rFormat.GetRange().front();
1484 ScAddress aAddr = rRange.aStart;
1485 // exact position is not important, we allow only absolute refs
1486 mpCfvoLowerLimit.reset(
1487 new XclExpCfvo(GetRoot(), *mrFormat.GetDataBarData()->mpLowerLimit, aAddr, true));
1488 mpCfvoUpperLimit.reset(
1489 new XclExpCfvo(GetRoot(), *mrFormat.GetDataBarData()->mpUpperLimit, aAddr, false));
1490
1492}
1493
1495{
1496 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1497
1498 rWorksheet->startElement( XML_cfRule,
1499 XML_type, "dataBar",
1500 XML_priority, OString::number(mnPriority + 1) );
1501
1502 rWorksheet->startElement( XML_dataBar,
1503 XML_showValue, ToPsz10(!mrFormat.GetDataBarData()->mbOnlyBar),
1504 XML_minLength, OString::number(sal_uInt32(mrFormat.GetDataBarData()->mnMinLength)),
1505 XML_maxLength, OString::number(sal_uInt32(mrFormat.GetDataBarData()->mnMaxLength)) );
1506
1507 mpCfvoLowerLimit->SaveXml(rStrm);
1508 mpCfvoUpperLimit->SaveXml(rStrm);
1509 mpCol->SaveXml(rStrm);
1510
1511 rWorksheet->endElement( XML_dataBar );
1512
1513 // extLst entries for Excel 2010 and 2013
1514 rWorksheet->startElement(XML_extLst);
1515 rWorksheet->startElement(XML_ext,
1516 FSNS(XML_xmlns, XML_x14), rStrm.getNamespaceURL(OOX_NS(xls14Lst)),
1517 XML_uri, "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}");
1518
1519 rWorksheet->startElementNS( XML_x14, XML_id );
1520 rWorksheet->write(maGUID);
1521 rWorksheet->endElementNS( XML_x14, XML_id );
1522
1523 rWorksheet->endElement( XML_ext );
1524 rWorksheet->endElement( XML_extLst );
1525
1526 rWorksheet->endElement( XML_cfRule );
1527}
1528
1529XclExpIconSet::XclExpIconSet( const XclExpRoot& rRoot, const ScIconSetFormat& rFormat, sal_Int32 nPriority ):
1530 XclExpRoot( rRoot ),
1531 mrFormat( rFormat ),
1532 mnPriority( nPriority )
1533{
1534 const ScRange & rRange = rFormat.GetRange().front();
1535 ScAddress aAddr = rRange.aStart;
1536 for (auto const& itr : rFormat)
1537 {
1538 // exact position is not important, we allow only absolute refs
1539
1540 XclExpCfvoList::RecordRefType xCfvo( new XclExpCfvo( GetRoot(), *itr, aAddr ) );
1541 maCfvoList.AppendRecord( xCfvo );
1542 }
1543}
1544
1546{
1547 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1548
1549 rWorksheet->startElement( XML_cfRule,
1550 XML_type, "iconSet",
1551 XML_priority, OString::number(mnPriority + 1) );
1552
1554 rWorksheet->startElement( XML_iconSet,
1555 XML_iconSet, pIconSetName,
1558
1560
1561 rWorksheet->endElement( XML_iconSet );
1562 rWorksheet->endElement( XML_cfRule );
1563}
1564
1566 XclExpRoot( rRoot )
1567{
1568 if( const ScConditionalFormatList* pCondFmtList = GetDoc().GetCondFormList(GetCurrScTab()) )
1569 {
1570 sal_Int32 nIndex = 0;
1571 for( const auto& rxCondFmt : *pCondFmtList)
1572 {
1573 XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), *rxCondFmt, xExtLst, nIndex ));
1574 if( xCondfmtRec->IsValidForXml() )
1575 maCondfmtList.AppendRecord( xCondfmtRec );
1576 }
1577 }
1578}
1579
1581{
1583}
1584
1586{
1588}
1589
1590// Validation =================================================================
1591
1592namespace {
1593
1595void lclWriteDvFormula( XclExpStream& rStrm, const XclTokenArray* pXclTokArr )
1596{
1597 sal_uInt16 nFmlaSize = pXclTokArr ? pXclTokArr->GetSize() : 0;
1598 rStrm << nFmlaSize << sal_uInt16( 0 );
1599 if( pXclTokArr )
1600 pXclTokArr->WriteArray( rStrm );
1601}
1602
1604void lclWriteDvFormula( XclExpStream& rStrm, const XclExpString& rString )
1605{
1606 // fake a formula with a single tStr token
1607 rStrm << static_cast< sal_uInt16 >( rString.GetSize() + 1 )
1608 << sal_uInt16( 0 )
1609 << EXC_TOKID_STR
1610 << rString;
1611}
1612
1613const char* lcl_GetValidationType( sal_uInt32 nFlags )
1614{
1615 switch( nFlags & EXC_DV_MODE_MASK )
1616 {
1617 case EXC_DV_MODE_ANY: return "none";
1618 case EXC_DV_MODE_WHOLE: return "whole";
1619 case EXC_DV_MODE_DECIMAL: return "decimal";
1620 case EXC_DV_MODE_LIST: return "list";
1621 case EXC_DV_MODE_DATE: return "date";
1622 case EXC_DV_MODE_TIME: return "time";
1623 case EXC_DV_MODE_TEXTLEN: return "textLength";
1624 case EXC_DV_MODE_CUSTOM: return "custom";
1625 }
1626 return nullptr;
1627}
1628
1629const char* lcl_GetOperatorType( sal_uInt32 nFlags )
1630{
1631 switch( nFlags & EXC_DV_COND_MASK )
1632 {
1633 case EXC_DV_COND_BETWEEN: return "between";
1634 case EXC_DV_COND_NOTBETWEEN: return "notBetween";
1635 case EXC_DV_COND_EQUAL: return "equal";
1636 case EXC_DV_COND_NOTEQUAL: return "notEqual";
1637 case EXC_DV_COND_GREATER: return "greaterThan";
1638 case EXC_DV_COND_LESS: return "lessThan";
1639 case EXC_DV_COND_EQGREATER: return "greaterThanOrEqual";
1640 case EXC_DV_COND_EQLESS: return "lessThanOrEqual";
1641 }
1642 return nullptr;
1643}
1644
1645const char* lcl_GetErrorType( sal_uInt32 nFlags )
1646{
1647 switch (nFlags & EXC_DV_ERROR_MASK)
1648 {
1649 case EXC_DV_ERROR_STOP: return "stop";
1650 case EXC_DV_ERROR_WARNING: return "warning";
1651 case EXC_DV_ERROR_INFO: return "information";
1652 }
1653 return nullptr;
1654}
1655
1656void lcl_SetValidationText(const OUString& rText, XclExpString& rValidationText)
1657{
1658 if ( !rText.isEmpty() )
1659 {
1660 // maximum length allowed in Excel is 255 characters
1661 if ( rText.getLength() > 255 )
1662 {
1663 OUStringBuffer aBuf( rText );
1664 rValidationText.Assign(
1665 comphelper::string::truncateToLength(aBuf, 255).makeStringAndClear() );
1666 }
1667 else
1668 rValidationText.Assign( rText );
1669 }
1670 else
1671 rValidationText.Assign( '\0' );
1672}
1673
1674} // namespace
1675
1676XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uInt32 nScHandle ) :
1678 XclExpRoot( rRoot ),
1679 mnFlags( 0 ),
1680 mnScHandle( nScHandle )
1681{
1682 if( const ScValidationData* pValData = GetDoc().GetValidationEntry( mnScHandle ) )
1683 {
1684 // prompt box - empty string represented by single NUL character
1685 OUString aTitle, aText;
1686 bool bShowPrompt = pValData->GetInput( aTitle, aText );
1687 lcl_SetValidationText(aTitle, maPromptTitle);
1688 lcl_SetValidationText(aText, maPromptText);
1689
1690 // error box - empty string represented by single NUL character
1691 ScValidErrorStyle eScErrorStyle;
1692 bool bShowError = pValData->GetErrMsg( aTitle, aText, eScErrorStyle );
1693 lcl_SetValidationText(aTitle, maErrorTitle);
1694 lcl_SetValidationText(aText, maErrorText);
1695
1696 // flags
1697 switch( pValData->GetDataMode() )
1698 {
1699 case SC_VALID_ANY: mnFlags |= EXC_DV_MODE_ANY; break;
1702 case SC_VALID_LIST: mnFlags |= EXC_DV_MODE_LIST; break;
1703 case SC_VALID_DATE: mnFlags |= EXC_DV_MODE_DATE; break;
1704 case SC_VALID_TIME: mnFlags |= EXC_DV_MODE_TIME; break;
1707 default: OSL_FAIL( "XclExpDV::XclExpDV - unknown mode" );
1708 }
1709
1710 switch( pValData->GetOperation() )
1711 {
1721 default: OSL_FAIL( "XclExpDV::XclExpDV - unknown condition" );
1722 }
1723 switch( eScErrorStyle )
1724 {
1728 case SC_VALERR_MACRO:
1729 // set INFO for validity with macro call, delete title
1731 maErrorTitle.Assign( '\0' ); // contains macro name
1732 break;
1733 default: OSL_FAIL( "XclExpDV::XclExpDV - unknown error style" );
1734 }
1735 ::set_flag( mnFlags, EXC_DV_IGNOREBLANK, pValData->IsIgnoreBlank() );
1736 ::set_flag( mnFlags, EXC_DV_SUPPRESSDROPDOWN, pValData->GetListType() == css::sheet::TableValidationVisibility::INVISIBLE );
1737 ::set_flag( mnFlags, EXC_DV_SHOWPROMPT, bShowPrompt );
1738 ::set_flag( mnFlags, EXC_DV_SHOWERROR, bShowError );
1739
1740 // formulas
1742
1743 // first formula
1744 std::unique_ptr< ScTokenArray > xScTokArr = pValData->CreateFlatCopiedTokenArray( 0 );
1745 if (xScTokArr)
1746 {
1747 if( pValData->GetDataMode() == SC_VALID_LIST )
1748 {
1749 OUString aString;
1750 if( XclTokenArrayHelper::GetStringList( aString, *xScTokArr, '\n' ) )
1751 {
1752 bool bList = false;
1753 OUStringBuffer sListBuf;
1754 OUStringBuffer sFormulaBuf;
1755 sFormulaBuf.append( '"' );
1756 /* Formula is a list of string tokens -> build the Excel string.
1757 Data validity is BIFF8 only (important for the XclExpString object).
1758 Excel uses the NUL character as string list separator. */
1760 if (!aString.isEmpty())
1761 {
1762 sal_Int32 nStringIx = 0;
1763 for(;;)
1764 {
1765 const std::u16string_view aToken( o3tl::getToken(aString, 0, '\n', nStringIx ) );
1766 if (aToken.find(',') != std::u16string_view::npos)
1767 {
1768 sListBuf.append('"');
1769 sListBuf.append(aToken);
1770 sListBuf.append('"');
1771 bList = true;
1772 }
1773 else
1774 sListBuf.append(aToken);
1775 mxString1->Append( aToken );
1776 sFormulaBuf.append( aToken );
1777 if (nStringIx<0)
1778 break;
1779 sal_Unicode cUnicodeChar = 0;
1780 mxString1->Append( std::u16string_view(&cUnicodeChar, 1) );
1781 sFormulaBuf.append( ',' );
1782 sListBuf.append( ',' );
1783 }
1784 }
1786
1787 // maximum length allowed in Excel is 255 characters, and don't end with an empty token
1788 // It should be 8192 but Excel doesn't accept it for unknown reason
1789 // See also https://bugs.documentfoundation.org/show_bug.cgi?id=137167#c2 for more details
1790 sal_uInt32 nLen = sFormulaBuf.getLength();
1791 if( nLen > 256 ) // 255 + beginning quote mark
1792 {
1793 nLen = 256;
1794 if( sFormulaBuf[nLen - 1] == ',' )
1795 --nLen;
1796 sFormulaBuf.truncate(nLen);
1797 }
1798
1799 sFormulaBuf.append( '"' );
1800 msFormula1 = sFormulaBuf.makeStringAndClear();
1801 if (bList)
1802 msList = sListBuf.makeStringAndClear();
1803 else
1804 sListBuf.remove(0, sListBuf.getLength());
1805 }
1806 else
1807 {
1808 /* All other formulas in validation are stored like conditional
1809 formatting formulas (with tRefN/tAreaN tokens as value or
1810 array class). But NOT the cell references and defined names
1811 in list validation - they are stored as reference class
1812 tokens... Example:
1813 1) Cell must be equal to A1 -> formula is =A1 -> writes tRefNV token
1814 2) List is taken from A1 -> formula is =A1 -> writes tRefNR token
1815 Formula compiler supports this by offering two different functions
1816 CreateDataValFormula() and CreateListValFormula(). */
1818 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_LISTVAL, *xScTokArr );
1819 else
1821 xScTokArr.get());
1822 }
1823 }
1824 else
1825 {
1826 // no list validation -> convert the formula
1828 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, *xScTokArr );
1829 else
1831 xScTokArr.get());
1832 }
1833 }
1834
1835 // second formula
1836 xScTokArr = pValData->CreateFlatCopiedTokenArray( 1 );
1837 if (xScTokArr)
1838 {
1840 mxTokArr2 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, *xScTokArr );
1841 else
1843 xScTokArr.get());
1844 }
1845 }
1846 else
1847 {
1848 OSL_FAIL( "XclExpDV::XclExpDV - missing core data" );
1850 }
1851}
1852
1854{
1855}
1856
1858{
1859 maScRanges.Join( rRange );
1860}
1861
1863{
1865 return (mnScHandle != SAL_MAX_UINT32) && !maXclRanges.empty();
1866}
1867
1869{
1870 // flags and strings
1872 // condition formulas
1873 if( mxString1 )
1874 lclWriteDvFormula( rStrm, *mxString1 );
1875 else
1876 lclWriteDvFormula( rStrm, mxTokArr1.get() );
1877 lclWriteDvFormula( rStrm, mxTokArr2.get() );
1878 // cell ranges
1879 rStrm << maXclRanges;
1880}
1881
1883{
1884 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1885 rWorksheet->startElement( XML_dataValidation,
1886 XML_allowBlank, ToPsz( ::get_flag( mnFlags, EXC_DV_IGNOREBLANK ) ),
1887 XML_error, XESTRING_TO_PSZ( maErrorText ),
1888 XML_errorStyle, lcl_GetErrorType(mnFlags),
1889 XML_errorTitle, XESTRING_TO_PSZ( maErrorTitle ),
1890 // OOXTODO: XML_imeMode,
1891 XML_operator, lcl_GetOperatorType( mnFlags ),
1892 XML_prompt, XESTRING_TO_PSZ( maPromptText ),
1893 XML_promptTitle, XESTRING_TO_PSZ( maPromptTitle ),
1894 // showDropDown should have been showNoDropDown - check oox/xlsx import for details
1895 XML_showDropDown, ToPsz( ::get_flag( mnFlags, EXC_DV_SUPPRESSDROPDOWN ) ),
1896 XML_showErrorMessage, ToPsz( ::get_flag( mnFlags, EXC_DV_SHOWERROR ) ),
1897 XML_showInputMessage, ToPsz( ::get_flag( mnFlags, EXC_DV_SHOWPROMPT ) ),
1898 XML_sqref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), maScRanges),
1899 XML_type, lcl_GetValidationType(mnFlags) );
1900 if (!msList.isEmpty())
1901 {
1902 rWorksheet->startElement(FSNS(XML_mc, XML_AlternateContent),
1903 FSNS(XML_xmlns, XML_x12ac),rStrm.getNamespaceURL(OOX_NS(x12ac)),
1904 FSNS(XML_xmlns, XML_mc),rStrm.getNamespaceURL(OOX_NS(mce)));
1905 rWorksheet->startElement(FSNS(XML_mc, XML_Choice), XML_Requires, "x12ac");
1906 rWorksheet->startElement(FSNS(XML_x12ac, XML_list));
1907 rWorksheet->writeEscaped(msList);
1908 rWorksheet->endElement(FSNS(XML_x12ac, XML_list));
1909 rWorksheet->endElement(FSNS(XML_mc, XML_Choice));
1910 rWorksheet->startElement(FSNS(XML_mc, XML_Fallback));
1911 rWorksheet->startElement(XML_formula1);
1912 rWorksheet->writeEscaped(msFormula1);
1913 rWorksheet->endElement(XML_formula1);
1914 rWorksheet->endElement(FSNS(XML_mc, XML_Fallback));
1915 rWorksheet->endElement(FSNS(XML_mc, XML_AlternateContent));
1916 }
1917 if (msList.isEmpty() && !msFormula1.isEmpty())
1918 {
1919 rWorksheet->startElement(XML_formula1);
1920 rWorksheet->writeEscaped( msFormula1 );
1921 rWorksheet->endElement( XML_formula1 );
1922 }
1923 if( !msFormula2.isEmpty() )
1924 {
1925 rWorksheet->startElement(XML_formula2);
1926 rWorksheet->writeEscaped( msFormula2 );
1927 rWorksheet->endElement( XML_formula2 );
1928 }
1929 rWorksheet->endElement( XML_dataValidation );
1930}
1931
1934 XclExpRoot( rRoot )
1935{
1936}
1937
1939{
1940}
1941
1942void XclExpDval::InsertCellRange( const ScRange& rRange, sal_uInt32 nScHandle )
1943{
1944 if( GetBiff() == EXC_BIFF8 )
1945 {
1946 XclExpDV& rDVRec = SearchOrCreateDv( nScHandle );
1947 rDVRec.InsertCellRange( rRange );
1948 }
1949}
1950
1952{
1953 // check all records
1954 size_t nPos = maDVList.GetSize();
1955 while( nPos )
1956 {
1957 --nPos; // backwards to keep nPos valid
1958 XclExpDVRef xDVRec = maDVList.GetRecord( nPos );
1959 if( !xDVRec->Finalize() )
1961 }
1962
1963 // write the DVAL and the DV's
1964 if( !maDVList.IsEmpty() )
1965 {
1967 maDVList.Save( rStrm );
1968 }
1969}
1970
1972{
1973 if( maDVList.IsEmpty() )
1974 return;
1975
1976 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1977 rWorksheet->startElement( XML_dataValidations,
1978 XML_count, OString::number(maDVList.GetSize())
1979 // OOXTODO: XML_disablePrompts,
1980 // OOXTODO: XML_xWindow,
1981 // OOXTODO: XML_yWindow
1982 );
1984 rWorksheet->endElement( XML_dataValidations );
1985}
1986
1988{
1989 // test last found record
1990 if( mxLastFoundDV && (mxLastFoundDV->GetScHandle() == nScHandle) )
1991 return *mxLastFoundDV;
1992
1993 // binary search
1994 size_t nCurrPos = 0;
1995 if( !maDVList.IsEmpty() )
1996 {
1997 size_t nFirstPos = 0;
1998 size_t nLastPos = maDVList.GetSize() - 1;
1999 bool bLoop = true;
2000 sal_uInt32 nCurrScHandle = ::std::numeric_limits< sal_uInt32 >::max();
2001 while( (nFirstPos <= nLastPos) && bLoop )
2002 {
2003 nCurrPos = (nFirstPos + nLastPos) / 2;
2004 mxLastFoundDV = maDVList.GetRecord( nCurrPos );
2005 nCurrScHandle = mxLastFoundDV->GetScHandle();
2006 if( nCurrScHandle == nScHandle )
2007 bLoop = false;
2008 else if( nCurrScHandle < nScHandle )
2009 nFirstPos = nCurrPos + 1;
2010 else if( nCurrPos )
2011 nLastPos = nCurrPos - 1;
2012 else // special case for nLastPos = -1
2013 bLoop = false;
2014 }
2015 if( nCurrScHandle == nScHandle )
2016 return *mxLastFoundDV;
2017 else if( nCurrScHandle < nScHandle )
2018 ++nCurrPos;
2019 }
2020
2021 // create new DV record
2022 mxLastFoundDV = new XclExpDV( *this, nScHandle );
2023 maDVList.InsertRecord( mxLastFoundDV, nCurrPos );
2024 return *mxLastFoundDV;
2025}
2026
2028{
2029 rStrm.WriteZeroBytes( 10 );
2030 rStrm << EXC_DVAL_NOOBJ << static_cast< sal_uInt32 >( maDVList.GetSize() );
2031}
2032
2033// Web Queries ================================================================
2034
2036 const OUString& rRangeName,
2037 const OUString& rUrl,
2038 std::u16string_view rSource,
2039 sal_Int32 nRefrSecs ) :
2040 maDestRange( rRangeName ),
2041 maUrl( rUrl ),
2042 // refresh delay time: seconds -> minutes
2043 mnRefresh( ulimit_cast< sal_Int16 >( (nRefrSecs + 59) / 60 ) ),
2044 mbEntireDoc( false )
2045{
2046 // comma separated list of HTML table names or indexes
2047 OUString aNewTables;
2048 OUString aAppendTable;
2049 bool bExitLoop = false;
2050 if (!rSource.empty())
2051 {
2052 sal_Int32 nStringIx = 0;
2053 do
2054 {
2055 OUString aToken( o3tl::getToken(rSource, 0, ';', nStringIx ) );
2057 bExitLoop = mbEntireDoc || ScfTools::IsHTMLTablesName( aToken );
2058 if( !bExitLoop && ScfTools::GetHTMLNameFromName( aToken, aAppendTable ) )
2059 aNewTables = ScGlobal::addToken( aNewTables, aAppendTable, ',' );
2060 }
2061 while (nStringIx>0 && !bExitLoop);
2062 }
2063
2064 if( !bExitLoop ) // neither HTML_all nor HTML_tables found
2065 {
2066 if( !aNewTables.isEmpty() )
2067 mxQryTables.reset( new XclExpString( aNewTables ) );
2068 else
2069 mbEntireDoc = true;
2070 }
2071}
2072
2074{
2075}
2076
2078{
2079 OSL_ENSURE( !mbEntireDoc || !mxQryTables, "XclExpWebQuery::Save - illegal mode" );
2080 sal_uInt16 nFlags;
2081
2082 // QSI record
2083 rStrm.StartRecord( EXC_ID_QSI, 10 + maDestRange.GetSize() );
2085 << sal_uInt16( 0x0010 )
2086 << sal_uInt16( 0x0012 )
2087 << sal_uInt32( 0x00000000 )
2088 << maDestRange;
2089 rStrm.EndRecord();
2090
2091 // PARAMQRY record
2092 nFlags = 0;
2093 ::insert_value( nFlags, EXC_PQRYTYPE_WEBQUERY, 0, 3 );
2094 ::set_flag( nFlags, EXC_PQRY_WEBQUERY );
2096 rStrm.StartRecord( EXC_ID_PQRY, 12 );
2097 rStrm << nFlags
2098 << sal_uInt16( 0x0000 )
2099 << sal_uInt16( 0x0001 );
2100 rStrm.WriteZeroBytes( 6 );
2101 rStrm.EndRecord();
2102
2103 // WQSTRING record
2104 rStrm.StartRecord( EXC_ID_WQSTRING, maUrl.GetSize() );
2105 rStrm << maUrl;
2106 rStrm.EndRecord();
2107
2108 // unknown record 0x0802
2109 rStrm.StartRecord( EXC_ID_0802, 16 + maDestRange.GetSize() );
2110 rStrm << EXC_ID_0802; // repeated record id ?!?
2111 rStrm.WriteZeroBytes( 6 );
2112 rStrm << sal_uInt16( 0x0003 )
2113 << sal_uInt32( 0x00000000 )
2114 << sal_uInt16( 0x0010 )
2115 << maDestRange;
2116 rStrm.EndRecord();
2117
2118 // WEBQRYSETTINGS record
2120 rStrm.StartRecord( EXC_ID_WQSETT, 28 );
2121 rStrm << EXC_ID_WQSETT // repeated record id ?!?
2122 << sal_uInt16( 0x0000 )
2123 << sal_uInt16( 0x0004 )
2124 << sal_uInt16( 0x0000 )
2126 << nFlags;
2127 rStrm.WriteZeroBytes( 10 );
2128 rStrm << mnRefresh // refresh delay in minutes
2130 << sal_uInt16( 0x0000 );
2131 rStrm.EndRecord();
2132
2133 // WEBQRYTABLES record
2134 if( mxQryTables )
2135 {
2136 rStrm.StartRecord( EXC_ID_WQTABLES, 4 + mxQryTables->GetSize() );
2137 rStrm << EXC_ID_WQTABLES // repeated record id ?!?
2138 << sal_uInt16( 0x0000 )
2139 << *mxQryTables; // comma separated list of source tables
2140 rStrm.EndRecord();
2141 }
2142}
2143
2145{
2146 SCTAB nScTab = rRoot.GetCurrScTab();
2147 SfxObjectShell* pShell = rRoot.GetDocShell();
2148 if( !pShell ) return;
2149 ScfPropertySet aModelProp( pShell->GetModel() );
2150 if( !aModelProp.Is() ) return;
2151
2152 Reference< XAreaLinks > xAreaLinks;
2153 aModelProp.GetProperty( xAreaLinks, SC_UNO_AREALINKS );
2154 if( !xAreaLinks.is() ) return;
2155
2156 for( sal_Int32 nIndex = 0, nCount = xAreaLinks->getCount(); nIndex < nCount; ++nIndex )
2157 {
2158 Reference< XAreaLink > xAreaLink( xAreaLinks->getByIndex( nIndex ), UNO_QUERY );
2159 if( xAreaLink.is() )
2160 {
2161 CellRangeAddress aDestRange( xAreaLink->getDestArea() );
2162 if( static_cast< SCTAB >( aDestRange.Sheet ) == nScTab )
2163 {
2164 ScfPropertySet aLinkProp( xAreaLink );
2165 OUString aFilter;
2166 if( aLinkProp.GetProperty( aFilter, SC_UNONAME_FILTER ) &&
2167 (aFilter == EXC_WEBQRY_FILTER) )
2168 {
2169 // get properties
2170 OUString /*aFilterOpt,*/ aUrl;
2171 sal_Int32 nRefresh = 0;
2172
2173// aLinkProp.GetProperty( aFilterOpt, SC_UNONAME_FILTOPT );
2174 aLinkProp.GetProperty( aUrl, SC_UNONAME_LINKURL );
2175 aLinkProp.GetProperty( nRefresh, SC_UNONAME_REFDELAY );
2176
2177 OUString aAbsDoc( ScGlobal::GetAbsDocName( aUrl, pShell ) );
2178 INetURLObject aUrlObj( aAbsDoc );
2179 OUString aWebQueryUrl( aUrlObj.getFSysPath( FSysStyle::Dos ) );
2180 if( aWebQueryUrl.isEmpty() )
2181 aWebQueryUrl = aAbsDoc;
2182
2183 // find range or create a new range
2184 OUString aRangeName;
2185 ScRange aScDestRange;
2186 ScUnoConversion::FillScRange( aScDestRange, aDestRange );
2187 if( const ScRangeData* pRangeData = rRoot.GetNamedRanges().findByRange( aScDestRange ) )
2188 {
2189 aRangeName = pRangeData->GetName();
2190 }
2191 else
2192 {
2193 XclExpFormulaCompiler& rFmlaComp = rRoot.GetFormulaCompiler();
2194 XclExpNameManager& rNameMgr = rRoot.GetNameManager();
2195
2196 // create a new unique defined name containing the range
2197 XclTokenArrayRef xTokArr = rFmlaComp.CreateFormula( EXC_FMLATYPE_WQUERY, aScDestRange );
2198 sal_uInt16 nNameIdx = rNameMgr.InsertUniqueName( aUrlObj.getBase(), xTokArr, nScTab );
2199 aRangeName = rNameMgr.GetOrigName( nNameIdx );
2200 }
2201
2202 // create and store the web query record
2203 if( !aRangeName.isEmpty() )
2205 aRangeName, aWebQueryUrl, xAreaLink->getSourceArea(), nRefresh ) );
2206 }
2207 }
2208 }
2209 }
2210}
2211
2212/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Any maOrigin
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetMark(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetURLNoMark(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool HasMark() const
static OUString GetRelURL(std::u16string_view rTheBaseURIRef, OUString const &rTheAbsURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
INetProtocol GetProtocol() const
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
SCROW Row() const
Definition: address.hxx:274
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
SCCOL Col() const
Definition: address.hxx:279
const ScRangeList & GetRange() const
Definition: colorscale.cxx:437
double GetValue() const
Definition: colorscale.cxx:236
const ScTokenArray * GetFormula() const
Definition: colorscale.cxx:216
ScColorScaleEntryType GetType() const
Definition: colorscale.hxx:76
condformat::ScCondFormatDateType GetDateType() const
Definition: conditio.hxx:511
const OUString & GetStyleName() const
Definition: conditio.hxx:513
const OUString & GetStyle() const
Definition: conditio.hxx:472
ScAddress GetValidSrcPos() const
Return a position that's adjusted to allow textual representation of expressions if possible.
Definition: conditio.cxx:1341
ScConditionMode GetOperation() const
Definition: conditio.hxx:368
std::unique_ptr< ScTokenArray > CreateFlatCopiedTokenArray(sal_uInt16 nPos) const
Create a flat copy using ScTokenArray copy-ctor with shared tokens.
Definition: conditio.cxx:1296
OUString GetExpression(const ScAddress &rCursor, sal_uInt16 nPos, sal_uInt32 nNumFmt=0, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
Definition: conditio.cxx:1250
const ScRangeList & GetRange() const
Definition: conditio.hxx:558
const ScFormatEntry * GetEntry(sal_uInt16 nPos) const
Definition: conditio.cxx:1796
size_t size() const
Definition: conditio.cxx:1782
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:741
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:264
ScRangePairListRef & GetRowNameRangesRef()
Definition: document.hxx:821
ScRangePairListRef & GetColNameRangesRef()
Definition: document.hxx:820
static SC_DLLPUBLIC OUString addToken(std::u16string_view rTokenList, std::u16string_view rToken, sal_Unicode cSep, sal_Int32 nSepCount=1, bool bForceSep=false)
Adds the string rToken to rTokenList, using a list separator character.
Definition: global.cxx:703
static SC_DLLPUBLIC OUString GetAbsDocName(const OUString &rFileName, const SfxObjectShell *pShell)
Definition: global2.cxx:287
static const char * getIconSetName(ScIconSetType eType)
const ScIconSetFormatData * GetIconSetData() const
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
ScRange & front()
Definition: rangelst.hxx:92
void Format(OUString &, ScRefFlags nFlags, const ScDocument &, formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO, sal_Unicode cDelimiter=0, bool bFullAddressNotation=false) const
Definition: rangelst.cxx:132
void Join(const ScRange &, bool bIsInList=false)
Definition: rangelst.cxx:152
ScRange Combine() const
Definition: rangelst.cxx:1107
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1137
size_t size() const
Definition: rangelst.hxx:89
SC_DLLPUBLIC const ScRangeData * findByRange(const ScRange &rRange) const
Definition: rangenam.cxx:697
const ScRange & GetRange(sal_uInt16 n) const
Definition: address.hxx:810
ScAddress aEnd
Definition: address.hxx:498
bool Contains(const ScAddress &) const
is Address& fully in Range?
Definition: address.hxx:718
ScAddress aStart
Definition: address.hxx:497
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
Definition: convuno.hxx:79
A wrapper for a UNO property set.
Definition: fapihelper.hxx:104
bool GetProperty(Type &rValue, const OUString &rPropName) const
Gets the specified property from the property set.
Definition: fapihelper.hxx:148
bool Is() const
Returns true, if the contained XPropertySet interface is valid.
Definition: fapihelper.hxx:128
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 IsHTMLTablesName(std::u16string_view rSource)
Returns true, if rSource is the built-in range name for all HTML tables.
Definition: ftools.cxx:327
static bool GetHTMLNameFromName(const OUString &rSource, OUString &rName)
Converts a built-in range name to an HTML table name.
Definition: ftools.cxx:332
static bool IsHTMLDocName(std::u16string_view rSource)
Returns true, if rSource is the built-in range name for an HTML document.
Definition: ftools.cxx:322
css::uno::Reference< css::frame::XModel3 > GetModel() const
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
const OUString & GetRepresentation() const
const OUString & GetURL() const
Provides functions to convert Calc cell addresses to Excel cell addresses.
Definition: xehelper.hxx:82
void ConvertRangeList(XclRangeList &rXclRanges, const ScRangeList &rScRanges, bool bWarn)
Converts the passed Calc cell range list to an Excel cell range list.
Definition: xehelper.cxx:271
Represents a CF record that contains one condition of a conditional format.
Definition: xecontent.cxx:598
bool mbColorUsed
true = Font weight used.
Definition: xecontent.cxx:621
bool mbPattUsed
true = Border attribute used.
Definition: xecontent.cxx:626
const ScCondFormatEntry & mrFormatEntry
Definition: xecontent.cxx:607
XclTokenArrayRef mxTokArr1
Pattern formatting attributes.
Definition: xecontent.cxx:612
void SaveXml(XclExpXmlStream &rStrm)
Definition: xecontent.cxx:1031
void WriteBody(XclExpStream &rStrm)
Writes the body of the CF record.
Definition: xecontent.cxx:729
bool mbUnderlUsed
true = Font color used.
Definition: xecontent.cxx:622
bool mbHeightUsed
true = Any font attribute used.
Definition: xecontent.cxx:619
bool mbFontUsed
Priority of this entry; needed for oox export.
Definition: xecontent.cxx:618
XclTokenArrayRef mxTokArr2
Formula for first condition.
Definition: xecontent.cxx:613
XclExpCellBorder maBorder
Font formatting attributes.
Definition: xecontent.cxx:610
bool mbFormula2
true = Pattern attribute used.
Definition: xecontent.cxx:627
bool mbBorderUsed
true = Font strikeout used.
Definition: xecontent.cxx:625
sal_uInt32 mnFontColorId
Formula for second condition.
Definition: xecontent.cxx:614
XclExpCFImpl(const XclExpRoot &rRoot, const ScCondFormatEntry &rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin)
Definition: xecontent.cxx:630
sal_uInt8 mnType
Font color ID.
Definition: xecontent.cxx:615
bool mbStrikeUsed
true = Font posture used.
Definition: xecontent.cxx:624
sal_uInt8 mnOperator
Type of the condition (cell/formula).
Definition: xecontent.cxx:616
bool mbWeightUsed
true = Font height used.
Definition: xecontent.cxx:620
bool mbItalicUsed
true = Font underline type used.
Definition: xecontent.cxx:623
ScAddress maOrigin
Calc conditional format entry.
Definition: xecontent.cxx:608
XclExpCellArea maArea
Border formatting attributes.
Definition: xecontent.cxx:611
sal_Int32 mnPriority
Comparison operator for cell type.
Definition: xecontent.cxx:617
XclFontData maFontData
Top left cell of the combined range.
Definition: xecontent.cxx:609
Represents a CF record that contains one condition of a conditional format.
Definition: xecontent.hxx:168
XclExpCFImplPtr mxImpl
Definition: xecontent.hxx:181
XclExpCF(const XclExpRoot &rRoot, const ScCondFormatEntry &rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin)
Definition: xecontent.cxx:1101
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1117
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the CF record.
Definition: xecontent.cxx:1112
virtual ~XclExpCF() override
Definition: xecontent.cxx:1108
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1222
ScAddress maSrcPos
Definition: xecontent.hxx:205
const ScColorScaleEntry & mrEntry
Definition: xecontent.hxx:204
bool mbFirst
Definition: xecontent.hxx:206
XclExpCfvo(const XclExpRoot &rRoot, const ScColorScaleEntry &rFormatEntry, const ScAddress &rPos, bool bFirst=true)
Definition: xecontent.cxx:1184
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1255
const Color & mrColor
Definition: xecontent.hxx:217
XclExpColScaleCol(const XclExpRoot &rRoot, const Color &rColor)
Definition: xecontent.cxx:1245
virtual ~XclExpColScaleCol() override
Definition: xecontent.cxx:1251
XclExpColorScale(const XclExpRoot &rRoot, const ScColorScaleFormat &rFormat, sal_Int32 nPriority)
Definition: xecontent.cxx:1442
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1459
XclExpCfvoList maCfvoList
Definition: xecontent.hxx:257
XclExpColScaleColList maColList
Definition: xecontent.hxx:258
sal_Int32 mnPriority
Definition: xecontent.hxx:259
XclExpCondFormatBuffer(const XclExpRoot &rRoot, const XclExtLstRef &xExtLst)
Constructs CONDFMT and CF records containing the conditional formats of the current sheet.
Definition: xecontent.cxx:1565
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1585
virtual void Save(XclExpStream &rStrm) override
Writes all contained CONDFMT records with their CF records.
Definition: xecontent.cxx:1580
XclExpCondfmtList maCondfmtList
Definition: xecontent.hxx:305
Represents a CONDFMT record that contains all conditions of a conditional format.
Definition: xecontent.hxx:223
bool IsValidForBinary() const
Returns true, if this conditional format contains at least one cell range and CF record.
Definition: xecontent.cxx:1391
XclExpCondfmt(const XclExpRoot &rRoot, const ScConditionalFormat &rCondFormat, const XclExtLstRef &xExtLst, sal_Int32 &rIndex)
Definition: xecontent.cxx:1298
XclRangeList maXclRanges
List of CF records.
Definition: xecontent.hxx:243
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1426
virtual void Save(XclExpStream &rStrm) override
Writes the CONDFMT record with following CF records, if there is valid data.
Definition: xecontent.cxx:1406
bool IsValidForXml() const
Definition: xecontent.cxx:1401
XclExpRecordList< XclExpRecord > maCFList
Definition: xecontent.hxx:242
OUString msSeqRef
Cell ranges for this conditional format.
Definition: xecontent.hxx:244
virtual ~XclExpCondfmt() override
Definition: xecontent.cxx:1387
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the CONDFMT record.
Definition: xecontent.cxx:1415
Provides export of the data of a DV record.
Definition: xecontent.hxx:315
XclExpString maPromptText
The prompt title.
Definition: xecontent.hxx:339
sal_uInt32 mnFlags
OOXML Formula for second condition.
Definition: xecontent.hxx:348
void InsertCellRange(const ScRange &rPos)
Inserts a new cell range into the cell range list.
Definition: xecontent.cxx:1857
XclRangeList maXclRanges
Calc range list with all affected cells.
Definition: xecontent.hxx:337
XclExpString maErrorTitle
The prompt text.
Definition: xecontent.hxx:340
XclTokenArrayRef mxTokArr2
x12ac:list for first condition.
Definition: xecontent.hxx:346
ScRangeList maScRanges
Definition: xecontent.hxx:336
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the DV record.
Definition: xecontent.cxx:1868
XclExpStringRef mxString1
The error text.
Definition: xecontent.hxx:342
OUString msFormula1
Formula for first condition.
Definition: xecontent.hxx:344
XclExpDV(const XclExpRoot &rRoot, sal_uInt32 nScHandle)
Definition: xecontent.cxx:1676
OUString msFormula2
Formula for second condition.
Definition: xecontent.hxx:347
sal_uInt32 mnScHandle
Miscellaneous flags.
Definition: xecontent.hxx:349
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1882
bool Finalize()
Converts the Calc range list to the Excel range list.
Definition: xecontent.cxx:1862
XclExpString maPromptTitle
Excel range list with all affected cells.
Definition: xecontent.hxx:338
XclTokenArrayRef mxTokArr1
String for first condition formula.
Definition: xecontent.hxx:343
XclExpString maErrorText
The error title.
Definition: xecontent.hxx:341
OUString msList
OOXML Formula for first condition.
Definition: xecontent.hxx:345
virtual ~XclExpDV() override
Definition: xecontent.cxx:1853
std::unique_ptr< XclExpColScaleCol > mpCol
Definition: xecontent.hxx:271
XclExpDataBar(const XclExpRoot &rRoot, const ScDataBarFormat &rFormat, sal_Int32 nPriority, OString aGUID)
Definition: xecontent.cxx:1477
OString maGUID
Definition: xecontent.hxx:275
sal_Int32 mnPriority
Definition: xecontent.hxx:274
std::unique_ptr< XclExpCfvo > mpCfvoUpperLimit
Definition: xecontent.hxx:270
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1494
const ScDataBarFormat & mrFormat
Definition: xecontent.hxx:273
std::unique_ptr< XclExpCfvo > mpCfvoLowerLimit
Definition: xecontent.hxx:269
const ScCondDateFormatEntry & mrFormatEntry
Definition: xecontent.hxx:193
sal_Int32 mnPriority
Definition: xecontent.hxx:194
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1168
XclExpDateFormat(const XclExpRoot &rRoot, const ScCondDateFormatEntry &rFormatEntry, sal_Int32 nPriority)
Definition: xecontent.cxx:1122
virtual ~XclExpDateFormat() override
Definition: xecontent.cxx:1130
void InsertCellRange(const ScRange &rRange, sal_uInt32 nScHandle)
Inserts the cell range into the range list of the DV record with the specified handle.
Definition: xecontent.cxx:1942
virtual void Save(XclExpStream &rStrm) override
Writes the DVAL record and the DV record list.
Definition: xecontent.cxx:1951
virtual ~XclExpDval() override
Definition: xecontent.cxx:1938
XclExpDVList maDVList
Definition: xecontent.hxx:377
XclExpDval(const XclExpRoot &rRoot)
Definition: xecontent.cxx:1932
XclExpDVRef mxLastFoundDV
List of DV records.
Definition: xecontent.hxx:378
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1971
XclExpDV & SearchOrCreateDv(sal_uInt32 nScHandle)
Searches for or creates a XclExpDV record object with the specified handle.
Definition: xecontent.cxx:1987
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the DVAL record.
Definition: xecontent.cxx:2027
Base class for ext entries.
Definition: xeextlst.hxx:38
The formula compiler to create Excel token arrays from Calc token arrays.
Definition: xeformula.hxx:52
XclTokenArrayRef CreateFormula(XclFormulaType eType, const ScTokenArray &rScTokArr, const ScAddress *pScBasePos=nullptr, XclExpRefLog *pRefLog=nullptr)
Creates and returns the token array of a formula.
Definition: xeformula.cxx:2644
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:1545
XclExpIconSet(const XclExpRoot &rRoot, const ScIconSetFormat &rFormat, sal_Int32 nPriority)
Definition: xecontent.cxx:1529
const ScIconSetFormat & mrFormat
Definition: xecontent.hxx:288
sal_Int32 mnPriority
Definition: xecontent.hxx:289
XclExpCfvoList maCfvoList
Definition: xecontent.hxx:287
XclExpLabelranges(const XclExpRoot &rRoot)
Fills the cell range lists with all ranges of the current sheet.
Definition: xecontent.cxx:551
static void FillRangeList(ScRangeList &rScRanges, const ScRangePairListRef &xLabelRangesRef, SCTAB nScTab)
Fills the specified range list with all label headers of the current sheet.
Definition: xecontent.cxx:568
ScRangeList maColRanges
Cell range list for row labels.
Definition: xecontent.hxx:159
ScRangeList maRowRanges
Definition: xecontent.hxx:158
virtual void Save(XclExpStream &rStrm) override
Writes the LABELRANGES record if it contains at least one range.
Definition: xecontent.cxx:580
virtual void Save(XclExpStream &rStrm) override
Writes the record, if it contains at least one merged cell range.
Definition: xecontent.cxx:291
void AppendRange(const ScRange &rRange, sal_uInt32 nBaseXFId)
Appends a new range to the list of merged cell ranges.
Definition: xecontent.cxx:268
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:311
ScfUInt32Vec maBaseXFIds
All merged cell ranges of the sheet.
Definition: xecontent.hxx:89
XclExpMergedcells(const XclExpRoot &rRoot)
Definition: xecontent.cxx:263
sal_uInt32 GetBaseXFId(const ScAddress &rPos) const
Returns the XF identifier of the top-left cell in a merged range.
Definition: xecontent.cxx:277
ScRangeList maMergedRanges
Definition: xecontent.hxx:88
Manager that stores all internal defined names (NAME records) of the document.
Definition: xename.hxx:32
sal_uInt16 InsertUniqueName(const OUString &rName, const XclTokenArrayRef &xTokArr, SCTAB nScTab)
Inserts a new defined name.
Definition: xename.cxx:826
OUString GetOrigName(sal_uInt16 nNameIdx) const
Returns the Calc sheet of a local defined name, or SCTAB_GLOBAL for global defined names.
Definition: xename.cxx:842
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: xerecord.hxx:382
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
Definition: xerecord.hxx:361
size_t GetSize() const
Definition: xerecord.hxx:327
void RemoveRecord(size_t nPos)
Removes the record at the specified position from the list.
Definition: xerecord.hxx:369
bool IsEmpty() const
Definition: xerecord.hxx:326
void InsertRecord(RecType *pRec, size_t nPos)
Inserts a record at the specified position into the list.
Definition: xerecord.hxx:343
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 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
XclExpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
Definition: xeroot.cxx:142
XclExpFormulaCompiler & GetFormulaCompiler() const
Returns the formula compiler to produce formula token arrays.
Definition: xeroot.cxx:88
XclExpDxfs & GetDxfs() const
Returns the differential formatting list.
Definition: xeroot.cxx:160
XclExpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xeroot.cxx:82
sc::CompileFormulaContext & GetCompileFormulaContext() const
Definition: xeroot.hxx:121
bool IsRelUrl() const
Returns true, if URLs should be stored relative to the document location.
Definition: xeroot.hxx:120
XclExpPalette & GetPalette() const
Returns the color buffer.
Definition: xeroot.cxx:106
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xeroot.hxx:118
Implementation of the SST export.
Definition: xecontent.cxx:95
sal_uInt32 mnSize
Total count of strings (including doubles).
Definition: xecontent.cxx:113
std::vector< XclExpHashVec > maHashTab
List of unique strings (in SST ID order).
Definition: xecontent.cxx:111
sal_uInt32 mnTotal
Hashed table that manages string pointers.
Definition: xecontent.cxx:112
void SaveXml(XclExpXmlStream &rStrm)
Definition: xecontent.cxx:207
std::vector< XclExpStringRef > maStringVector
Definition: xecontent.cxx:109
sal_uInt32 Insert(XclExpStringRef xString)
Inserts the passed string, if not already inserted, and returns the unique SST index.
Definition: xecontent.cxx:125
void Save(XclExpStream &rStrm)
Writes the complete SST and EXTSST records.
Definition: xecontent.cxx:156
::std::vector< XclExpHashEntry > XclExpHashVec
Definition: xecontent.cxx:107
virtual ~XclExpSst() override
Definition: xecontent.cxx:242
virtual void Save(XclExpStream &rStrm) override
Writes the complete SST and EXTSST records.
Definition: xecontent.cxx:251
sal_uInt32 Insert(const XclExpStringRef &xString)
Inserts a new string into the table.
Definition: xecontent.cxx:246
XclExpSstImplPtr mxImpl
Definition: xecontent.hxx:67
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xecontent.cxx:256
This class is used to export Excel record streams.
Definition: xestream.hxx:73
void WriteZeroBytes(std::size_t nBytes)
Writes a sequence of nBytes zero bytes (respects slice setting).
Definition: xestream.cxx:263
std::size_t Write(const void *pData, std::size_t nBytes)
Writes nBytes bytes from memory.
Definition: xestream.cxx:222
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:48
void Assign(const OUString &rString, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Assigns an unformatted string, converts this object to a BIFF8 Unicode string.
Definition: xestring.cxx:111
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
Definition: xestring.cxx:249
std::size_t GetBufferSize() const
Returns the byte count the character buffer will take on export.
Definition: xestring.cxx:244
void WriteBuffer(XclExpStream &rStrm) const
Writes the raw character buffer.
Definition: xestring.cxx:305
sal_uInt16 Len() const
Returns the character count of the string.
Definition: xestring.hxx:118
XclExpWebQueryBuffer(const XclExpRoot &rRoot)
Definition: xecontent.cxx:2144
Contains all records for a web query (linked tables in an HTML document).
Definition: xecontent.hxx:388
virtual void Save(XclExpStream &rStrm) override
Writes all needed records for this web query.
Definition: xecontent.cxx:2077
XclExpStringRef mxQryTables
Source document URL.
Definition: xecontent.hxx:404
virtual ~XclExpWebQuery() override
Definition: xecontent.cxx:2073
bool mbEntireDoc
Refresh time in minutes.
Definition: xecontent.hxx:406
XclExpString maDestRange
Definition: xecontent.hxx:402
sal_Int16 mnRefresh
List of source range names.
Definition: xecontent.hxx:405
XclExpWebQuery(const OUString &rRangeName, const OUString &rUrl, std::u16string_view rSource, sal_Int32 nRefrSecs)
Constructs a web query record container with settings from Calc.
Definition: xecontent.cxx:2035
XclExpString maUrl
Destination range.
Definition: xecontent.hxx:403
A 2D cell range address list with Excel column and row indexes.
Definition: xladdress.hxx:102
XclRange GetEnclosingRange() const
Definition: xladdress.cxx:72
bool empty() const
Definition: xladdress.hxx:110
void WriteSubList(XclExpStream &rStrm, size_t nBegin, size_t nCount, bool bCol16Bit=true, sal_uInt16 nCountInStream=0) const
Definition: xladdress.cxx:119
size_t size() const
Definition: xladdress.hxx:109
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:291
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:143
const OUString & GetBasePath() const
Returns the base path of the imported/exported file.
Definition: xlroot.hxx:174
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:147
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
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
ScRangeName & GetNamedRanges() const
Returns the defined names container of the Calc document.
Definition: xlroot.cxx:312
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:286
static bool GetStringList(OUString &rStringList, const ScTokenArray &rScTokArr, sal_Unicode cSep)
Parses the passed formula and tries to find a string token list, i.e.
Definition: xlformula.cxx:893
Binary representation of an Excel token array.
Definition: xlformula.hxx:377
sal_uInt16 GetSize() const
Returns the size of the token array in bytes.
Definition: xlformula.cxx:735
void WriteArray(XclExpStream &rStrm) const
Writes the tokens of the token array (without size field).
Definition: xlformula.cxx:781
static const XclGuid maGuidStdLink
Definition: xltools.hxx:95
static const XclGuid maGuidFileMoniker
GUID of URL moniker (HLINK record).
Definition: xltools.hxx:97
static const XclGuid maGuidUrlMoniker
GUID of StdLink (HLINK record).
Definition: xltools.hxx:96
static OString ToOString(const Color &rColor)
Definition: xestream.cxx:711
static OUString ToOUString(const char *s)
Definition: xestream.cxx:787
@ IconSet_3Triangles
Definition: colorscale.hxx:200
@ IconSet_3ColorSmilies
Definition: colorscale.hxx:201
@ IconSet_5Boxes
Definition: colorscale.hxx:211
@ IconSet_3Smilies
Definition: colorscale.hxx:198
@ IconSet_3Stars
Definition: colorscale.hxx:199
@ COLORSCALE_MAX
Definition: colorscale.hxx:35
@ COLORSCALE_FORMULA
Definition: colorscale.hxx:39
@ COLORSCALE_PERCENT
Definition: colorscale.hxx:38
@ COLORSCALE_PERCENTILE
Definition: colorscale.hxx:36
@ COLORSCALE_AUTO
Definition: colorscale.hxx:33
@ COLORSCALE_MIN
Definition: colorscale.hxx:34
ScConditionMode
Definition: conditio.hxx:60
int nCount
sal_uInt32 mnSize
float u
OUString maUrl
FuncFlags mnFlags
Information about all parameters.
constexpr sal_Int32 FSNS(sal_Int32 namespc, sal_Int32 element)
void insert_value(Type &rnBitField, InsertType nValue, sal_uInt8 nStartBit, sal_uInt8 nBitCount)
Inserts a value into a bitfield.
Definition: ftools.hxx:102
bool get_flag(Type nBitField, Type nMask)
Returns true, if at least one of the bits set in nMask is set in nBitField.
Definition: ftools.hxx:75
ReturnType ulimit_cast(Type nValue, ReturnType nMax)
Returns the value, if it is not greater than nMax, otherwise nMax.
Definition: ftools.hxx:53
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
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
aBuf
OUStringBuffer & truncateToLength(OUStringBuffer &rBuffer, sal_Int32 nLength)
OString generateGUIDString()
ScCondFormatDateType
Definition: conditio.hxx:484
int i
void SvStream & rStrm
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OUString getRelationship(Relationship eRelationship)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const char * UseIf(const char *s, bool bUse)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
XML_type
const ObjectTypeFormatEntry & mrEntry
@ SC_AUTOCOL_RAW
COL_AUTO is returned.
Definition: patattr.hxx:44
sal_Int32 mnType
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
constexpr TypedWhichId< SvxCrossedOutItem > ATTR_FONT_CROSSEDOUT(106)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
double mnPriority
#define STREAM_SEEK_TO_BEGIN
std::unique_ptr< ScColorScaleEntry, o3tl::default_delete< ScColorScaleEntry > > mpLowerLimit
Definition: colorscale.hxx:185
double mnMinLength
Minimal length of a databar in percent of cell length Value has to be in the range [0,...
Definition: colorscale.hxx:172
double mnMaxLength
Maximal length of a databar in percent of cell length Value has to be in the range (0,...
Definition: colorscale.hxx:177
Color maPositiveColor
Color for all Positive Values and if mbNeg == false also for negative ones.
Definition: colorscale.hxx:134
bool mbOnlyBar
If TRUE we only show the bar and not the value.
Definition: colorscale.hxx:182
std::unique_ptr< ScColorScaleEntry, o3tl::default_delete< ScColorScaleEntry > > mpUpperLimit
Definition: colorscale.hxx:184
ScIconSetType eIconSetType
Definition: colorscale.hxx:333
bool mbReverse
Specifies whether the icons should be shown in reverse order.
Definition: colorscale.hxx:338
Extends the XclCellArea struct for export.
Definition: xestyle.hxx:374
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 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
Extends the XclCellBorder struct for export.
Definition: xestyle.hxx:343
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
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
const ScFormatEntry * pEntry
Definition: xeextlst.hxx:31
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:284
void FillFromVclFont(const vcl::Font &rFont)
Fills all members (except color and escapement) from the passed font.
Definition: xlstyle.cxx:202
Color maColor
String with styles (bold, italic).
Definition: xlstyle.hxx:287
sal_uInt16 mnHeight
Font color.
Definition: xlstyle.hxx:288
sal_uInt16 mnWeight
Font height in twips (1/20 of a point).
Definition: xlstyle.hxx:289
bool mbItalic
Underline style.
Definition: xlstyle.hxx:294
sal_uInt8 mnUnderline
Windows character set.
Definition: xlstyle.hxx:293
bool mbStrikeout
true = Italic.
Definition: xlstyle.hxx:295
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
#define SAL_MAX_UINT32
sal_Int16 SCTAB
Definition: types.hxx:22
OUString sId
constexpr OUStringLiteral SC_UNONAME_FILTER
Definition: unonames.hxx:367
constexpr OUStringLiteral SC_UNONAME_REFDELAY
Definition: unonames.hxx:371
constexpr OUStringLiteral SC_UNONAME_LINKURL
Definition: unonames.hxx:369
constexpr OUStringLiteral SC_UNO_AREALINKS
Definition: unonames.hxx:39
INetProtocol
constexpr OUStringLiteral INET_FILE_SCHEME
@ SC_VALID_TEXTLEN
Definition: validat.hxx:45
@ SC_VALID_TIME
Definition: validat.hxx:44
@ SC_VALID_CUSTOM
Definition: validat.hxx:47
@ SC_VALID_ANY
Definition: validat.hxx:40
@ SC_VALID_DECIMAL
Definition: validat.hxx:42
@ SC_VALID_WHOLE
Definition: validat.hxx:41
@ SC_VALID_DATE
Definition: validat.hxx:43
@ SC_VALID_LIST
Definition: validat.hxx:46
ScValidErrorStyle
Definition: validat.hxx:51
@ SC_VALERR_MACRO
Definition: validat.hxx:55
@ SC_VALERR_STOP
Definition: validat.hxx:52
@ SC_VALERR_WARNING
Definition: validat.hxx:53
@ SC_VALERR_INFO
Definition: validat.hxx:54
std::unique_ptr< char[]> aBuffer
const sal_uInt32 EXC_SST_HASHTABLE_SIZE
Definition: xecontent.cxx:116
@ XclExpExtDataBarType
Definition: xeextlst.hxx:21
std::shared_ptr< XclExpString > XclExpStringRef
Definition: xeroot.hxx:35
#define XESTRING_TO_PSZ(s)
Definition: xestream.hxx:232
@ EXC_COLOR_CELLTEXT
Definition: xestyle.hxx:48
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35
@ EXC_OUTPUT_BINARY
Definition: xlconst.hxx:42
@ EXC_OUTPUT_XML_2007
MS Excel binary .xls.
Definition: xlconst.hxx:43
const sal_uInt32 EXC_DV_COND_NOTBETWEEN
Definition: xlcontent.hxx:126
const sal_uInt16 EXC_ID_DV
Definition: xlcontent.hxx:103
const sal_uInt16 EXC_WQSETT_SPECTABLES
All tables or entire document.
Definition: xlcontent.hxx:176
const sal_uInt32 EXC_DV_ERROR_INFO
Definition: xlcontent.hxx:138
const sal_uInt32 EXC_DV_IGNOREBLANK
Definition: xlcontent.hxx:107
const sal_uInt32 EXC_DV_COND_BETWEEN
Definition: xlcontent.hxx:125
const sal_uInt32 EXC_DV_COND_NOTEQUAL
Definition: xlcontent.hxx:128
const sal_uInt16 EXC_MERGEDCELLS_MAXCOUNT
Definition: xlcontent.hxx:34
const sal_uInt32 EXC_HLINK_DESCR
Absolute path.
Definition: xlcontent.hxx:146
const sal_uInt32 EXC_DV_MODE_ANY
Definition: xlcontent.hxx:114
const sal_uInt16 EXC_ID_LABELRANGES
Definition: xlcontent.hxx:50
const sal_uInt16 EXC_ID_CF
Definition: xlcontent.hxx:55
constexpr OUStringLiteral EXC_WEBQRY_FILTER
UNC path.
Definition: xlcontent.hxx:153
const sal_uInt16 EXC_QSI_DEFAULTFLAGS
Definition: xlcontent.hxx:168
const sal_uInt32 EXC_DV_SHOWPROMPT
Definition: xlcontent.hxx:109
const sal_uInt16 EXC_PQRYTYPE_WEBQUERY
Source type: ODBC.
Definition: xlcontent.hxx:161
const sal_uInt16 EXC_WQSETT_DEFAULTFLAGS
Specific tables.
Definition: xlcontent.hxx:177
const sal_uInt16 EXC_WQSETT_FORMATFULL
Definition: xlcontent.hxx:180
const sal_uInt32 EXC_DV_MODE_WHOLE
Definition: xlcontent.hxx:115
const sal_uInt32 EXC_CF_BLOCK_AREA
Border block present?
Definition: xlcontent.hxx:85
const sal_uInt16 EXC_ID_0802
Flags for export.
Definition: xlcontent.hxx:171
const sal_uInt16 EXC_ID_QSI
All tables.
Definition: xlcontent.hxx:167
const sal_uInt8 EXC_CF_CMP_NOT_BETWEEN
Definition: xlcontent.hxx:63
const sal_uInt16 EXC_WQSETT_ALL
Definition: xlcontent.hxx:175
const sal_uInt16 EXC_ID_WQSTRING
Definition: xlcontent.hxx:156
const sal_uInt32 EXC_CF_ALLDEFAULT
Any area attribute modified?
Definition: xlcontent.hxx:80
const sal_uInt32 EXC_HLINK_BODY
Definition: xlcontent.hxx:144
const sal_uInt32 EXC_CF_FONT_ESCAPEM
Font underline type modified?
Definition: xlcontent.hxx:94
const sal_uInt32 EXC_DV_MODE_MASK
Definition: xlcontent.hxx:113
const sal_uInt16 EXC_ID_HLINK
Definition: xlcontent.hxx:142
const sal_uInt32 EXC_CF_AREA_ALL
Background color modified?
Definition: xlcontent.hxx:79
const sal_uInt16 EXC_ID_SST
Definition: xlcontent.hxx:45
const sal_uInt32 EXC_DV_ERROR_WARNING
Definition: xlcontent.hxx:137
const sal_uInt32 EXC_CF_BLOCK_BORDER
Alignment block present?
Definition: xlcontent.hxx:84
const sal_uInt32 EXC_CF_FONT_STYLE
NumberFormat String or Id?
Definition: xlcontent.hxx:89
const sal_uInt32 EXC_DV_COND_MASK
Definition: xlcontent.hxx:124
const sal_uInt8 EXC_CF_TYPE_FMLA
Definition: xlcontent.hxx:59
const sal_uInt32 EXC_CF_BLOCK_FONT
Font block present?
Definition: xlcontent.hxx:82
const sal_uInt32 EXC_DV_SUPPRESSDROPDOWN
Definition: xlcontent.hxx:108
const sal_uInt32 EXC_DV_SHOWERROR
Definition: xlcontent.hxx:110
const sal_uInt32 EXC_DV_COND_LESS
Definition: xlcontent.hxx:130
const sal_uInt16 EXC_ID_WQTABLES
Definition: xlcontent.hxx:183
const sal_uInt16 EXC_ID_EXTSST
Definition: xlcontent.hxx:46
const sal_uInt32 EXC_DV_MODE_TIME
Definition: xlcontent.hxx:119
const sal_uInt8 EXC_CF_TYPE_CELL
Definition: xlcontent.hxx:58
const sal_uInt32 EXC_CF_BORDER_ALL
Bottom border line modified?
Definition: xlcontent.hxx:75
const sal_uInt8 EXC_CF_CMP_LESS
Definition: xlcontent.hxx:67
const sal_uInt8 EXC_CF_CMP_GREATER
Definition: xlcontent.hxx:66
const sal_uInt32 EXC_DV_MODE_TEXTLEN
Definition: xlcontent.hxx:120
const sal_uInt16 EXC_PQRY_WEBQUERY
ODBC connection.
Definition: xlcontent.hxx:163
const sal_uInt8 EXC_CF_TYPE_NONE
Definition: xlcontent.hxx:57
const sal_uInt32 EXC_DV_MODE_LIST
Definition: xlcontent.hxx:117
const sal_uInt16 EXC_ID_PQRY
Definition: xlcontent.hxx:159
const sal_uInt8 EXC_CF_CMP_LESS_EQUAL
Definition: xlcontent.hxx:69
const sal_uInt32 EXC_CF_FONT_ALLDEFAULT
Font cancellation modified?
Definition: xlcontent.hxx:91
const sal_uInt32 EXC_DV_COND_EQGREATER
Definition: xlcontent.hxx:131
const sal_uInt16 EXC_ID_CONDFMT
Definition: xlcontent.hxx:54
const sal_uInt8 EXC_CF_CMP_NONE
Definition: xlcontent.hxx:61
const sal_uInt32 EXC_DV_MODE_DATE
Definition: xlcontent.hxx:118
const sal_uInt32 EXC_DV_COND_EQUAL
Definition: xlcontent.hxx:127
const sal_uInt32 EXC_DV_MODE_DECIMAL
Definition: xlcontent.hxx:116
const sal_uInt8 EXC_CF_CMP_GREATER_EQUAL
Definition: xlcontent.hxx:68
const sal_uInt32 EXC_DV_ERROR_STOP
Definition: xlcontent.hxx:136
const sal_uInt32 EXC_DV_ERROR_MASK
Definition: xlcontent.hxx:135
const sal_uInt32 EXC_DV_MODE_CUSTOM
Definition: xlcontent.hxx:121
const sal_uInt16 EXC_ID_DVAL
Font escapement type modified?
Definition: xlcontent.hxx:98
const sal_uInt8 EXC_CF_CMP_NOT_EQUAL
Definition: xlcontent.hxx:65
const sal_uInt16 EXC_ID_MERGEDCELLS
Definition: xlcontent.hxx:33
const sal_uInt32 EXC_DV_STRINGLIST
Definition: xlcontent.hxx:106
const sal_uInt32 EXC_CF_FONT_STRIKEOUT
Font posture or weight modified?
Definition: xlcontent.hxx:90
const sal_uInt8 EXC_CF_CMP_EQUAL
Definition: xlcontent.hxx:64
const sal_uInt16 EXC_ID_WQSETT
Definition: xlcontent.hxx:174
const sal_uInt32 EXC_DV_COND_EQLESS
Definition: xlcontent.hxx:132
const sal_uInt32 EXC_HLINK_MARK
Description.
Definition: xlcontent.hxx:147
const sal_uInt16 EXC_PQRY_TABLES
Web query.
Definition: xlcontent.hxx:164
const sal_uInt32 EXC_DV_COND_GREATER
Definition: xlcontent.hxx:129
const sal_uInt8 EXC_CF_CMP_BETWEEN
Definition: xlcontent.hxx:62
const sal_uInt32 EXC_CF_FONT_UNDERL
Default flags.
Definition: xlcontent.hxx:93
const sal_uInt32 EXC_HLINK_ABS
Contains file link or URL.
Definition: xlcontent.hxx:145
@ EXC_FMLATYPE_DATAVAL
Conditional format.
Definition: xlformula.hxx:165
@ EXC_FMLATYPE_WQUERY
Spreadsheet links in form controls.
Definition: xlformula.hxx:169
@ EXC_FMLATYPE_LISTVAL
Web query source range.
Definition: xlformula.hxx:170
@ EXC_FMLATYPE_CONDFMT
Shared formula.
Definition: xlformula.hxx:164
std::shared_ptr< XclTokenArray > XclTokenArrayRef
Definition: xlformula.hxx:416
const sal_uInt8 EXC_TOKID_STR
Missing argument.
Definition: xlformula.hxx:74
@ EightBitLength
Always use UCS-2 characters (default: try to compress). BIFF8 only.
@ ForceUnicode
Default string settings.
const sal_uInt16 EXC_FONTESC_NONE
Definition: xlstyle.hxx:125
const sal_uInt32 EXC_XFID_NOTFOUND
Special index for "not found" state.
Definition: xlstyle.hxx:142