LibreOffice Module sc (master) 1
xicontent.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 <com/sun/star/sheet/TableValidationVisibility.hpp>
21#include <utility>
22#include <xicontent.hxx>
23#include <sfx2/objsh.hxx>
24#include <sfx2/docfile.hxx>
25#include <tools/urlobj.hxx>
26#include <sfx2/linkmgr.hxx>
27#include <svl/itemset.hxx>
28#include <scitems.hxx>
29#include <editeng/eeitem.hxx>
30#include <svl/intitem.hxx>
31#include <svl/stritem.hxx>
32#include <editeng/flditem.hxx>
33#include <editeng/editobj.hxx>
36#include <stringutil.hxx>
37#include <cellform.hxx>
38#include <cellvalue.hxx>
39#include <document.hxx>
40#include <editutil.hxx>
41#include <validat.hxx>
42#include <patattr.hxx>
43#include <docpool.hxx>
44#include <rangenam.hxx>
45#include <arealink.hxx>
46#include <stlsheet.hxx>
47#include <xlcontent.hxx>
48#include <xlformula.hxx>
49#include <xltracer.hxx>
50#include <xistream.hxx>
51#include <xihelper.hxx>
52#include <xistyle.hxx>
53#include <xiescher.hxx>
54#include <xiname.hxx>
55
56#include <excform.hxx>
57#include <tabprotection.hxx>
58#include <documentimport.hxx>
59
60#include <memory>
61#include <oox/helper/helper.hxx>
62#include <sal/log.hxx>
63
64using ::com::sun::star::uno::Sequence;
65using ::std::unique_ptr;
66
67// Shared string table ========================================================
68
70 XclImpRoot( rRoot )
71{
72}
73
75{
76 rStrm.Ignore( 4 );
77 sal_uInt32 nStrCount = rStrm.ReaduInt32();
78 auto nBytesAvailable = rStrm.GetRecLeft();
79 if (nStrCount > nBytesAvailable)
80 {
81 SAL_WARN("sc.filter", "xls claimed to have " << nStrCount << " strings, but only " << nBytesAvailable << " bytes available, truncating");
82 nStrCount = nBytesAvailable;
83 }
84 maStrings.clear();
85 maStrings.reserve(nStrCount);
86 while( (nStrCount > 0) && rStrm.IsValid() )
87 {
88 XclImpString aString;
89 aString.Read( rStrm );
90 maStrings.push_back( aString );
91 --nStrCount;
92 }
93}
94
95const XclImpString* XclImpSst::GetString( sal_uInt32 nSstIndex ) const
96{
97 return (nSstIndex < maStrings.size()) ? &maStrings[ nSstIndex ] : nullptr;
98}
99
100// Hyperlinks =================================================================
101
102namespace {
103
107void lclAppendString32( OUString& rString, XclImpStream& rStrm, sal_uInt32 nChars, bool b16Bit )
108{
109 sal_uInt16 nReadChars = ulimit_cast< sal_uInt16 >( nChars );
110 rString += rStrm.ReadRawUniString( nReadChars, b16Bit );
111 // ignore remaining chars
112 std::size_t nIgnore = nChars - nReadChars;
113 if( b16Bit )
114 nIgnore *= 2;
115 rStrm.Ignore( nIgnore );
116}
117
120void lclAppendString32( OUString& rString, XclImpStream& rStrm, bool b16Bit )
121{
122 lclAppendString32( rString, rStrm, rStrm.ReaduInt32(), b16Bit );
123}
124
126void lclIgnoreString32( XclImpStream& rStrm )
127{
128 sal_uInt32 nChars = rStrm.ReaduInt32();
129 nChars *= 2;
130 rStrm.Ignore( nChars );
131}
132
136void lclGetAbsPath( OUString& rPath, sal_uInt16 nLevel, const SfxObjectShell* pDocShell )
137{
138 OUStringBuffer aTmpStr;
139 while( nLevel )
140 {
141 aTmpStr.append( "../" );
142 --nLevel;
143 }
144 aTmpStr.append( rPath );
145
146 if( pDocShell )
147 {
148 bool bWasAbs = false;
149 rPath = pDocShell->GetMedium()->GetURLObject().smartRel2Abs( aTmpStr.makeStringAndClear(), bWasAbs ).GetMainURL( INetURLObject::DecodeMechanism::NONE );
150 // full path as stored in SvxURLField must be encoded
151 }
152 else
153 rPath = aTmpStr.makeStringAndClear();
154}
155
157void lclInsertUrl( XclImpRoot& rRoot, const OUString& rUrl, SCCOL nScCol, SCROW nScRow, SCTAB nScTab )
158{
159 ScDocumentImport& rDoc = rRoot.GetDocImport();
160 ScAddress aScPos( nScCol, nScRow, nScTab );
161 ScRefCellValue aCell(rDoc.getDoc(), aScPos);
162 switch( aCell.getType() )
163 {
164 // #i54261# hyperlinks in string cells
165 case CELLTYPE_STRING:
166 case CELLTYPE_EDIT:
167 {
168 sal_uInt32 nNumFmt = rDoc.getDoc().GetNumberFormat(rDoc.getDoc().GetNonThreadedContext(), aScPos);
169 SvNumberFormatter* pFormatter = rDoc.getDoc().GetFormatTable();
170 const Color* pColor;
171 OUString aDisplText = ScCellFormat::GetString(aCell, nNumFmt, &pColor, *pFormatter, rDoc.getDoc());
172 if (aDisplText.isEmpty())
173 aDisplText = rUrl;
174
176 SvxURLField aUrlField( rUrl, aDisplText, SvxURLFormat::AppDefault );
177
178 if( aCell.getType() == CELLTYPE_EDIT )
179 {
180 const EditTextObject* pEditObj = aCell.getEditText();
181 rEE.SetTextCurrentDefaults( *pEditObj );
182 rEE.QuickInsertField( SvxFieldItem( aUrlField, EE_FEATURE_FIELD ), ESelection( 0, 0, EE_PARA_ALL, 0 ) );
183 }
184 else
185 {
186 rEE.SetTextCurrentDefaults( OUString() );
187 rEE.QuickInsertField( SvxFieldItem( aUrlField, EE_FEATURE_FIELD ), ESelection() );
188 if( const ScPatternAttr* pPattern = rDoc.getDoc().GetPattern( aScPos.Col(), aScPos.Row(), nScTab ) )
189 {
190 SfxItemSet aItemSet( rEE.GetEmptyItemSet() );
191 pPattern->FillEditItemSet( &aItemSet );
192 rEE.QuickSetAttribs( aItemSet, ESelection( 0, 0, EE_PARA_ALL, 0 ) );
193 }
194 }
195
196 // The cell will own the text object instance.
197 rDoc.setEditCell(aScPos, rEE.CreateTextObject());
198 }
199 break;
200
201 default:
202 // Handle other cell types e.g. formulas ( and ? ) that have associated
203 // hyperlinks.
204 // Ideally all hyperlinks should be treated as below. For the moment,
205 // given the current absence of ods support lets just handle what we
206 // previously didn't handle the new way.
207 // Unfortunately we won't be able to preserve such hyperlinks when
208 // saving to ods. Note: when we are able to save such hyperlinks to ods
209 // we should handle *all* imported hyperlinks as below ( e.g. as cell
210 // attribute ) for better interoperability.
211 {
212 SfxStringItem aItem( ATTR_HYPERLINK, rUrl );
213 rDoc.getDoc().ApplyAttr(nScCol, nScRow, nScTab, aItem);
214 break;
215 }
216 }
217}
218
219} // namespace
220
222{
224 rStrm >> aXclRange;
225 // #i80006# Excel silently ignores invalid hi-byte of column index (TODO: everywhere?)
226 aXclRange.maFirst.mnCol &= 0xFF;
227 aXclRange.maLast.mnCol &= 0xFF;
228 OUString aString = ReadEmbeddedData( rStrm );
229 if ( !aString.isEmpty() )
230 rStrm.GetRoot().GetXFRangeBuffer().SetHyperlink( aXclRange, aString );
231}
232
234{
235 const XclImpRoot& rRoot = rStrm.GetRoot();
236 SfxObjectShell* pDocShell = rRoot.GetDocShell();
237
238 OSL_ENSURE_BIFF( rRoot.GetBiff() == EXC_BIFF8 );
239
240 XclGuid aGuid;
241 rStrm >> aGuid;
242 rStrm.Ignore( 4 );
243 sal_uInt32 nFlags = rStrm.ReaduInt32();
244
245 OSL_ENSURE( aGuid == XclTools::maGuidStdLink, "XclImpHyperlink::ReadEmbeddedData - unknown header GUID" );
246
247 ::std::unique_ptr< OUString > xLongName; // link / file name
248 ::std::unique_ptr< OUString > xShortName; // 8.3-representation of file name
249 ::std::unique_ptr< OUString > xTextMark; // text mark
250
251 // description (ignore)
252 if( ::get_flag( nFlags, EXC_HLINK_DESCR ) )
253 lclIgnoreString32( rStrm );
254 // target frame (ignore) !! DESCR/FRAME - is this the right order? (never seen them together)
255 if( ::get_flag( nFlags, EXC_HLINK_FRAME ) )
256 lclIgnoreString32( rStrm );
257
258 // URL fields are zero-terminated - do not let the stream replace them
259 // in the lclAppendString32() with the '?' character.
260 rStrm.SetNulSubstChar( '\0' );
261
262 // UNC path
263 if( ::get_flag( nFlags, EXC_HLINK_UNC ) )
264 {
265 xLongName.reset( new OUString );
266 lclAppendString32( *xLongName, rStrm, true );
267 lclGetAbsPath( *xLongName, 0, pDocShell );
268 }
269 // file link or URL
270 else if( ::get_flag( nFlags, EXC_HLINK_BODY ) )
271 {
272 rStrm >> aGuid;
273
274 if( aGuid == XclTools::maGuidFileMoniker )
275 {
276 sal_uInt16 nLevel = rStrm.ReaduInt16(); // counter for level to climb down in path
277 xShortName.reset( new OUString );
278 lclAppendString32( *xShortName, rStrm, false );
279 rStrm.Ignore( 24 );
280
281 sal_uInt32 nStrLen = rStrm.ReaduInt32();
282 if( nStrLen )
283 {
284 nStrLen = rStrm.ReaduInt32();
285 nStrLen /= 2; // it's byte count here...
286 rStrm.Ignore( 2 );
287 xLongName.reset( new OUString );
288 lclAppendString32( *xLongName, rStrm, nStrLen, true );
289 lclGetAbsPath( *xLongName, nLevel, pDocShell );
290 }
291 else
292 lclGetAbsPath( *xShortName, nLevel, pDocShell );
293 }
294 else if( aGuid == XclTools::maGuidUrlMoniker )
295 {
296 sal_uInt32 nStrLen = rStrm.ReaduInt32();
297 nStrLen /= 2; // it's byte count here...
298 xLongName.reset( new OUString );
299 lclAppendString32( *xLongName, rStrm, nStrLen, true );
300 if( !::get_flag( nFlags, EXC_HLINK_ABS ) )
301 lclGetAbsPath( *xLongName, 0, pDocShell );
302 }
303 else
304 {
305 OSL_FAIL( "XclImpHyperlink::ReadEmbeddedData - unknown content GUID" );
306 }
307 }
308
309 // text mark
310 if( ::get_flag( nFlags, EXC_HLINK_MARK ) )
311 {
312 xTextMark.reset( new OUString );
313 lclAppendString32( *xTextMark, rStrm, true );
314 }
315
316 rStrm.SetNulSubstChar(); // back to default
317
318 OSL_ENSURE( rStrm.GetRecLeft() == 0, "XclImpHyperlink::ReadEmbeddedData - record size mismatch" );
319
320 if (!xLongName && xShortName)
321 xLongName = std::move(xShortName);
322 else if (!xLongName && xTextMark)
323 xLongName.reset( new OUString );
324
325 if (xLongName)
326 {
327 if (xTextMark)
328 {
329 if( xLongName->isEmpty() )
330 {
331 sal_Int32 nSepPos = xTextMark->lastIndexOf( '!' );
332 if( nSepPos > 0 )
333 {
334 // Do not attempt to blindly convert '#SheetName!A1' to
335 // '#SheetName.A1', it can be #SheetName!R1C1 as well.
336 // Hyperlink handler has to handle all, but prefer
337 // '#SheetName.A1' if possible.
338 if (nSepPos < xTextMark->getLength() - 1)
339 {
340 ScDocument& rDoc = rRoot.GetDoc();
341 ScRange aRange;
342 if ((aRange.ParseAny( xTextMark->copy( nSepPos + 1 ), rDoc, formula::FormulaGrammar::CONV_XL_R1C1)
344 xTextMark.reset( new OUString( xTextMark->replaceAt( nSepPos, 1, rtl::OUStringChar( '.' ))));
345 }
346 }
347 }
348 xLongName.reset( new OUString( *xLongName + "#" + *xTextMark ) );
349 }
350 return( *xLongName );
351 }
352 return( OUString() );
353}
354
356{
357 sal_Int32 n = rUrl.getLength();
358 if (n < 4)
359 // Needs at least 4 characters.
360 return;
361
362 if (rUrl[0] != '#')
363 // the 1st character must be '#'.
364 return;
365
366 OUStringBuffer aNewUrl("#");
367 OUStringBuffer aTabName;
368
369 bool bInQuote = false;
370 bool bQuoteTabName = false;
371 for( sal_Int32 i = 1; i < n; ++i )
372 {
373 sal_Unicode c = rUrl[i];
374 if (c == '\'')
375 {
376 if (bInQuote && i+1 < n && rUrl[i+1] == '\'')
377 {
378 // Two consecutive single quotes ('') signify a single literal
379 // quite. When this occurs, the whole table name needs to be
380 // quoted.
381 bQuoteTabName = true;
382 aTabName.append(c).append(c);
383 ++i;
384 continue;
385 }
386
387 bInQuote = !bInQuote;
388 if (!bInQuote && !aTabName.isEmpty())
389 {
390 if (bQuoteTabName)
391 aNewUrl.append("'");
392 aNewUrl.append(aTabName);
393 if (bQuoteTabName)
394 aNewUrl.append("'");
395 }
396 }
397 else if (bInQuote)
398 aTabName.append(c);
399 else
400 aNewUrl.append(c);
401 }
402
403 if (bInQuote)
404 // It should be outside the quotes!
405 return;
406
407 // All is good. Pass the new URL.
408 rUrl = aNewUrl.makeStringAndClear();
409}
410
411void XclImpHyperlink::InsertUrl( XclImpRoot& rRoot, const XclRange& rXclRange, const OUString& rUrl )
412{
413 OUString aUrl(rUrl);
415
416 SCTAB nScTab = rRoot.GetCurrScTab();
418 if( rRoot.GetAddressConverter().ConvertRange( aScRange, rXclRange, nScTab, nScTab, true ) )
419 {
420 SCCOL nScCol1, nScCol2;
421 SCROW nScRow1, nScRow2;
422 aScRange.GetVars( nScCol1, nScRow1, nScTab, nScCol2, nScRow2, nScTab );
423
425 {
426 SCROW nRows = nScRow2 - nScRow1;
427 if (nRows > 1024)
428 {
429 SAL_WARN("sc.filter", "for fuzzing performance, clamped hyperlink apply range end row from " << nScRow2 << " to " << nScRow1 + 1024);
430 nScRow2 = nScRow1 + 1024;
431 }
432 }
433
434 for( SCCOL nScCol = nScCol1; nScCol <= nScCol2; ++nScCol )
435 for( SCROW nScRow = nScRow1; nScRow <= nScRow2; ++nScRow )
436 lclInsertUrl( rRoot, aUrl, nScCol, nScRow, nScTab );
437 }
438}
439
440// Label ranges ===============================================================
441
443{
444 const XclImpRoot& rRoot = rStrm.GetRoot();
445 OSL_ENSURE_BIFF( rRoot.GetBiff() == EXC_BIFF8 );
446
447 ScDocument& rDoc = rRoot.GetDoc();
448 SCTAB nScTab = rRoot.GetCurrScTab();
449 XclImpAddressConverter& rAddrConv = rRoot.GetAddressConverter();
450 ScRangePairListRef xLabelRangesRef;
451
452 XclRangeList aRowXclRanges, aColXclRanges;
453 rStrm >> aRowXclRanges >> aColXclRanges;
454
455 // row label ranges
456 ScRangeList aRowScRanges;
457 rAddrConv.ConvertRangeList( aRowScRanges, aRowXclRanges, nScTab, false );
458 xLabelRangesRef = rDoc.GetRowNameRangesRef();
459 for ( size_t i = 0, nRanges = aRowScRanges.size(); i < nRanges; ++i )
460 {
461 const ScRange & rScRange = aRowScRanges[ i ];
462 ScRange aDataRange( rScRange );
463 if( aDataRange.aEnd.Col() < rDoc.MaxCol() )
464 {
465 aDataRange.aStart.SetCol( aDataRange.aEnd.Col() + 1 );
466 aDataRange.aEnd.SetCol( rDoc.MaxCol() );
467 }
468 else if( aDataRange.aStart.Col() > 0 )
469 {
470 aDataRange.aEnd.SetCol( aDataRange.aStart.Col() - 1 );
471 aDataRange.aStart.SetCol( 0 );
472 }
473 xLabelRangesRef->Append( ScRangePair( rScRange, aDataRange ) );
474 }
475
476 // column label ranges
477 ScRangeList aColScRanges;
478 rAddrConv.ConvertRangeList( aColScRanges, aColXclRanges, nScTab, false );
479 xLabelRangesRef = rDoc.GetColNameRangesRef();
480
481 for ( size_t i = 0, nRanges = aColScRanges.size(); i < nRanges; ++i )
482 {
483 const ScRange & rScRange = aColScRanges[ i ];
484 ScRange aDataRange( rScRange );
485 if( aDataRange.aEnd.Row() < rDoc.MaxRow() )
486 {
487 aDataRange.aStart.SetRow( aDataRange.aEnd.Row() + 1 );
488 aDataRange.aEnd.SetRow( rDoc.MaxRow() );
489 }
490 else if( aDataRange.aStart.Row() > 0 )
491 {
492 aDataRange.aEnd.SetRow( aDataRange.aStart.Row() - 1 );
493 aDataRange.aStart.SetRow( 0 );
494 }
495 xLabelRangesRef->Append( ScRangePair( rScRange, aDataRange ) );
496 }
497}
498
499// Conditional formatting =====================================================
500
501XclImpCondFormat::XclImpCondFormat( const XclImpRoot& rRoot, sal_uInt32 nFormatIndex ) :
502 XclImpRoot( rRoot ),
503 mnFormatIndex( nFormatIndex ),
504 mnCondCount( 0 ),
505 mnCondIndex( 0 )
506{
507}
508
510{
511}
512
514{
515 OSL_ENSURE( !mnCondCount, "XclImpCondFormat::ReadCondfmt - already initialized" );
516 XclRangeList aXclRanges;
517 mnCondCount = rStrm.ReaduInt16();
518 rStrm.Ignore( 10 );
519 rStrm >> aXclRanges;
521}
522
524{
525 if( mnCondIndex >= mnCondCount )
526 {
527 OSL_FAIL( "XclImpCondFormat::ReadCF - CF without leading CONDFMT" );
528 return;
529 }
530
531 // entire conditional format outside of valid range?
532 if( maRanges.empty() )
533 return;
534
535 sal_uInt8 nType = rStrm.ReaduInt8();
536 sal_uInt8 nOperator = rStrm.ReaduInt8();
537 sal_uInt16 nFmlaSize1 = rStrm.ReaduInt16();
538 sal_uInt16 nFmlaSize2 = rStrm.ReaduInt16();
539 sal_uInt32 nFlags = rStrm.ReaduInt32();
540 rStrm.Ignore( 2 ); //nFlagsExtended
541
542 // *** mode and comparison operator ***
543
545 switch( nType )
546 {
547 case EXC_CF_TYPE_CELL:
548 {
549 switch( nOperator )
550 {
559 default:
560 SAL_INFO(
561 "sc.filter", "unknown CF comparison " << nOperator);
562 }
563 }
564 break;
565
566 case EXC_CF_TYPE_FMLA:
568 break;
569
570 default:
571 SAL_INFO("sc.filter", "unknown CF mode " << nType);
572 return;
573 }
574
575 // *** create style sheet ***
576
578 SfxItemSet& rStyleItemSet = ScfTools::MakeCellStyleSheet( GetStyleSheetPool(), aStyleName, true ).GetItemSet();
579
580 const XclImpPalette& rPalette = GetPalette();
581
582 // number format
583
584 if( get_flag( nFlags, EXC_CF_BLOCK_NUMFMT ) )
585 {
586 XclImpNumFmtBuffer& rNumFmtBuffer = GetRoot().GetNumFmtBuffer();
587 bool bIFmt = get_flag( nFlags, EXC_CF_IFMT_USER );
588 sal_uInt16 nFormat = rNumFmtBuffer.ReadCFFormat( rStrm, bIFmt );
589 rNumFmtBuffer.FillToItemSet( rStyleItemSet, nFormat );
590 }
591
592 // *** font block ***
593
594 if( ::get_flag( nFlags, EXC_CF_BLOCK_FONT ) )
595 {
596 XclImpFont aFont( GetRoot() );
597 aFont.ReadCFFontBlock( rStrm );
598 aFont.FillToItemSet( rStyleItemSet, XclFontItemType::Cell );
599 }
600
601 // alignment
602 if( get_flag( nFlags, EXC_CF_BLOCK_ALIGNMENT ) )
603 {
604 XclImpCellAlign aAlign;
605 sal_uInt16 nAlign(0);
606 sal_uInt16 nAlignMisc(0);
607 nAlign = rStrm.ReaduInt16();
608 nAlignMisc = rStrm.ReaduInt16();
609 aAlign.FillFromCF( nAlign, nAlignMisc );
610 aAlign.FillToItemSet( rStyleItemSet, nullptr );
611 rStrm.Ignore(4);
612 }
613
614 // *** border block ***
615
616 if( ::get_flag( nFlags, EXC_CF_BLOCK_BORDER ) )
617 {
618 sal_uInt16 nLineStyle(0);
619 sal_uInt32 nLineColor(0);
620 nLineStyle = rStrm.ReaduInt16();
621 nLineColor = rStrm.ReaduInt32();
622 rStrm.Ignore( 2 );
623
624 XclImpCellBorder aBorder;
625 aBorder.FillFromCF8( nLineStyle, nLineColor, nFlags );
626 aBorder.FillToItemSet( rStyleItemSet, rPalette );
627 }
628
629 // *** pattern block ***
630
631 if( ::get_flag( nFlags, EXC_CF_BLOCK_AREA ) )
632 {
633 sal_uInt16 nPattern(0), nColor(0);
634 nPattern = rStrm.ReaduInt16();
635 nColor = rStrm.ReaduInt16();
636
637 XclImpCellArea aArea;
638 aArea.FillFromCF8( nPattern, nColor, nFlags );
639 aArea.FillToItemSet( rStyleItemSet, rPalette );
640 }
641
642 if( get_flag( nFlags, EXC_CF_BLOCK_PROTECTION ) )
643 {
644 sal_uInt16 nCellProt;
645 nCellProt = rStrm.ReaduInt16();
646 XclImpCellProt aCellProt;
647 aCellProt.FillFromXF3(nCellProt);
648 aCellProt.FillToItemSet( rStyleItemSet );
649 }
650
651 // *** formulas ***
652
653 const ScAddress& rPos = maRanges.front().aStart; // assured above that maRanges is not empty
654 ExcelToSc& rFmlaConv = GetOldFmlaConverter();
655
656 ::std::unique_ptr< ScTokenArray > xTokArr1;
657 if( nFmlaSize1 > 0 )
658 {
659 std::unique_ptr<ScTokenArray> pTokArr;
660 rFmlaConv.Reset( rPos );
661 rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize1, false, FT_CondFormat );
662 // formula converter owns pTokArr -> create a copy of the token array
663 if( pTokArr )
664 {
665 xTokArr1 = std::move( pTokArr );
667 }
668 }
669
670 ::std::unique_ptr< ScTokenArray > xTokArr2;
671 if( nFmlaSize2 > 0 )
672 {
673 std::unique_ptr<ScTokenArray> pTokArr;
674 rFmlaConv.Reset( rPos );
675 rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize2, false, FT_CondFormat );
676 // formula converter owns pTokArr -> create a copy of the token array
677 if( pTokArr )
678 {
679 xTokArr2 = std::move( pTokArr );
681 }
682 }
683
684 // *** create the Calc conditional formatting ***
685
686 const ScAddress aPos(rPos); //in case maRanges.Join invalidates it
687
688 if( !mxScCondFmt )
689 {
690 mxScCondFmt.reset( new ScConditionalFormat( 0/*nKey*/, &GetDoc() ) );
691 if(maRanges.size() > 1)
692 maRanges.Join(maRanges[0], true);
693 mxScCondFmt->SetRange(maRanges);
694 }
695
696 ScCondFormatEntry* pEntry = new ScCondFormatEntry(eMode, xTokArr1.get(), xTokArr2.get(), GetDoc(), aPos, aStyleName);
697 mxScCondFmt->AddEntry( pEntry );
698 ++mnCondIndex;
699}
700
702{
703 if( mxScCondFmt )
704 {
705 ScDocument& rDoc = GetDoc();
706
707 SCTAB nTab = maRanges.front().aStart.Tab();
708 sal_uLong nKey = rDoc.AddCondFormat( mxScCondFmt->Clone(), nTab );
709
710 rDoc.AddCondFormatData( maRanges, nTab, nKey );
711 }
712}
713
715 XclImpRoot( rRoot )
716{
717}
718
720{
722 pFmt->ReadCondfmt( rStrm );
723 maCondFmtList.push_back( std::unique_ptr<XclImpCondFormat>(pFmt) );
724}
725
727{
728 OSL_ENSURE( !maCondFmtList.empty(), "XclImpCondFormatManager::ReadCF - CF without leading CONDFMT" );
729 if( !maCondFmtList.empty() )
730 maCondFmtList.back()->ReadCF( rStrm );
731}
732
734{
735 for( auto& rxFmt : maCondFmtList )
736 rxFmt->Apply();
737 maCondFmtList.clear();
738}
739
740// Data Validation ============================================================
741
743 maRanges(std::move(aRanges)), maValidData(rValidData) {}
744
746 XclImpRoot( rRoot )
747{
748}
749
751{
752 const XclImpRoot& rRoot = rStrm.GetRoot();
753 OSL_ENSURE_BIFF( rRoot.GetBiff() == EXC_BIFF8 );
754
755 sal_uInt32 nObjId(0);
756 rStrm.Ignore( 10 );
757 nObjId = rStrm.ReaduInt32();
758 if( nObjId != EXC_DVAL_NOOBJ )
759 {
760 OSL_ENSURE( nObjId <= 0xFFFF, "XclImpValidation::ReadDval - invalid object ID" );
761 rRoot.GetCurrSheetDrawing().SetSkipObj( static_cast< sal_uInt16 >( nObjId ) );
762 }
763}
764
766{
767 const XclImpRoot& rRoot = rStrm.GetRoot();
768 OSL_ENSURE_BIFF( rRoot.GetBiff() == EXC_BIFF8 );
769
770 ScDocument& rDoc = rRoot.GetDoc();
771 SCTAB nScTab = rRoot.GetCurrScTab();
772 ExcelToSc& rFmlaConv = rRoot.GetOldFmlaConverter();
773
774 // flags
775 sal_uInt32 nFlags = rStrm.ReaduInt32();
776
777 // message strings
778 /* Empty strings are single NUL characters in Excel (string length is 1).
779 -> Do not let the stream replace them with '?' characters. */
780 rStrm.SetNulSubstChar( '\0' );
781 OUString aPromptTitle( rStrm.ReadUniString() );
782 OUString aErrorTitle( rStrm.ReadUniString() );
783 OUString aPromptMessage( rStrm.ReadUniString() );
784 OUString aErrorMessage( rStrm.ReadUniString() );
785 rStrm.SetNulSubstChar(); // back to default
786
787 // formula(s)
788 if ( rStrm.GetRecLeft() <= 8 )
789 // Not enough bytes left in the record. Bail out.
790 return;
791
792 // first formula
793 // string list is single tStr token with NUL separators -> replace them with LF
794 rStrm.SetNulSubstChar( '\n' );
795 ::std::unique_ptr< ScTokenArray > xTokArr1;
796
797 // We can't import the formula directly because we need the range
798 sal_uInt16 nLenFormula1 = rStrm.ReaduInt16();
799 rStrm.Ignore( 2 );
800 XclImpStreamPos aPosFormula1;
801 rStrm.StorePosition(aPosFormula1);
802 rStrm.Ignore(nLenFormula1);
803
804 // second formula
805 ::std::unique_ptr< ScTokenArray > xTokArr2;
806
807 sal_uInt16 nLenFormula2 = rStrm.ReaduInt16();
808 rStrm.Ignore( 2 );
809 XclImpStreamPos aPosFormula2;
810 rStrm.StorePosition(aPosFormula2);
811 rStrm.Ignore(nLenFormula2);
812
813 // read all cell ranges
814 XclRangeList aXclRanges;
815 rStrm >> aXclRanges;
816
817 // convert to Calc range list
818 ScRangeList aScRanges;
819 rRoot.GetAddressConverter().ConvertRangeList( aScRanges, aXclRanges, nScTab, true );
820
821 // only continue if there are valid ranges
822 if ( aScRanges.empty() )
823 return;
824
825 ScRange aCombinedRange = aScRanges.Combine();
826
827 XclImpStreamPos aCurrentPos;
828 rStrm.StorePosition(aCurrentPos);
829 rStrm.RestorePosition(aPosFormula1);
830 if( nLenFormula1 > 0 )
831 {
832 std::unique_ptr<ScTokenArray> pTokArr;
833 rFmlaConv.Reset(aCombinedRange.aStart);
834 rFmlaConv.Convert( pTokArr, rStrm, nLenFormula1, false, FT_CondFormat );
835 // formula converter owns pTokArr -> create a copy of the token array
836 if( pTokArr )
837 xTokArr1 = std::move( pTokArr );
838 }
839 rStrm.SetNulSubstChar(); // back to default
840 if (nLenFormula2 > 0)
841 {
842 rStrm.RestorePosition(aPosFormula2);
843 std::unique_ptr<ScTokenArray> pTokArr;
844 rFmlaConv.Reset(aCombinedRange.aStart);
845 rFmlaConv.Convert( pTokArr, rStrm, nLenFormula2, false, FT_CondFormat );
846 // formula converter owns pTokArr -> create a copy of the token array
847 if( pTokArr )
848 xTokArr2 = std::move( pTokArr );
849 }
850
851 rStrm.RestorePosition(aCurrentPos);
852
853 bool bIsValid = true; // valid settings in flags field
854
856 switch( nFlags & EXC_DV_MODE_MASK )
857 {
858 case EXC_DV_MODE_ANY: eValMode = SC_VALID_ANY; break;
859 case EXC_DV_MODE_WHOLE: eValMode = SC_VALID_WHOLE; break;
860 case EXC_DV_MODE_DECIMAL: eValMode = SC_VALID_DECIMAL; break;
861 case EXC_DV_MODE_LIST: eValMode = SC_VALID_LIST; break;
862 case EXC_DV_MODE_DATE: eValMode = SC_VALID_DATE; break;
863 case EXC_DV_MODE_TIME: eValMode = SC_VALID_TIME; break;
864 case EXC_DV_MODE_TEXTLEN: eValMode = SC_VALID_TEXTLEN; break;
865 case EXC_DV_MODE_CUSTOM: eValMode = SC_VALID_CUSTOM; break;
866 default: bIsValid = false;
867 }
868 rRoot.GetTracer().TraceDVType(eValMode == SC_VALID_CUSTOM);
869
871 switch( nFlags & EXC_DV_COND_MASK )
872 {
873 case EXC_DV_COND_BETWEEN: eCondMode = ScConditionMode::Between; break;
875 case EXC_DV_COND_EQUAL: eCondMode = ScConditionMode::Equal; break;
876 case EXC_DV_COND_NOTEQUAL: eCondMode = ScConditionMode::NotEqual; break;
877 case EXC_DV_COND_GREATER: eCondMode = ScConditionMode::Greater; break;
878 case EXC_DV_COND_LESS: eCondMode = ScConditionMode::Less; break;
879 case EXC_DV_COND_EQGREATER: eCondMode = ScConditionMode::EqGreater; break;
880 case EXC_DV_COND_EQLESS: eCondMode = ScConditionMode::EqLess; break;
881 default: bIsValid = false;
882 }
883
884 if ( !bIsValid )
885 // No valid validation found. Bail out.
886 return;
887
888 // The default value for comparison is _BETWEEN. However, custom
889 // rules are a formula, and thus the comparator should be ignored
890 // and only a true or false from the formula is evaluated. In Calc,
891 // formulas use comparison SC_COND_DIRECT.
892 if( eValMode == SC_VALID_CUSTOM )
893 {
894 eCondMode = ScConditionMode::Direct;
895 }
896
897 // first range for base address for relative references
898 const ScRange& rScRange = aScRanges.front(); // aScRanges is not empty
899
900 // process string list of a list validity (convert to list of string tokens)
901 if( xTokArr1 && (eValMode == SC_VALID_LIST) && ::get_flag( nFlags, EXC_DV_STRINGLIST ) )
903
904 maDVItems.push_back(
905 std::make_unique<DVItem>(aScRanges, ScValidationData(eValMode, eCondMode, xTokArr1.get(), xTokArr2.get(), rDoc, rScRange.aStart)));
906 DVItem& rItem = *maDVItems.back();
907
909 rItem.maValidData.SetListType( ::get_flagvalue( nFlags, EXC_DV_SUPPRESSDROPDOWN, css::sheet::TableValidationVisibility::INVISIBLE, css::sheet::TableValidationVisibility::UNSORTED ) );
910
911 // *** prompt box ***
912 if( !aPromptTitle.isEmpty() || !aPromptMessage.isEmpty() )
913 {
914 // set any text stored in the record
915 rItem.maValidData.SetInput( aPromptTitle, aPromptMessage );
916 if( !::get_flag( nFlags, EXC_DV_SHOWPROMPT ) )
917 rItem.maValidData.ResetInput();
918 }
919
920 // *** error box ***
922 switch( nFlags & EXC_DV_ERROR_MASK )
923 {
924 case EXC_DV_ERROR_WARNING: eErrStyle = SC_VALERR_WARNING; break;
925 case EXC_DV_ERROR_INFO: eErrStyle = SC_VALERR_INFO; break;
926 }
927 // set texts and error style
928 rItem.maValidData.SetError( aErrorTitle, aErrorMessage, eErrStyle );
929 if( !::get_flag( nFlags, EXC_DV_SHOWERROR ) )
930 rItem.maValidData.ResetError();
931}
932
934{
935 const bool bFuzzing = utl::ConfigManager::IsFuzzing();
936 size_t nPatterns = 0;
937
938 ScDocument& rDoc = GetRoot().GetDoc();
939 for (const auto& rxDVItem : maDVItems)
940 {
941 DVItem& rItem = *rxDVItem;
942 // set the handle ID
943 sal_uInt32 nHandle = rDoc.AddValidationEntry( rItem.maValidData );
944 ScPatternAttr aPattern( rDoc.GetPool() );
946
947 // apply all ranges
948 for ( size_t i = 0, nRanges = rItem.maRanges.size(); i < nRanges; ++i, ++nPatterns )
949 {
950 const ScRange & rScRange = rItem.maRanges[ i ];
951 rDoc.ApplyPatternAreaTab( rScRange.aStart.Col(), rScRange.aStart.Row(),
952 rScRange.aEnd.Col(), rScRange.aEnd.Row(), rScRange.aStart.Tab(), aPattern );
953 if (bFuzzing && nPatterns >= 128)
954 {
955 SAL_WARN("sc.filter", "for fuzzing performance, abandoned pattern after " << nPatterns << " insertions");
956 break;
957 }
958 }
959 }
960 maDVItems.clear();
961}
962
963// Web queries ================================================================
964
966 maDestRange( rDestRange ),
967 meMode( xlWQUnknown ),
968 mnRefresh( 0 )
969{
970}
971
973{
974 sal_uInt16 nFlags = rStrm.ReaduInt16();
975 sal_uInt16 nType = ::extract_value< sal_uInt16 >( nFlags, 0, 3 );
976 if( !((nType == EXC_PQRYTYPE_WEBQUERY) && ::get_flag( nFlags, EXC_PQRY_WEBQUERY )) )
977 return;
978
979 if( ::get_flag( nFlags, EXC_PQRY_TABLES ) )
980 {
983 }
984 else
985 {
988 }
989}
990
992{
993 maURL = rStrm.ReadUniString();
994}
995
997{
998 rStrm.Ignore( 10 );
999 sal_uInt16 nFlags = rStrm.ReaduInt16();
1000 rStrm.Ignore( 10 );
1001 mnRefresh = rStrm.ReaduInt16();
1002
1003 if( ::get_flag( nFlags, EXC_WQSETT_SPECTABLES ) && (meMode == xlWQAllTables) )
1005}
1006
1008{
1009 if( meMode != xlWQSpecTables )
1010 return;
1011
1012 rStrm.Ignore( 4 );
1013 OUString aTables( rStrm.ReadUniString() );
1014
1015 const sal_Unicode cSep = ';';
1016 static const OUStringLiteral aQuotedPairs( u"\"\"" );
1017 maTables.clear();
1018 for ( sal_Int32 nStringIx {aTables.isEmpty() ? -1 : 0}; nStringIx>=0; )
1019 {
1020 OUString aToken( ScStringUtil::GetQuotedToken( aTables, 0, aQuotedPairs, ',', nStringIx ) );
1021 sal_Int32 nTabNum = CharClass::isAsciiNumeric( aToken ) ? aToken.toInt32() : 0;
1022 if( nTabNum > 0 )
1023 maTables = ScGlobal::addToken( maTables, ScfTools::GetNameFromHTMLIndex( static_cast< sal_uInt32 >( nTabNum ) ), cSep );
1024 else
1025 {
1026 ScGlobal::EraseQuotes( aToken, '"', false );
1027 if( !aToken.isEmpty() )
1029 }
1030 }
1031}
1032
1033void XclImpWebQuery::Apply( ScDocument& rDoc, const OUString& rFilterName )
1034{
1035 if( !maURL.isEmpty() && (meMode != xlWQUnknown) && rDoc.GetDocumentShell() )
1036 {
1038 maURL, rFilterName, OUString(), maTables, maDestRange, mnRefresh * 60UL );
1040 maURL, &rFilterName, &maTables );
1041 }
1042}
1043
1045 XclImpRoot( rRoot )
1046{
1047}
1048
1050{
1051 if( GetBiff() == EXC_BIFF8 )
1052 {
1053 rStrm.Ignore( 10 );
1054 OUString aXclName( rStrm.ReadUniString() );
1055
1056 // #i64794# Excel replaces spaces with underscores
1057 aXclName = aXclName.replaceAll( " ", "_" );
1058
1059 // find the defined name used in Calc
1060 if( const XclImpName* pName = GetNameManager().FindName( aXclName, GetCurrScTab() ) )
1061 {
1062 if( const ScRangeData* pRangeData = pName->GetScRangeData() )
1063 {
1064 ScRange aRange;
1065 if( pRangeData->IsReference( aRange ) )
1066 maWQList.emplace_back( aRange );
1067 }
1068 }
1069 }
1070 else
1071 {
1073 }
1074}
1075
1077{
1078 if (!maWQList.empty())
1079 maWQList.back().ReadParamqry( rStrm );
1080}
1081
1083{
1084 if (!maWQList.empty())
1085 maWQList.back().ReadWqstring( rStrm );
1086}
1087
1089{
1090 if (!maWQList.empty())
1091 maWQList.back().ReadWqsettings( rStrm );
1092}
1093
1095{
1096 if (!maWQList.empty())
1097 maWQList.back().ReadWqtables( rStrm );
1098}
1099
1101{
1102 ScDocument& rDoc = GetDoc();
1103 for( auto& rQuery : maWQList )
1104 rQuery.Apply( rDoc, EXC_WEBQRY_FILTER );
1105}
1106
1107// Decryption =================================================================
1108
1109namespace {
1110
1111XclImpDecrypterRef lclReadFilepass5( XclImpStream& rStrm )
1112{
1113 XclImpDecrypterRef xDecr;
1114 OSL_ENSURE( rStrm.GetRecLeft() == 4, "lclReadFilepass5 - wrong record size" );
1115 if( rStrm.GetRecLeft() == 4 )
1116 {
1117 sal_uInt16 nKey(0), nHash(0);
1118 nKey = rStrm.ReaduInt16();
1119 nHash = rStrm.ReaduInt16();
1120 xDecr = std::make_shared<XclImpBiff5Decrypter>( nKey, nHash );
1121 }
1122 return xDecr;
1123}
1124
1125XclImpDecrypterRef lclReadFilepass8_Standard( XclImpStream& rStrm )
1126{
1127 XclImpDecrypterRef xDecr;
1128 OSL_ENSURE( rStrm.GetRecLeft() == 48, "lclReadFilepass8 - wrong record size" );
1129 if( rStrm.GetRecLeft() == 48 )
1130 {
1131 std::vector<sal_uInt8> aSalt(16);
1132 std::vector<sal_uInt8> aVerifier(16);
1133 std::vector<sal_uInt8> aVerifierHash(16);
1134 rStrm.Read(aSalt.data(), 16);
1135 rStrm.Read(aVerifier.data(), 16);
1136 rStrm.Read(aVerifierHash.data(), 16);
1137 xDecr = std::make_shared<XclImpBiff8StdDecrypter>(std::move(aSalt), std::move(aVerifier), std::move(aVerifierHash));
1138 }
1139 return xDecr;
1140}
1141
1142XclImpDecrypterRef lclReadFilepass8_Strong(XclImpStream& rStream)
1143{
1144 //It is possible there are other variants in existence but these
1145 //are the defaults I get with Excel 2013
1146 XclImpDecrypterRef xDecr;
1147
1149
1150 info.header.flags = rStream.ReaduInt32();
1152 return xDecr;
1153
1154 sal_uInt32 nHeaderSize = rStream.ReaduInt32();
1155 sal_uInt32 actualHeaderSize = sizeof(info.header);
1156
1157 if( nHeaderSize < actualHeaderSize )
1158 return xDecr;
1159
1160 info.header.flags = rStream.ReaduInt32();
1161 info.header.sizeExtra = rStream.ReaduInt32();
1162 info.header.algId = rStream.ReaduInt32();
1163 info.header.algIdHash = rStream.ReaduInt32();
1164 info.header.keyBits = rStream.ReaduInt32();
1165 info.header.providedType = rStream.ReaduInt32();
1166 info.header.reserved1 = rStream.ReaduInt32();
1167 info.header.reserved2 = rStream.ReaduInt32();
1168
1169 rStream.Ignore(nHeaderSize - actualHeaderSize);
1170
1171 info.verifier.saltSize = rStream.ReaduInt32();
1173 return xDecr;
1174 rStream.Read(&info.verifier.salt, sizeof(info.verifier.salt));
1175 rStream.Read(&info.verifier.encryptedVerifier, sizeof(info.verifier.encryptedVerifier));
1176
1178 if (info.verifier.encryptedVerifierHashSize != RTL_DIGEST_LENGTH_SHA1)
1179 return xDecr;
1181
1182 // check flags and algorithm IDs, required are AES128 and SHA-1
1184 return xDecr;
1185
1187 return xDecr;
1188
1190 return xDecr;
1191
1192 // hash algorithm ID 0 defaults to SHA-1 too
1194 return xDecr;
1195
1196 xDecr = std::make_shared<XclImpBiff8CryptoAPIDecrypter>(
1197 std::vector<sal_uInt8>(info.verifier.salt,
1199 std::vector<sal_uInt8>(info.verifier.encryptedVerifier,
1201 std::vector<sal_uInt8>(info.verifier.encryptedVerifierHash,
1203
1204 return xDecr;
1205}
1206
1207XclImpDecrypterRef lclReadFilepass8( XclImpStream& rStrm )
1208{
1209 XclImpDecrypterRef xDecr;
1210
1211 sal_uInt16 nMode = rStrm.ReaduInt16();
1212 switch( nMode )
1213 {
1214 case EXC_FILEPASS_BIFF5:
1215 xDecr = lclReadFilepass5( rStrm );
1216 break;
1217
1218 case EXC_FILEPASS_BIFF8:
1219 {
1220 sal_uInt32 nVersion = rStrm.ReaduInt32();
1221 if (nVersion == msfilter::VERSION_INFO_1997_FORMAT)
1222 {
1223 //A Version structure where Version.vMajor MUST be 0x0001,
1224 //and Version.vMinor MUST be 0x0001.
1225 xDecr = lclReadFilepass8_Standard(rStrm);
1226 }
1227 else if (nVersion == msfilter::VERSION_INFO_2007_FORMAT ||
1229 {
1230 //Version.vMajor MUST be 0x0002, 0x0003 or 0x0004 and
1231 //Version.vMinor MUST be 0x0002.
1232 xDecr = lclReadFilepass8_Strong(rStrm);
1233 }
1234 else
1235 OSL_FAIL("lclReadFilepass8 - unknown BIFF8 encryption sub mode");
1236 }
1237 break;
1238
1239 default:
1240 OSL_FAIL( "lclReadFilepass8 - unknown encryption mode" );
1241 }
1242
1243 return xDecr;
1244}
1245
1246} // namespace
1247
1249{
1250 XclImpDecrypterRef xDecr;
1251 rStrm.DisableDecryption();
1252
1253 // read the FILEPASS record and create a new decrypter object
1254 switch( rStrm.GetRoot().GetBiff() )
1255 {
1256 case EXC_BIFF2:
1257 case EXC_BIFF3:
1258 case EXC_BIFF4:
1259 case EXC_BIFF5: xDecr = lclReadFilepass5( rStrm ); break;
1260 case EXC_BIFF8: xDecr = lclReadFilepass8( rStrm ); break;
1261 default: DBG_ERROR_BIFF();
1262 };
1263
1264 // set decrypter at import stream
1265 rStrm.SetDecrypter( xDecr );
1266
1267 // request and verify a password (decrypter implements IDocPasswordVerifier)
1268 if( xDecr )
1269 rStrm.GetRoot().RequestEncryptionData( *xDecr );
1270
1271 // return error code (success, wrong password, etc.)
1272 return xDecr ? xDecr->GetError() : EXC_ENCR_ERROR_UNSUPP_CRYPT;
1273}
1274
1275// Document protection ========================================================
1276
1278 XclImpRoot( rRoot ),
1279 mnPassHash(0x0000),
1280 mbDocProtect(false),
1281 mbWinProtect(false)
1282{
1283}
1284
1286{
1287 mbDocProtect = rStrm.ReaduInt16() != 0;
1288}
1289
1291{
1292 mbWinProtect = rStrm.ReaduInt16() != 0;
1293}
1294
1296{
1297 rStrm.EnableDecryption();
1298 mnPassHash = rStrm.ReaduInt16();
1299}
1300
1302{
1303 if (!mbDocProtect && !mbWinProtect)
1304 // Excel requires either the structure or windows protection is set.
1305 // If neither is set then the document is not protected at all.
1306 return;
1307
1308 unique_ptr<ScDocProtection> pProtect(new ScDocProtection);
1309 pProtect->setProtected(true);
1310
1311 if (mnPassHash)
1312 {
1313 // 16-bit password hash.
1314 Sequence<sal_Int8> aPass{sal_Int8(mnPassHash >> 8), sal_Int8(mnPassHash & 0xFF)};
1315 pProtect->setPasswordHash(aPass, PASSHASH_XL);
1316 }
1317
1318 // document protection options
1319 pProtect->setOption(ScDocProtection::STRUCTURE, mbDocProtect);
1320 pProtect->setOption(ScDocProtection::WINDOWS, mbWinProtect);
1321
1322 GetDoc().SetDocProtection(pProtect.get());
1323}
1324
1325// Sheet Protection ===========================================================
1326
1328 mbProtected(false),
1329 mnPasswordHash(0x0000),
1330 mnOptions(0x4400)
1331{
1332}
1333
1335 mbProtected(r.mbProtected),
1336 mnPasswordHash(r.mnPasswordHash),
1337 mnOptions(r.mnOptions)
1338{
1339}
1340
1342 XclImpRoot( rRoot )
1343{
1344}
1345
1347{
1348 if ( rStrm.ReaduInt16() )
1349 {
1350 Sheet* pSheet = GetSheetItem(nTab);
1351 if (pSheet)
1352 pSheet->mbProtected = true;
1353 }
1354}
1355
1357{
1358 // The flag size specifies the size of bytes that follows that stores
1359 // feature data. If -1 it depends on the feature type imported earlier.
1360 // For enhanced protection data, the size is always 4. For the most xls
1361 // documents out there this value is almost always -1.
1362 sal_Int32 nFlagSize = rStrm.ReadInt32();
1363 if (nFlagSize != -1)
1364 return;
1365
1366 // There are actually 4 bytes to read, but the upper 2 bytes currently
1367 // don't store any bits.
1368 sal_uInt16 nOptions = rStrm.ReaduInt16();
1369
1370 Sheet* pSheet = GetSheetItem(nTab);
1371 if (pSheet)
1372 pSheet->mnOptions = nOptions;
1373}
1374
1376{
1377 Sheet* pSheet = GetSheetItem(nTab);
1378 if (pSheet)
1379 pSheet->maEnhancedProtections.push_back( rProt);
1380}
1381
1383{
1384 sal_uInt16 nHash = rStrm.ReaduInt16();
1385 Sheet* pSheet = GetSheetItem(nTab);
1386 if (pSheet)
1387 pSheet->mnPasswordHash = nHash;
1388}
1389
1391{
1392 for (const auto& [rTab, rSheet] : maProtectedSheets)
1393 {
1394 if (!rSheet.mbProtected)
1395 // This sheet is (for whatever reason) not protected.
1396 continue;
1397
1398 unique_ptr<ScTableProtection> pProtect(new ScTableProtection);
1399 pProtect->setProtected(true);
1400
1401 // 16-bit hash password
1402 const sal_uInt16 nHash = rSheet.mnPasswordHash;
1403 if (nHash)
1404 {
1405 Sequence<sal_Int8> aPass{sal_Int8(nHash >> 8), sal_Int8(nHash & 0xFF)};
1406 pProtect->setPasswordHash(aPass, PASSHASH_XL);
1407 }
1408
1409 // sheet protection options
1410 const sal_uInt16 nOptions = rSheet.mnOptions;
1411 pProtect->setOption( ScTableProtection::OBJECTS, (nOptions & 0x0001) );
1412 pProtect->setOption( ScTableProtection::SCENARIOS, (nOptions & 0x0002) );
1413 pProtect->setOption( ScTableProtection::FORMAT_CELLS, (nOptions & 0x0004) );
1414 pProtect->setOption( ScTableProtection::FORMAT_COLUMNS, (nOptions & 0x0008) );
1415 pProtect->setOption( ScTableProtection::FORMAT_ROWS, (nOptions & 0x0010) );
1416 pProtect->setOption( ScTableProtection::INSERT_COLUMNS, (nOptions & 0x0020) );
1417 pProtect->setOption( ScTableProtection::INSERT_ROWS, (nOptions & 0x0040) );
1418 pProtect->setOption( ScTableProtection::INSERT_HYPERLINKS, (nOptions & 0x0080) );
1419 pProtect->setOption( ScTableProtection::DELETE_COLUMNS, (nOptions & 0x0100) );
1420 pProtect->setOption( ScTableProtection::DELETE_ROWS, (nOptions & 0x0200) );
1421 pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, (nOptions & 0x0400) );
1422 pProtect->setOption( ScTableProtection::SORT, (nOptions & 0x0800) );
1423 pProtect->setOption( ScTableProtection::AUTOFILTER, (nOptions & 0x1000) );
1424 pProtect->setOption( ScTableProtection::PIVOT_TABLES, (nOptions & 0x2000) );
1425 pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, (nOptions & 0x4000) );
1426
1427 // Enhanced protection containing editable ranges and permissions.
1428 pProtect->setEnhancedProtection( std::vector(rSheet.maEnhancedProtections) );
1429
1430 // all done. now commit.
1431 GetDoc().SetTabProtection(rTab, pProtect.get());
1432 }
1433}
1434
1436{
1437 ProtectedSheetMap::iterator itr = maProtectedSheets.find(nTab);
1438 if (itr == maProtectedSheets.end())
1439 {
1440 // new sheet
1441 if ( !maProtectedSheets.emplace( nTab, Sheet() ).second )
1442 return nullptr;
1443
1444 itr = maProtectedSheets.find(nTab);
1445 }
1446
1447 return &itr->second;
1448}
1449
1450/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
static bool isAsciiNumeric(std::u16string_view rStr)
std::unique_ptr< EditTextObject > CreateTextObject()
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
const SfxItemSet & GetEmptyItemSet() const
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
virtual ConvErr Convert(std::unique_ptr< ScTokenArray > &, XclImpStream &rStrm, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT=FT_CellFormula) override
Definition: excform.cxx:201
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetURLObject smartRel2Abs(OUString const &rTheRelURIRef, bool &rWasAbsolute, bool bIgnoreFragment=false, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, bool bRelativeNonURIs=false, FSysStyle eStyle=FSysStyle::Detect) const
@ UNINITIALIZED
Definition: address.hxx:220
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
SCCOL Col() const
Definition: address.hxx:279
static OUString GetString(const ScRefCellValue &rCell, sal_uInt32 nFormat, const Color **ppColor, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bNullVals=true, bool bFormula=false, bool bUseStarFormat=false)
Definition: cellform.cxx:31
void SetIgnoreBlank(bool bSet)
Definition: conditio.cxx:418
Accessor class to ScDocument.
void setEditCell(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
ScDocument & getDoc()
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3686
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:891
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6170
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4864
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:892
SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck(const ScTokenArray &rCode)
Check token array and set link check if ocDde/ocWebservice is contained.
Definition: documen8.cxx:1154
ScInterpreterContext & GetNonThreadedContext() const
Definition: document.hxx:616
ScRangePairListRef & GetRowNameRangesRef()
Definition: document.hxx:821
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4835
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1081
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:592
SC_DLLPUBLIC sal_uLong AddValidationEntry(const ScValidationData &rNew)
Definition: documen4.cxx:726
SC_DLLPUBLIC void AddCondFormatData(const ScRangeList &rRange, SCTAB nTab, sal_uInt32 nIndex)
Definition: document.cxx:4885
ScRangePairListRef & GetColNameRangesRef()
Definition: document.hxx:820
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
SC_DLLPUBLIC void SetDocProtection(const ScDocProtection *pProtect)
Definition: documen3.cxx:1900
SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection *pProtect)
Definition: documen3.cxx:1936
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:231
SC_DLLPUBLIC sal_uLong AddCondFormat(std::unique_ptr< ScConditionalFormat > pNew, SCTAB nTab)
Definition: documen4.cxx:715
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4813
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:616
static SC_DLLPUBLIC void EraseQuotes(OUString &rString, sal_Unicode cQuote, bool bUnescapeEmbedded=true)
Erases the character cQuote from rString, if it exists at beginning AND end.
Definition: global.cxx:731
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
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
ScRange & front()
Definition: rangelst.hxx:92
void Join(const ScRange &, bool bIsInList=false)
Definition: rangelst.cxx:152
ScRange Combine() const
Definition: rangelst.cxx:1107
bool empty() const
Definition: rangelst.hxx:88
size_t size() const
Definition: rangelst.hxx:89
void GetVars(SCCOL &nCol1, SCROW &nRow1, SCTAB &nTab1, SCCOL &nCol2, SCROW &nRow2, SCTAB &nTab2) const
Definition: address.hxx:690
ScAddress aEnd
Definition: address.hxx:498
ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
Definition: address.cxx:1733
ScAddress aStart
Definition: address.hxx:497
static OUString SC_DLLPUBLIC GetQuotedToken(const OUString &rIn, sal_Int32 nToken, const OUString &rQuotedPairs, sal_Unicode cTok, sal_Int32 &rIndex)
Definition: stringutil.cxx:347
virtual SC_DLLPUBLIC SfxItemSet & GetItemSet() override
Definition: stlsheet.cxx:128
sheet protection state container
void SetListType(sal_Int16 nListType)
Definition: validat.hxx:117
void SetInput(const OUString &rTitle, const OUString &rMsg)
Definition: validat.cxx:160
void ResetInput()
Definition: validat.cxx:150
void SetError(const OUString &rTitle, const OUString &rMsg, ScValidErrorStyle eStyle)
Definition: validat.cxx:167
void ResetError()
Definition: validat.cxx:155
static const OUString & GetHTMLDocName()
Returns the built-in range name for an HTML document.
Definition: ftools.cxx:285
static const OUString & GetHTMLTablesName()
Returns the built-in range name for all HTML tables.
Definition: ftools.cxx:291
static OUString GetNameFromHTMLIndex(sal_uInt32 nIndex)
Returns the built-in range name for an HTML table, specified by table index.
Definition: ftools.cxx:310
static ScStyleSheet & MakeCellStyleSheet(ScStyleSheetPool &rPool, const OUString &rStyleName, bool bForceName)
Creates and returns a cell style sheet and inserts it into the pool.
Definition: ftools.cxx:257
static OUString GetNameFromHTMLName(std::u16string_view rTabName)
Returns the built-in range name for an HTML table, specified by table name.
Definition: ftools.cxx:317
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const INetURLObject & GetURLObject() const
SfxMedium * GetMedium() const
SvStream & ReadInt32(sal_Int32 &rInt32)
ErrCode GetError() const
Provides functions to convert Excel cell addresses to Calc cell addresses.
Definition: xihelper.hxx:42
bool ConvertRange(ScRange &rScRange, const XclRange &rXclRange, SCTAB nScTab1, SCTAB nScTab2, bool bWarn)
Converts the passed Excel cell range to a Calc cell range.
Definition: xihelper.cxx:101
void ConvertRangeList(ScRangeList &rScRanges, const XclRangeList &rXclRanges, SCTAB nScTab, bool bWarn)
Converts the passed Excel cell range list to a Calc cell range list.
Definition: xihelper.cxx:125
std::vector< std::unique_ptr< XclImpCondFormat > > maCondFmtList
Definition: xicontent.hxx:162
void Apply()
Inserts the conditional formatting into the document.
Definition: xicontent.cxx:733
void ReadCondfmt(XclImpStream &rStrm)
Reads a CONDFMT record and starts a new conditional format to be filled from CF records.
Definition: xicontent.cxx:719
void ReadCF(XclImpStream &rStrm)
Reads a CF record and inserts the formatting data to the current conditional format.
Definition: xicontent.cxx:726
XclImpCondFormatManager(const XclImpRoot &rRoot)
Definition: xicontent.cxx:714
Represents a conditional format with condition formulas, and formatting attributes.
Definition: xicontent.hxx:123
sal_uInt32 mnFormatIndex
Calc conditional format.
Definition: xicontent.hxx:141
XclImpCondFormat(const XclImpRoot &rRoot, sal_uInt32 nFormatIndex)
Definition: xicontent.cxx:501
sal_uInt16 mnCondIndex
Number of conditions to be inserted.
Definition: xicontent.hxx:143
virtual ~XclImpCondFormat() override
Definition: xicontent.cxx:509
sal_uInt16 mnCondCount
Index of this conditional format in list.
Definition: xicontent.hxx:142
void ReadCondfmt(XclImpStream &rStrm)
Reads a CONDFMT record and initializes this conditional format.
Definition: xicontent.cxx:513
ScRangeList maRanges
Definition: xicontent.hxx:139
void Apply()
Inserts this conditional format into the document.
Definition: xicontent.cxx:701
ScCondFmtPtr mxScCondFmt
Destination cell ranges.
Definition: xicontent.hxx:140
void ReadCF(XclImpStream &rStrm)
Reads a CF record and adds a new condition and the formatting attributes.
Definition: xicontent.cxx:523
static const ErrCode & ReadFilepass(XclImpStream &rStrm)
Reads the FILEPASS record, queries a password and sets decryption algorithm.
Definition: xicontent.cxx:1248
XclImpDocProtectBuffer(const XclImpRoot &rRoot)
Definition: xicontent.cxx:1277
void ReadPasswordHash(XclImpStream &rStrm)
Definition: xicontent.cxx:1295
void ReadDocProtect(XclImpStream &rStrm)
document structure protection flag
Definition: xicontent.cxx:1285
void ReadWinProtect(XclImpStream &rStrm)
document windows properties protection flag
Definition: xicontent.cxx:1290
void SetSkipObj(sal_uInt16 nObjId)
Sets the object with the passed identification to be skipped on import.
Definition: xiescher.cxx:4070
Stores all data of an Excel font and provides import of FONT records.
Definition: xistyle.hxx:71
void ReadCFFontBlock(XclImpStream &rStrm)
Reads the font block from a CF (conditional format) record.
Definition: xistyle.cxx:283
void FillToItemSet(SfxItemSet &rItemSet, XclFontItemType eType, bool bSkipPoolDefs=false) const
Fills all font properties to the item set.
Definition: xistyle.cxx:317
static void ReadLabelranges(XclImpStream &rStrm)
Reads a LABELRANGES record and inserts the label ranges into the document.
Definition: xicontent.cxx:442
Represents a defined name.
Definition: xiname.hxx:34
Stores all user defined number formats occurred in the file.
Definition: xistyle.hxx:205
sal_uInt16 ReadCFFormat(XclImpStream &rStrm, bool bIFmt)
Read NumFmt from conditional format record.
Definition: xistyle.cxx:681
void FillToItemSet(SfxItemSet &rItemSet, sal_uInt16 nXclNumFmt, bool bSkipPoolDefs=false) const
Fills an Excel number format to the passed item set.
Definition: xistyle.cxx:731
Stores the default colors for the current BIFF version and the contents of a PALETTE record.
Definition: xistyle.hxx:45
Access to global data from other classes.
Definition: xiroot.hxx:129
ExcelToSc & GetOldFmlaConverter() const
Returns the old formula converter.
Definition: xiroot.cxx:133
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xiroot.cxx:123
ScDocumentImport & GetDocImport()
Definition: xiroot.cxx:294
XclImpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
Definition: xiroot.cxx:185
XclImpPalette & GetPalette() const
Returns the color buffer.
Definition: xiroot.cxx:145
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xiroot.hxx:134
XclImpSheetDrawing & GetCurrSheetDrawing() const
Returns the drawing container of the current sheet.
Definition: xiroot.cxx:201
XclImpNumFmtBuffer & GetNumFmtBuffer() const
Returns the number format buffer.
Definition: xiroot.cxx:155
XclImpSheetProtectBuffer(const XclImpRoot &rRoot)
Definition: xicontent.cxx:1341
void ReadOptions(XclImpStream &rStrm, SCTAB nTab)
Definition: xicontent.cxx:1356
void ReadProtect(XclImpStream &rStrm, SCTAB nTab)
Definition: xicontent.cxx:1346
Sheet * GetSheetItem(SCTAB nTab)
Definition: xicontent.cxx:1435
void AppendEnhancedProtection(const ScEnhancedProtection &rProt, SCTAB nTab)
Definition: xicontent.cxx:1375
ProtectedSheetMap maProtectedSheets
Definition: xicontent.hxx:327
void ReadPasswordHash(XclImpStream &rStrm, SCTAB nTab)
Definition: xicontent.cxx:1382
XclImpSst(const XclImpRoot &rRoot)
Definition: xicontent.cxx:69
const XclImpString * GetString(sal_uInt32 nSstIndex) const
Returns a pointer to the string with the passed index.
Definition: xicontent.cxx:95
XclImpStringVec maStrings
Definition: xicontent.hxx:69
void ReadSst(XclImpStream &rStrm)
Reads the entire SST record.
Definition: xicontent.cxx:74
This class represents an Excel stream position.
Definition: xistream.hxx:202
This class is used to import record oriented streams.
Definition: xistream.hxx:278
sal_uInt32 ReaduInt32()
Definition: xistream.cxx:685
std::size_t Read(void *pData, std::size_t nBytes)
Reads nBytes bytes to the existing(!) buffer pData.
Definition: xistream.cxx:721
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
Definition: xistream.cxx:798
This class represents an unformatted or formatted string and provides importing from stream.
Definition: xistring.hxx:31
void Read(XclImpStream &rStrm, XclStrFlags nFlags=XclStrFlags::NONE)
Reads a complete string from the passed stream.
Definition: xistring.cxx:42
std::vector< std::unique_ptr< DVItem > > maDVItems
Definition: xicontent.hxx:188
XclImpValidationManager(const XclImpRoot &rRoot)
Definition: xicontent.cxx:745
static void ReadDval(XclImpStream &rStrm)
Reads a DVAL record and sets marks the dropdown arrow control to be ignored.
Definition: xicontent.cxx:750
void ReadDV(XclImpStream &rStrm)
Reads a DV record and inserts validation data into the document.
Definition: xicontent.cxx:765
void ReadWqsettings(XclImpStream &rStrm)
Reads a WEBQRYSETTINGS record and sets refresh rate to the current web query.
Definition: xicontent.cxx:1088
void Apply()
Inserts all web queries into the document.
Definition: xicontent.cxx:1100
void ReadWqtables(XclImpStream &rStrm)
Reads a WEBQRYTABLES record and sets source range list to the current web query.
Definition: xicontent.cxx:1094
void ReadWqstring(XclImpStream &rStrm)
Reads a WQSTRING record and sets URL to the current web query.
Definition: xicontent.cxx:1082
void ReadQsi(XclImpStream &rStrm)
Reads the QSI record and creates a new web query in the buffer.
Definition: xicontent.cxx:1049
XclImpWebQueryList maWQList
Definition: xicontent.hxx:249
void ReadParamqry(XclImpStream &rStrm)
Reads a PARAMQRY record and sets data to the current web query.
Definition: xicontent.cxx:1076
XclImpWebQueryBuffer(const XclImpRoot &rRoot)
Definition: xicontent.cxx:1044
void ReadWqtables(XclImpStream &rStrm)
Reads a WEBQRYTABLES record and sets source range list.
Definition: xicontent.cxx:1007
@ xlWQAllTables
Entire document.
Definition: xicontent.hxx:217
@ xlWQDocument
Not specified.
Definition: xicontent.hxx:216
@ xlWQSpecTables
All tables.
Definition: xicontent.hxx:218
XclImpWebQueryMode meMode
Destination range.
Definition: xicontent.hxx:224
void ReadWqsettings(XclImpStream &rStrm)
Reads a WEBQRYSETTINGS record and sets refresh rate.
Definition: xicontent.cxx:996
OUString maTables
Source document URL.
Definition: xicontent.hxx:222
sal_uInt16 mnRefresh
Current mode of the web query.
Definition: xicontent.hxx:225
XclImpWebQuery(const ScRange &rDestRange)
Definition: xicontent.cxx:965
void ReadWqstring(XclImpStream &rStrm)
Reads a WQSTRING record and sets URL.
Definition: xicontent.cxx:991
void ReadParamqry(XclImpStream &rStrm)
Reads a PARAMQRY record and sets data to the web query.
Definition: xicontent.cxx:972
void Apply(ScDocument &rDoc, const OUString &rFilterName)
Inserts the web query into the document.
Definition: xicontent.cxx:1033
OUString maURL
Definition: xicontent.hxx:221
ScRange maDestRange
List of source range names.
Definition: xicontent.hxx:223
A 2D cell range address list with Excel column and row indexes.
Definition: xladdress.hxx:102
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:291
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:434
ScEditEngineDefaulter & GetEditEngine() const
Returns the edit engine for import/export of rich strings etc.
Definition: xlroot.cxx:366
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
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:286
static void ConvertStringToList(ScTokenArray &rScTokArr, svl::SharedStringPool &rSPool, sal_Unicode cStringSep)
Tries to convert a formula that consists of a single string token to a list of strings.
Definition: xlformula.cxx:921
static const XclGuid maGuidStdLink
Definition: xltools.hxx:95
static OUString GetCondFormatStyleName(SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition)
Returns the style name for a single condition of a conditional formatting.
Definition: xltools.cxx:662
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
void TraceDVType(bool bType)
Definition: xltracer.cxx:126
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
static bool IsFuzzing()
ColorMode meMode
ScConditionMode
Definition: conditio.hxx:60
float u
sal_Int16 nVersion
@ FT_CondFormat
Definition: formel.hxx:52
ReturnType get_flagvalue(Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset)
Returns nSet, if at least one bit of nMask is set in nBitField, otherwise nUnset.
Definition: ftools.hxx:80
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
@ CELLTYPE_EDIT
Definition: global.hxx:276
@ CELLTYPE_STRING
Definition: global.hxx:274
Mode eMode
sal_Int64 n
SvBaseLink * pLink
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
double getLength(const B2DPolygon &rCandidate)
int i
void SvStream & rStrm
const sal_uInt32 VERSION_INFO_1997_FORMAT
const sal_uInt32 VERSION_INFO_2007_FORMAT
const sal_uInt32 VERSION_INFO_2007_FORMAT_SP2
const sal_uInt32 ENCRYPT_HASH_SHA1
const sal_uInt32 ENCRYPTINFO_AES
const sal_uInt32 SALT_LENGTH
const sal_uInt32 ENCRYPTINFO_CRYPTOAPI
const sal_uInt32 ENCRYPT_ALGO_RC4
const sal_uInt32 ENCRYPTINFO_EXTERNAL
bool getFlag(Type nBitField, Type nMask)
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
sal_Int32 nHandle
constexpr TypedWhichId< SfxStringItem > ATTR_HYPERLINK(155)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
sal_uIntPtr sal_uLong
Container for the Excel EnhancedProtection feature.
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
sal_uInt16 mnCol
Definition: xladdress.hxx:31
This struct stores a GUID (class ID) and supports reading, writing and comparison.
Definition: xltools.hxx:60
Extends the XclCellAlign struct for import.
Definition: xistyle.hxx:265
void FillFromCF(sal_uInt16 nAlign, sal_uInt16 nMiscAttrib)
Fills this struct with CF record data.
Definition: xistyle.cxx:803
void FillToItemSet(SfxItemSet &rItemSet, const XclImpFont *pFont, bool bSkipPoolDefs=false) const
Inserts items representing this alignment style into the item set.
Definition: xistyle.cxx:814
Extends the XclCellArea struct for import.
Definition: xistyle.hxx:325
void FillFromCF8(sal_uInt16 nPattern, sal_uInt16 nColor, sal_uInt32 nFlags)
Fills this struct with BIFF8 CF (conditional format) record data.
Definition: xistyle.cxx:1056
void FillToItemSet(SfxItemSet &rItemSet, const XclImpPalette &rPalette, bool bSkipPoolDefs=false) const
Inserts a brush item representing this area style into the item set.
Definition: xistyle.cxx:1077
Extends the XclCellBorder struct for import.
Definition: xistyle.hxx:287
void FillToItemSet(SfxItemSet &rItemSet, const XclImpPalette &rPalette, bool bSkipPoolDefs=false) const
Inserts a box item representing this border style into the item set.
Definition: xistyle.cxx:981
void FillFromCF8(sal_uInt16 nLineStyle, sal_uInt32 nLineColor, sal_uInt32 nFlags)
Fills this struct with BIFF8 CF (conditional format) record data.
Definition: xistyle.cxx:917
Extends the XclCellProt struct for import.
Definition: xistyle.hxx:251
void FillFromXF3(sal_uInt16 nProt)
Fills this struct with BIFF3-BIFF8 XF record data.
Definition: xistyle.cxx:755
void FillToItemSet(SfxItemSet &rItemSet, bool bSkipPoolDefs=false) const
Inserts items representing this protection style into the item set.
Definition: xistyle.cxx:761
::std::vector< ScEnhancedProtection > maEnhancedProtections
Definition: xicontent.hxx:317
DVItem(ScRangeList aRanges, const ScValidationData &rValidData)
Definition: xicontent.cxx:742
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:59
XclAddress maFirst
Definition: xladdress.hxx:60
XclAddress maLast
Definition: xladdress.hxx:61
sal_uInt8 encryptedVerifierHash[comphelper::SHA1_HASH_LENGTH]
sal_uInt8 encryptedVerifier[ENCRYPTED_VERIFIER_LENGTH]
sal_uInt8 salt[SALT_LENGTH]
EncryptionStandardHeader header
EncryptionVerifierRC4 verifier
@ PASSHASH_XL
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
signed char sal_Int8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
ScValidationMode
Definition: validat.hxx:39
@ 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_STOP
Definition: validat.hxx:52
@ SC_VALERR_WARNING
Definition: validat.hxx:53
@ SC_VALERR_INFO
Definition: validat.hxx:54
std::shared_ptr< XclImpDecrypter > XclImpDecrypterRef
Definition: xistream.hxx:40
@ EXC_BIFF5
MS Excel 4.0.
Definition: xlconst.hxx:34
@ EXC_BIFF4
MS Excel 3.0.
Definition: xlconst.hxx:33
@ EXC_BIFF2
Definition: xlconst.hxx:31
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35
@ EXC_BIFF3
MS Excel 2.1.
Definition: xlconst.hxx:32
const sal_uInt32 EXC_DV_COND_NOTBETWEEN
Definition: xlcontent.hxx:126
const sal_uInt32 EXC_HLINK_FRAME
Text mark.
Definition: xlcontent.hxx:148
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_uInt32 EXC_HLINK_DESCR
Absolute path.
Definition: xlcontent.hxx:146
const sal_uInt32 EXC_DV_MODE_ANY
Definition: xlcontent.hxx:114
constexpr OUStringLiteral EXC_WEBQRY_FILTER
UNC path.
Definition: xlcontent.hxx:153
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_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_uInt8 EXC_CF_CMP_NOT_BETWEEN
Definition: xlcontent.hxx:63
const sal_uInt32 EXC_HLINK_BODY
Definition: xlcontent.hxx:144
const sal_uInt32 EXC_CF_BLOCK_NUMFMT
Default flags.
Definition: xlcontent.hxx:81
const sal_uInt32 EXC_DV_MODE_MASK
Definition: xlcontent.hxx:113
const sal_uInt16 EXC_FILEPASS_BIFF5
Definition: xlcontent.hxx:40
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_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_CF_IFMT_USER
Protection block present?
Definition: xlcontent.hxx:87
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_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_BLOCK_ALIGNMENT
Font block present?
Definition: xlcontent.hxx:83
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_uInt16 EXC_FILEPASS_BIFF8
Definition: xlcontent.hxx:41
const sal_uInt32 EXC_DV_MODE_LIST
Definition: xlcontent.hxx:117
const sal_uInt8 EXC_CF_CMP_LESS_EQUAL
Definition: xlcontent.hxx:69
const sal_uInt32 EXC_DV_COND_EQGREATER
Definition: xlcontent.hxx:131
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_MASK
Definition: xlcontent.hxx:135
const sal_uInt32 EXC_DV_MODE_CUSTOM
Definition: xlcontent.hxx:121
const sal_uInt8 EXC_CF_CMP_NOT_EQUAL
Definition: xlcontent.hxx:65
const sal_uInt32 EXC_DVAL_NOOBJ
Definition: xlcontent.hxx:99
const sal_uInt32 EXC_DV_STRINGLIST
Definition: xlcontent.hxx:106
const sal_uInt8 EXC_CF_CMP_EQUAL
Definition: xlcontent.hxx:64
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_CF_BLOCK_PROTECTION
Pattern block present?
Definition: xlcontent.hxx:86
const sal_uInt32 EXC_DV_COND_GREATER
Definition: xlcontent.hxx:129
const sal_uInt32 EXC_HLINK_UNC
Target frame.
Definition: xlcontent.hxx:149
const sal_uInt8 EXC_CF_CMP_BETWEEN
Definition: xlcontent.hxx:62
const sal_uInt32 EXC_HLINK_ABS
Contains file link or URL.
Definition: xlcontent.hxx:145
const ErrCode EXC_ENCR_ERROR_UNSUPP_CRYPT
Definition: xlstream.hxx:32
#define OSL_ENSURE_BIFF(c)
Definition: xltools.hxx:34
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:33