LibreOffice Module sc (master)  1
excrecds.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 <excrecds.hxx>
21 
22 #include <map>
24 
25 #include <svl/zforlist.hxx>
26 #include <sal/log.hxx>
27 
28 #include <string.h>
29 
30 #include <global.hxx>
31 #include <document.hxx>
32 #include <dbdata.hxx>
33 #include <oox/export/utils.hxx>
34 #include <oox/token/tokens.hxx>
35 #include <queryentry.hxx>
36 #include <queryparam.hxx>
37 #include <sortparam.hxx>
38 #include <userlist.hxx>
39 #include <root.hxx>
40 
41 #include <xeescher.hxx>
42 #include <xelink.hxx>
43 #include <xename.hxx>
44 #include <xlname.hxx>
45 
46 #include <xcl97rec.hxx>
47 #include <tabprotection.hxx>
48 
49 using namespace ::oox;
50 
51 using ::com::sun::star::uno::Sequence;
52 
53 //--------------------------------------------------------- class ExcDummy_00 -
55  0x5c, 0x00, 0x20, 0x00, 0x04, 'C', 'a', 'l', 'c', // WRITEACCESS
56  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
57  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
58  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
59 };
60 const std::size_t ExcDummy_00::nMyLen = sizeof( ExcDummy_00::pMyData );
61 
62 //-------------------------------------------------------- class ExcDummy_04x -
64  0x40, 0x00, 0x02, 0x00, 0x00, 0x00, // BACKUP
65  0x8d, 0x00, 0x02, 0x00, 0x00, 0x00, // HIDEOBJ
66 };
67 const std::size_t ExcDummy_040::nMyLen = sizeof( ExcDummy_040::pMyData );
68 
70  0x0e, 0x00, 0x02, 0x00, 0x01, 0x00, // PRECISION
71  0xda, 0x00, 0x02, 0x00, 0x00, 0x00 // BOOKBOOL
72 };
73 const std::size_t ExcDummy_041::nMyLen = sizeof( ExcDummy_041::pMyData );
74 
75 //-------------------------------------------------------- class ExcDummy_02a -
77  0x0d, 0x00, 0x02, 0x00, 0x01, 0x00, // CALCMODE
78  0x0c, 0x00, 0x02, 0x00, 0x64, 0x00, // CALCCOUNT
79  0x0f, 0x00, 0x02, 0x00, 0x01, 0x00, // REFMODE
80  0x11, 0x00, 0x02, 0x00, 0x00, 0x00, // ITERATION
81  0x10, 0x00, 0x08, 0x00, 0xfc, 0xa9, 0xf1, 0xd2, 0x4d, // DELTA
82  0x62, 0x50, 0x3f,
83  0x5f, 0x00, 0x02, 0x00, 0x01, 0x00 // SAVERECALC
84 };
85 const std::size_t ExcDummy_02a::nMyLen = sizeof( ExcDummy_02a::pMyData );
86 
87 //----------------------------------------------------------- class ExcRecord -
88 
90 {
91  SetRecHeader( GetNum(), GetLen() );
92  XclExpRecord::Save( rStrm );
93 }
94 
96 {
97 }
98 
100 {
101  SaveCont( rStrm );
102 }
103 
105 {
106 }
107 
108 //--------------------------------------------------------- class ExcEmptyRec -
109 
110 void ExcEmptyRec::Save( XclExpStream& /*rStrm*/ )
111 {
112 }
113 
114 sal_uInt16 ExcEmptyRec::GetNum() const
115 {
116  return 0;
117 }
118 
119 std::size_t ExcEmptyRec::GetLen() const
120 {
121  return 0;
122 }
123 
124 //--------------------------------------------------------- class ExcDummyRec -
125 
127 {
128  rStrm.Write( GetData(), GetLen() ); // raw write mode
129 }
130 
131 sal_uInt16 ExcDummyRec::GetNum() const
132 {
133  return 0x0000;
134 }
135 
136 //------------------------------------------------------- class ExcBoolRecord -
137 
139 {
140  rStrm << static_cast<sal_uInt16>(bVal ? 0x0001 : 0x0000);
141 }
142 
143 std::size_t ExcBoolRecord::GetLen() const
144 {
145  return 2;
146 }
147 
148 //--------------------------------------------------------- class ExcBof_Base -
149 
151  : nDocType(0)
152  , nVers(0)
153  , nRupBuild(0x096C) // copied from Excel
154  , nRupYear(0x07C9) // copied from Excel
155 {
156 }
157 
158 //-------------------------------------------------------------- class ExcBof -
159 
161 {
162  nDocType = 0x0010;
163  nVers = 0x0500;
164 }
165 
167 {
168  rStrm << nVers << nDocType << nRupBuild << nRupYear;
169 }
170 
171 sal_uInt16 ExcBof::GetNum() const
172 {
173  return 0x0809;
174 }
175 
176 std::size_t ExcBof::GetLen() const
177 {
178  return 8;
179 }
180 
181 //------------------------------------------------------------- class ExcBofW -
182 
184 {
185  nDocType = 0x0005;
186  nVers = 0x0500;
187 }
188 
190 {
191  rStrm << nVers << nDocType << nRupBuild << nRupYear;
192 }
193 
194 sal_uInt16 ExcBofW::GetNum() const
195 {
196  return 0x0809;
197 }
198 
199 std::size_t ExcBofW::GetLen() const
200 {
201  return 8;
202 }
203 
204 //-------------------------------------------------------------- class ExcEof -
205 
206 sal_uInt16 ExcEof::GetNum() const
207 {
208  return 0x000A;
209 }
210 
211 std::size_t ExcEof::GetLen() const
212 {
213  return 0;
214 }
215 
216 //--------------------------------------------------------- class ExcDummy_00 -
217 
218 std::size_t ExcDummy_00::GetLen() const
219 {
220  return nMyLen;
221 }
222 
224 {
225  return pMyData;
226 }
227 
228 //-------------------------------------------------------- class ExcDummy_04x -
229 
230 std::size_t ExcDummy_040::GetLen() const
231 {
232  return nMyLen;
233 }
234 
236 {
237  return pMyData;
238 }
239 
240 std::size_t ExcDummy_041::GetLen() const
241 {
242  return nMyLen;
243 }
244 
246 {
247  return pMyData;
248 }
249 
250 //------------------------------------------------------------- class Exc1904 -
251 
253 {
254  const Date& rDate = rDoc.GetFormatTable()->GetNullDate();
255  bVal = (rDate == Date( 1, 1, 1904 ));
256  bDateCompatibility = (rDate != Date( 30, 12, 1899 ));
257 }
258 
259 sal_uInt16 Exc1904::GetNum() const
260 {
261  return 0x0022;
262 }
263 
265 {
266  bool bISOIEC = ( rStrm.getVersion() == oox::core::ISOIEC_29500_2008 );
267 
268  if( bISOIEC )
269  {
270  rStrm.WriteAttributes(XML_dateCompatibility, ToPsz(bDateCompatibility));
271  }
272 
273  if( !bISOIEC || bDateCompatibility )
274  {
275  rStrm.WriteAttributes(XML_date1904, ToPsz(bVal));
276  }
277 }
278 
279 //------------------------------------------------------ class ExcBundlesheet -
280 
282  m_nStrPos( STREAM_SEEK_TO_END ),
283  m_nOwnPos( STREAM_SEEK_TO_END ),
284  nGrbit( rRootData.pER->GetTabInfo().IsVisibleTab( nTabNum ) ? 0x0000 : 0x0001 ),
285  nTab( nTabNum )
286 {
287 }
288 
290  m_nStrPos( STREAM_SEEK_TO_END ),
291  m_nOwnPos( STREAM_SEEK_TO_END ),
292  nGrbit( 0x0000 ),
293  nTab( SCTAB_GLOBAL )
294 {
295 }
296 
298 {
299  rStrm.SetSvStreamPos( m_nOwnPos );
300  rStrm.DisableEncryption();
301  rStrm << static_cast<sal_uInt32>(m_nStrPos);
302  rStrm.EnableEncryption();
303 }
304 
305 sal_uInt16 ExcBundlesheetBase::GetNum() const
306 {
307  return 0x0085;
308 }
309 
310 ExcBundlesheet::ExcBundlesheet( const RootData& rRootData, SCTAB _nTab ) :
311  ExcBundlesheetBase( rRootData, _nTab )
312 {
313  OUString sTabName = rRootData.pER->GetTabInfo().GetScTabName( _nTab );
314  OSL_ENSURE( sTabName.getLength() < 256, "ExcBundlesheet::ExcBundlesheet - table name too long" );
315  aName = OUStringToOString(sTabName, rRootData.pER->GetTextEncoding());
316 }
317 
319 {
320  m_nOwnPos = rStrm.GetSvStreamPos();
321  rStrm << sal_uInt32(0x00000000) // dummy (stream position of the sheet)
322  << nGrbit;
323  rStrm.WriteByteString(aName); // 8 bit length, max 255 chars
324 }
325 
326 std::size_t ExcBundlesheet::GetLen() const
327 {
328  return 7 + std::min( aName.getLength(), sal_Int32(255) );
329 }
330 
331 //--------------------------------------------------------- class ExcDummy_02 -
332 
333 std::size_t ExcDummy_02a::GetLen() const
334 {
335  return nMyLen;
336 }
337 
339 {
340  return pMyData;
341 }
342 //--------------------------------------------------------- class ExcDummy_02 -
343 
346 {
347  /* #i31530# set document country as UI country too -
348  needed for correct behaviour of number formats. */
349  mnUICountry = mnDocCountry = static_cast< sal_uInt16 >(
350  ::msfilter::ConvertLanguageToCountry( rRoot.GetDocLanguage() ) );
351 }
352 
354 {
355  rStrm << mnUICountry << mnDocCountry;
356 }
357 
358 // XclExpWsbool ===============================================================
359 
360 XclExpWsbool::XclExpWsbool( bool bFitToPages )
362 {
363  if( bFitToPages )
365 }
366 
367 XclExpXmlSheetPr::XclExpXmlSheetPr( bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager ) :
368  mnScTab(nScTab), mpManager(pManager), mbFitToPage(bFitToPages), maTabColor(rTabColor) {}
369 
371 {
372  sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
373  rWorksheet->startElement( XML_sheetPr,
374  // OOXTODO: XML_syncHorizontal,
375  // OOXTODO: XML_syncVertical,
376  // OOXTODO: XML_syncRef,
377  // OOXTODO: XML_transitionEvaluation,
378  // OOXTODO: XML_transitionEntry,
379  // OOXTODO: XML_published,
380  // OOXTODO: XML_codeName,
381  XML_filterMode, mpManager ? ToPsz(mpManager->HasFilterMode(mnScTab)) : nullptr
382  // OOXTODO: XML_enableFormatConditionsCalculation
383  );
384 
385  // Note : the order of child elements is significant. Don't change the order.
386 
387  // OOXTODO: XML_outlinePr
388 
389  if (maTabColor != COL_AUTO)
390  rWorksheet->singleElement(XML_tabColor, XML_rgb, XclXmlUtils::ToOString(maTabColor));
391 
392  rWorksheet->singleElement(XML_pageSetUpPr,
393  // OOXTODO: XML_autoPageBreaks,
394  XML_fitToPage, ToPsz(mbFitToPage));
395 
396  rWorksheet->endElement( XML_sheetPr );
397 }
398 
399 // XclExpWindowProtection ===============================================================
400 
403 {
404 }
405 
407 {
408  rStrm.WriteAttributes(XML_lockWindows, ToPsz(GetBool()));
409 }
410 
411 // XclExpDocProtection ===============================================================
412 
415 {
416 }
417 
419  XclExpProtection( bValue),
420  mnTab(nTab)
421 {
422 }
423 
425 {
426  ScDocument& rDoc = rStrm.GetRoot().GetDoc();
427  const ScTableProtection* pTabProtect = rDoc.GetTabProtection(mnTab);
428  if ( !pTabProtect )
429  return;
430 
431  const ScOoxPasswordHash& rPH = pTabProtect->getPasswordHash();
432  // Do not write any hash attributes if there is no password.
433  ScOoxPasswordHash aPH;
434  if (rPH.hasPassword())
435  aPH = rPH;
436 
437  Sequence<sal_Int8> aHash = pTabProtect->getPasswordHash(PASSHASH_XL);
438  OString sHash;
439  if (aHash.getLength() >= 2)
440  {
441  sHash = OString::number(
442  ( static_cast<sal_uInt8>(aHash[0]) << 8
443  | static_cast<sal_uInt8>(aHash[1]) ),
444  16 );
445  }
446  sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
447  rWorksheet->singleElement( XML_sheetProtection,
448  XML_algorithmName, aPH.maAlgorithmName.isEmpty() ? nullptr : aPH.maAlgorithmName.toUtf8().getStr(),
449  XML_hashValue, aPH.maHashValue.isEmpty() ? nullptr : aPH.maHashValue.toUtf8().getStr(),
450  XML_saltValue, aPH.maSaltValue.isEmpty() ? nullptr : aPH.maSaltValue.toUtf8().getStr(),
451  XML_spinCount, aPH.mnSpinCount ? OString::number( aPH.mnSpinCount).getStr() : nullptr,
452  XML_sheet, ToPsz( true ),
453  XML_password, sHash.isEmpty()? nullptr : sHash.getStr(),
454  XML_objects, pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS ) ? nullptr : ToPsz( true ),
455  XML_scenarios, pTabProtect->isOptionEnabled( ScTableProtection::SCENARIOS ) ? nullptr : ToPsz( true ),
456  XML_formatCells, pTabProtect->isOptionEnabled( ScTableProtection::FORMAT_CELLS ) ? ToPsz( false ) : nullptr,
457  XML_formatColumns, pTabProtect->isOptionEnabled( ScTableProtection::FORMAT_COLUMNS ) ? ToPsz( false ) : nullptr,
458  XML_formatRows, pTabProtect->isOptionEnabled( ScTableProtection::FORMAT_ROWS ) ? ToPsz( false ) : nullptr,
459  XML_insertColumns, pTabProtect->isOptionEnabled( ScTableProtection::INSERT_COLUMNS ) ? ToPsz( false ) : nullptr,
460  XML_insertRows, pTabProtect->isOptionEnabled( ScTableProtection::INSERT_ROWS ) ? ToPsz( false ) : nullptr,
461  XML_insertHyperlinks, pTabProtect->isOptionEnabled( ScTableProtection::INSERT_HYPERLINKS ) ? ToPsz( false ) : nullptr,
462  XML_deleteColumns, pTabProtect->isOptionEnabled( ScTableProtection::DELETE_COLUMNS ) ? ToPsz( false ) : nullptr,
463  XML_deleteRows, pTabProtect->isOptionEnabled( ScTableProtection::DELETE_ROWS ) ? ToPsz( false ) : nullptr,
464  XML_selectLockedCells, pTabProtect->isOptionEnabled( ScTableProtection::SELECT_LOCKED_CELLS ) ? nullptr : ToPsz( true ),
465  XML_sort, pTabProtect->isOptionEnabled( ScTableProtection::SORT ) ? ToPsz( false ) : nullptr,
466  XML_autoFilter, pTabProtect->isOptionEnabled( ScTableProtection::AUTOFILTER ) ? ToPsz( false ) : nullptr,
467  XML_pivotTables, pTabProtect->isOptionEnabled( ScTableProtection::PIVOT_TABLES ) ? ToPsz( false ) : nullptr,
468  XML_selectUnlockedCells, pTabProtect->isOptionEnabled( ScTableProtection::SELECT_UNLOCKED_CELLS ) ? nullptr : ToPsz( true ) );
469 
470  const ::std::vector<ScEnhancedProtection>& rProts( pTabProtect->getEnhancedProtection());
471  if (rProts.empty())
472  return;
473 
474  rWorksheet->startElement(XML_protectedRanges);
475  for (const auto& rProt : rProts)
476  {
477  SAL_WARN_IF( rProt.maSecurityDescriptorXML.isEmpty() && !rProt.maSecurityDescriptor.empty(),
478  "sc.filter", "XclExpSheetProtection::SaveXml: losing BIFF security descriptor");
479  rWorksheet->singleElement( XML_protectedRange,
480  XML_name, rProt.maTitle.isEmpty() ? nullptr : rProt.maTitle.toUtf8().getStr(),
481  XML_securityDescriptor, rProt.maSecurityDescriptorXML.isEmpty() ? nullptr : rProt.maSecurityDescriptorXML.toUtf8().getStr(),
482  /* XXX 'password' is not part of OOXML, but Excel2013
483  * writes it if loaded from BIFF, in which case
484  * 'algorithmName', 'hashValue', 'saltValue' and
485  * 'spinCount' are absent; so do we if it was present. */
486  XML_password, rProt.mnPasswordVerifier ? OString::number( rProt.mnPasswordVerifier, 16).getStr() : nullptr,
487  XML_algorithmName, rProt.maPasswordHash.maAlgorithmName.isEmpty() ? nullptr : rProt.maPasswordHash.maAlgorithmName.toUtf8().getStr(),
488  XML_hashValue, rProt.maPasswordHash.maHashValue.isEmpty() ? nullptr : rProt.maPasswordHash.maHashValue.toUtf8().getStr(),
489  XML_saltValue, rProt.maPasswordHash.maSaltValue.isEmpty() ? nullptr : rProt.maPasswordHash.maSaltValue.toUtf8().getStr(),
490  XML_spinCount, rProt.maPasswordHash.mnSpinCount ? OString::number( rProt.maPasswordHash.mnSpinCount).getStr() : nullptr,
491  XML_sqref, rProt.maRangeList.is() ? XclXmlUtils::ToOString( rStrm.GetRoot().GetDoc(), *rProt.maRangeList).getStr() : nullptr);
492  }
493  rWorksheet->endElement( XML_protectedRanges);
494 }
495 
496 XclExpPassHash::XclExpPassHash(const Sequence<sal_Int8>& aHash) :
498  mnHash(0x0000)
499 {
500  if (aHash.getLength() >= 2)
501  {
502  mnHash = ((aHash[0] << 8) & 0xFFFF);
503  mnHash |= (aHash[1] & 0xFF);
504  }
505 }
506 
508 {
509 }
510 
512 {
513  rStrm << mnHash;
514 }
515 
518 {
519 }
520 
522  XclExpUInt16Record( EXC_ID_AUTOFILTERINFO, static_cast< sal_uInt16 >( nScCol ) ),
523  maStartPos( rStartPos )
524 {
525 }
526 
529  nOper( EXC_AFOPER_EQUAL ),
530  fVal( 0.0 )
531 {
532 }
533 
535 {
536 }
537 
539 {
540  return pText ? (1 + pText->GetBufferSize()) : 0;
541 }
542 
543 void ExcFilterCondition::SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, const OUString* pT )
544 {
545  nType = nTp;
546  nOper = nOp;
547  fVal = fV;
548  pText.reset( pT ? new XclExpString( *pT, XclStrFlags::EightBitLength ) : nullptr);
549 }
550 
552 {
553  rStrm << nType << nOper;
554  switch( nType )
555  {
556  case EXC_AFTYPE_DOUBLE:
557  rStrm << fVal;
558  break;
559  case EXC_AFTYPE_STRING:
560  OSL_ENSURE( pText, "ExcFilterCondition::Save() -- pText is NULL!" );
561  rStrm << sal_uInt32(0) << static_cast<sal_uInt8>(pText->Len()) << sal_uInt16(0) << sal_uInt8(0);
562  break;
563  case EXC_AFTYPE_BOOLERR:
564  rStrm << sal_uInt8(0) << static_cast<sal_uInt8>((fVal != 0) ? 1 : 0) << sal_uInt32(0) << sal_uInt16(0);
565  break;
566  default:
567  rStrm << sal_uInt32(0) << sal_uInt32(0);
568  }
569 }
570 
571 static const char* lcl_GetOperator( sal_uInt8 nOper )
572 {
573  switch( nOper )
574  {
575  case EXC_AFOPER_EQUAL: return "equal";
576  case EXC_AFOPER_GREATER: return "greaterThan";
577  case EXC_AFOPER_GREATEREQUAL: return "greaterThanOrEqual";
578  case EXC_AFOPER_LESS: return "lessThan";
579  case EXC_AFOPER_LESSEQUAL: return "lessThanOrEqual";
580  case EXC_AFOPER_NOTEQUAL: return "notEqual";
581  case EXC_AFOPER_NONE:
582  default: return "**none**";
583  }
584 }
585 
586 static OString lcl_GetValue( sal_uInt8 nType, double fVal, const XclExpString* pStr )
587 {
588  switch( nType )
589  {
590  case EXC_AFTYPE_STRING: return XclXmlUtils::ToOString( *pStr );
591  case EXC_AFTYPE_DOUBLE: return OString::number( fVal );
592  case EXC_AFTYPE_BOOLERR: return OString::number( ( fVal != 0 ? 1 : 0 ) );
593  default: return OString();
594  }
595 }
596 
598 {
599  if( IsEmpty() )
600  return;
601 
602  rStrm.GetCurrentStream()->singleElement( XML_customFilter,
603  XML_operator, lcl_GetOperator( nOper ),
604  XML_val, lcl_GetValue(nType, fVal, pText.get()) );
605 }
606 
608 {
609  if( nType == EXC_AFTYPE_STRING )
610  {
611  OSL_ENSURE( pText, "ExcFilterCondition::SaveText() -- pText is NULL!" );
612  pText->WriteFlagField( rStrm );
613  pText->WriteBuffer( rStrm );
614  }
615 }
616 
617 XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC ) :
619  XclExpRoot( rRoot ),
620  meType(FilterCondition),
621  nCol( nC ),
622  nFlags( 0 )
623 {
624 }
625 
627  double fVal, const OUString* pText, bool bSimple )
628 {
629  if( !aCond[ 1 ].IsEmpty() )
630  return false;
631 
632  sal_uInt16 nInd = aCond[ 0 ].IsEmpty() ? 0 : 1;
633 
634  if( nInd == 1 )
635  nFlags |= (eConn == SC_OR) ? EXC_AFFLAG_OR : EXC_AFFLAG_AND;
636  if( bSimple )
637  nFlags |= (nInd == 0) ? EXC_AFFLAG_SIMPLE1 : EXC_AFFLAG_SIMPLE2;
638 
639  aCond[ nInd ].SetCondition( nType, nOp, fVal, pText );
640 
641  AddRecSize( aCond[ nInd ].GetTextBytes() );
642 
643  return true;
644 }
645 
647 {
648  return !aCond[0].IsEmpty();
649 }
650 
652 {
653  const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
654 
655  if (rItems.empty())
656  {
657  if (GetOutput() != EXC_OUTPUT_BINARY)
658  {
659  // tdf#123353 XLSX export
660  meType = BlankValue;
661  return false;
662  }
663  // XLS export
664  return true;
665  }
666 
667  if (GetOutput() != EXC_OUTPUT_BINARY && rItems.size() > 1)
668  {
669  AddMultiValueEntry(rEntry);
670  return false;
671  }
672 
673  bool bConflict = false;
674  OUString sText;
675  const ScQueryEntry::Item& rItem = rItems[0];
676  if (!rItem.maString.isEmpty())
677  {
678  sText = rItem.maString.getString();
679  switch( rEntry.eOp )
680  {
681  case SC_CONTAINS:
682  case SC_DOES_NOT_CONTAIN:
683  {
684  sText = "*" + sText + "*";
685  }
686  break;
687  case SC_BEGINS_WITH:
689  sText += "*";
690  break;
691  case SC_ENDS_WITH:
693  sText = "*" + sText;
694  break;
695  default:
696  {
697  //nothing
698  }
699  }
700  }
701 
702  bool bLen = sText.getLength() > 0;
703 
704  // empty/nonempty fields
705  if (rEntry.IsQueryByEmpty())
706  bConflict = !AddCondition( rEntry.eConnect, EXC_AFTYPE_EMPTY, EXC_AFOPER_NONE, 0.0, nullptr, true );
707  else if(rEntry.IsQueryByNonEmpty())
708  bConflict = !AddCondition( rEntry.eConnect, EXC_AFTYPE_NOTEMPTY, EXC_AFOPER_NONE, 0.0, nullptr, true );
709  // other conditions
710  else
711  {
712  double fVal = 0.0;
713  sal_uInt32 nIndex = 0;
714  bool bIsNum = !bLen || GetFormatter().IsNumberFormat( sText, nIndex, fVal );
715  OUString* pText = nullptr;
716  if (!bIsNum)
717  pText = &sText;
718 
719  // top10 flags
720  sal_uInt16 nNewFlags = 0x0000;
721  switch( rEntry.eOp )
722  {
723  case SC_TOPVAL:
724  nNewFlags = (EXC_AFFLAG_TOP10 | EXC_AFFLAG_TOP10TOP);
725  break;
726  case SC_BOTVAL:
727  nNewFlags = EXC_AFFLAG_TOP10;
728  break;
729  case SC_TOPPERC:
731  break;
732  case SC_BOTPERC:
733  nNewFlags = (EXC_AFFLAG_TOP10 | EXC_AFFLAG_TOP10PERC);
734  break;
735  default:;
736  }
737  bool bNewTop10 = ::get_flag( nNewFlags, EXC_AFFLAG_TOP10 );
738 
739  bConflict = HasTop10() && bNewTop10;
740  if( !bConflict )
741  {
742  if( bNewTop10 )
743  {
744  if( fVal < 0 ) fVal = 0;
745  if( fVal >= 501 ) fVal = 500;
746  nFlags |= (nNewFlags | static_cast<sal_uInt16>(fVal) << 7);
747  }
748  // normal condition
749  else
750  {
752  sal_uInt8 nOper = EXC_AFOPER_NONE;
753 
754  switch( rEntry.eOp )
755  {
756  case SC_EQUAL: nOper = EXC_AFOPER_EQUAL; break;
757  case SC_LESS: nOper = EXC_AFOPER_LESS; break;
758  case SC_GREATER: nOper = EXC_AFOPER_GREATER; break;
759  case SC_LESS_EQUAL: nOper = EXC_AFOPER_LESSEQUAL; break;
760  case SC_GREATER_EQUAL: nOper = EXC_AFOPER_GREATEREQUAL; break;
761  case SC_NOT_EQUAL: nOper = EXC_AFOPER_NOTEQUAL; break;
762  case SC_CONTAINS:
763  case SC_BEGINS_WITH:
764  case SC_ENDS_WITH:
765  nOper = EXC_AFOPER_EQUAL; break;
766  case SC_DOES_NOT_CONTAIN:
769  nOper = EXC_AFOPER_NOTEQUAL; break;
770  default:;
771  }
772  bConflict = !AddCondition( rEntry.eConnect, nType, nOper, fVal, pText );
773  }
774  }
775  }
776  return bConflict;
777 }
778 
780 {
781  meType = MultiValue;
782  const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
783  for (const auto& rItem : rItems)
784  maMultiValues.push_back(rItem.maString.getString());
785 }
786 
788 {
789  rStrm << nCol << nFlags;
790  aCond[ 0 ].Save( rStrm );
791  aCond[ 1 ].Save( rStrm );
792  aCond[ 0 ].SaveText( rStrm );
793  aCond[ 1 ].SaveText( rStrm );
794 }
795 
797 {
798  if (meType == FilterCondition && !HasCondition())
799  return;
800 
801  sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
802 
803  rWorksheet->startElement( XML_filterColumn,
804  XML_colId, OString::number(nCol)
805  // OOXTODO: XML_hiddenButton, AutoFilter12 fHideArrow?
806  // OOXTODO: XML_showButton
807  );
808 
809  switch (meType)
810  {
811  case FilterCondition:
812  {
813  if( HasTop10() )
814  {
815  rWorksheet->singleElement( XML_top10,
816  XML_top, ToPsz( get_flag( nFlags, EXC_AFFLAG_TOP10TOP ) ),
817  XML_percent, ToPsz( get_flag( nFlags, EXC_AFFLAG_TOP10PERC ) ),
818  XML_val, OString::number((nFlags >> 7))
819  // OOXTODO: XML_filterVal
820  );
821  }
822 
823  rWorksheet->startElement( XML_customFilters,
824  XML_and, ToPsz((nFlags & EXC_AFFLAG_ANDORMASK) == EXC_AFFLAG_AND) );
825  aCond[ 0 ].SaveXml( rStrm );
826  aCond[ 1 ].SaveXml( rStrm );
827  rWorksheet->endElement( XML_customFilters );
828  // OOXTODO: XLM_colorFilter, XML_dynamicFilter,
829  // XML_extLst, XML_filters, XML_iconFilter, XML_top10
830  }
831  break;
832  case BlankValue:
833  {
834  rWorksheet->singleElement(XML_filters, XML_blank, "1");
835  }
836  break;
837  case MultiValue:
838  {
839  rWorksheet->startElement(XML_filters);
840  for (const auto& rMultiValue : maMultiValues)
841  {
842  OString aStr = OUStringToOString(rMultiValue, RTL_TEXTENCODING_UTF8);
843  const char* pz = aStr.getStr();
844  rWorksheet->singleElement(XML_filter, XML_val, pz);
845  }
846  rWorksheet->endElement(XML_filters);
847  }
848  break;
849  }
850  rWorksheet->endElement( XML_filterColumn );
851 }
852 
853 ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const ScDBData* pDefinedData ) :
854  XclExpRoot( rRoot ),
855  mbAutoFilter (false)
856 {
857  XclExpNameManager& rNameMgr = GetNameManager();
858 
859  bool bFound = false;
860  bool bAdvanced = false;
861  const ScDBData* pData = (pDefinedData ? pDefinedData : rRoot.GetDoc().GetAnonymousDBData(nTab));
862  ScRange aAdvRange;
863  if (pData)
864  {
865  bAdvanced = pData->GetAdvancedQuerySource( aAdvRange );
866  bFound = (pData->HasQueryParam() || pData->HasAutoFilter() || bAdvanced);
867  }
868  if( !bFound )
869  return;
870 
871  ScQueryParam aParam;
872  pData->GetQueryParam( aParam );
873 
874  ScRange aRange( aParam.nCol1, aParam.nRow1, aParam.nTab,
875  aParam.nCol2, aParam.nRow2, aParam.nTab );
876  SCCOL nColCnt = aParam.nCol2 - aParam.nCol1 + 1;
877 
878  maRef = aRange;
879 
880  // #i2394# built-in defined names must be sorted by containing sheet name
881  if (!pDefinedData)
882  rNameMgr.InsertBuiltInName( EXC_BUILTIN_FILTERDATABASE, aRange );
883 
884  // advanced filter
885  if( bAdvanced )
886  {
887  // filter criteria, excel allows only same table
888  if( !pDefinedData && aAdvRange.aStart.Tab() == nTab )
889  rNameMgr.InsertBuiltInName( EXC_BUILTIN_CRITERIA, aAdvRange );
890 
891  // filter destination range, excel allows only same table
892  if( !aParam.bInplace )
893  {
894  ScRange aDestRange( aParam.nDestCol, aParam.nDestRow, aParam.nDestTab );
895  aDestRange.aEnd.IncCol( nColCnt - 1 );
896  if( !pDefinedData && aDestRange.aStart.Tab() == nTab )
897  rNameMgr.InsertBuiltInName( EXC_BUILTIN_EXTRACT, aDestRange );
898  }
899 
901  }
902  // AutoFilter
903  else
904  {
905  bool bConflict = false;
906  bool bContLoop = true;
907  bool bHasOr = false;
908  SCCOLROW nFirstField = aParam.GetEntry( 0 ).nField;
909 
910  // create AUTOFILTER records for filtered columns
911  for( SCSIZE nEntry = 0; !bConflict && bContLoop && (nEntry < aParam.GetEntryCount()); nEntry++ )
912  {
913  const ScQueryEntry& rEntry = aParam.GetEntry( nEntry );
914 
915  bContLoop = rEntry.bDoQuery;
916  if( bContLoop )
917  {
918  XclExpAutofilter* pFilter = GetByCol( static_cast<SCCOL>(rEntry.nField) - aRange.aStart.Col() );
919 
920  if( nEntry > 0 )
921  bHasOr |= (rEntry.eConnect == SC_OR);
922 
923  bConflict = (nEntry > 1) && bHasOr;
924  if( !bConflict )
925  bConflict = (nEntry == 1) && (rEntry.eConnect == SC_OR) &&
926  (nFirstField != rEntry.nField);
927  if( !bConflict )
928  bConflict = pFilter->AddEntry( rEntry );
929  }
930  }
931 
932  // additional tests for conflicts
933  for( size_t nPos = 0, nSize = maFilterList.GetSize(); !bConflict && (nPos < nSize); ++nPos )
934  {
936  bConflict = xFilter->HasCondition() && xFilter->HasTop10();
937  }
938 
939  if( bConflict )
941 
942  if( !maFilterList.IsEmpty() )
944  m_pFilterInfo = new XclExpAutofilterinfo( aRange.aStart, nColCnt );
945 
946  if (maFilterList.IsEmpty () && !bConflict)
947  mbAutoFilter = true;
948 
949  // get sort criteria
950  {
951  ScSortParam aSortParam;
952  pData->GetSortParam( aSortParam );
953 
955  if (aSortParam.bUserDef && pList && pList->size() > aSortParam.nUserIndex)
956  {
957  // get sorted area without headers
958  maSortRef = ScRange(
959  aParam.nCol1, aParam.nRow1 + (aSortParam.bHasHeader? 1 : 0), aParam.nTab,
960  aParam.nCol2, aParam.nRow2, aParam.nTab );
961 
962  // get sorted columns with custom lists
963  const ScUserListData& rData = (*pList)[aSortParam.nUserIndex];
964 
965  // get column index and sorting direction
966  SCCOLROW nField = 0;
967  bool bSortAscending=true;
968  for (const auto & rKey : aSortParam.maKeyState)
969  {
970  if (rKey.bDoSort)
971  {
972  nField = rKey.nField;
973  bSortAscending = rKey.bAscending;
974  break;
975  }
976  }
977 
978  // remember sort criteria
979  const ScRange aSortedColumn(
980  nField, aParam.nRow1 + (aSortParam.bHasHeader? 1 : 0), aParam.nTab,
981  nField, aParam.nRow2, aParam.nTab );
982  const OUString aItemList = rData.GetString();
983 
984  maSortCustomList.emplace_back(aSortedColumn, aItemList, !bSortAscending);
985  }
986  }
987  }
988 }
989 
991 {
992 }
993 
995 {
996  XclExpAutofilterRef xFilter;
997  for( size_t nPos = 0, nSize = maFilterList.GetSize(); nPos < nSize; ++nPos )
998  {
999  xFilter = maFilterList.GetRecord( nPos );
1000  if( xFilter->GetCol() == static_cast<sal_uInt16>(nCol) )
1001  return xFilter.get();
1002  }
1003  xFilter = new XclExpAutofilter( GetRoot(), static_cast<sal_uInt16>(nCol) );
1004  maFilterList.AppendRecord( xFilter );
1005  return xFilter.get();
1006 }
1007 
1009 {
1010  for( size_t nPos = 0, nSize = maFilterList.GetSize(); nPos < nSize; ++nPos )
1011  if( maFilterList.GetRecord( nPos )->GetCol() == static_cast<sal_uInt16>(nCol) )
1012  return true;
1013  return false;
1014 }
1015 
1017 {
1018  if( m_pFilterInfo )
1019  {
1020  ScAddress aAddr( m_pFilterInfo->GetStartPos() );
1021  for( SCCOL nObj = 0, nCount = m_pFilterInfo->GetColCount(); nObj < nCount; nObj++ )
1022  {
1023  std::unique_ptr<XclObj> pObjRec(new XclObjDropDown( GetObjectManager(), aAddr, IsFiltered( nObj ) ));
1024  GetObjectManager().AddObj( std::move(pObjRec) );
1025  aAddr.IncCol();
1026  }
1027  }
1028 }
1029 
1031 {
1032  if( m_pFilterMode )
1033  m_pFilterMode->Save( rStrm );
1034  if( m_pFilterInfo )
1035  m_pFilterInfo->Save( rStrm );
1036  maFilterList.Save( rStrm );
1037 }
1038 
1040 {
1041  if( maFilterList.IsEmpty() && !mbAutoFilter )
1042  return;
1043 
1044  sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1045  rWorksheet->startElement(XML_autoFilter, XML_ref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), maRef));
1046  // OOXTODO: XML_extLst, XML_sortState
1047  if( !maFilterList.IsEmpty() )
1048  maFilterList.SaveXml( rStrm );
1049 
1050  if (!maSortCustomList.empty())
1051  {
1052  rWorksheet->startElement(XML_sortState, XML_ref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), maSortRef));
1053 
1054  for (const auto & rSortCriteria : maSortCustomList)
1055  {
1056  if (std::get<2>(rSortCriteria))
1057  rWorksheet->singleElement(XML_sortCondition,
1058  XML_ref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(),
1059  std::get<0>(rSortCriteria)),
1060  XML_descending, "1",
1061  XML_customList, std::get<1>(rSortCriteria).toUtf8().getStr());
1062  else
1063  rWorksheet->singleElement(XML_sortCondition,
1064  XML_ref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(),
1065  std::get<0>(rSortCriteria)),
1066  XML_customList, std::get<1>(rSortCriteria).toUtf8().getStr());
1067  }
1068 
1069  rWorksheet->endElement(XML_sortState);
1070  }
1071 
1072  rWorksheet->endElement( XML_autoFilter );
1073 }
1074 
1076 {
1077  return m_pFilterMode != nullptr;
1078 }
1079 
1081  XclExpRoot( rRoot )
1082 {
1083 }
1084 
1086 {
1087  maFilterMap[ nScTab ] = new ExcAutoFilterRecs( GetRoot(), nScTab, nullptr );
1088 }
1089 
1091 {
1092  XclExpTabFilterRef xRec;
1093  XclExpTabFilterMap::iterator aIt = maFilterMap.find( nScTab );
1094  if( aIt != maFilterMap.end() )
1095  {
1096  xRec = aIt->second;
1097  xRec->AddObjRecs();
1098  }
1099  return xRec;
1100 }
1101 
1103 {
1104  XclExpTabFilterMap::iterator aIt = maFilterMap.find( nScTab );
1105  if( aIt != maFilterMap.end() )
1106  {
1107  return aIt->second->HasFilterMode();
1108  }
1109  return false;
1110 }
1111 
1112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetValue(const Type &rValue)
Sets a new record value.
Definition: xerecord.hxx:211
sal_uInt16 nRupBuild
Definition: excrecds.hxx:103
::std::vector< ScSortKeyState > maKeyState
Definition: sortparam.hxx:61
void WriteAttributes(sal_Int32 nAttribute, Str &&value, Args &&...rest)
Definition: xestream.hxx:299
XclExpWindowProtection(bool bValue)
Definition: excrecds.cxx:401
sal_uInt16 nUserIndex
Definition: sortparam.hxx:47
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:43
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
Definition: xerecord.hxx:376
virtual void SaveCont(XclExpStream &rStrm)
Definition: excrecds.cxx:95
Collection of user-defined sort lists.
Definition: userlist.hxx:66
std::size_t Write(const void *pData, std::size_t nBytes)
Writes nBytes bytes from memory.
Definition: xestream.cxx:215
bool HasAutoFilter() const
Definition: dbdata.hxx:204
static OString ToOString(const Color &rColor)
Definition: xestream.cxx:698
const sal_Unicode EXC_BUILTIN_CRITERIA
Definition: xlname.hxx:53
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:146
sal_Int32 nIndex
SC_DLLPUBLIC bool HasQueryParam() const
Definition: dbdata.cxx:510
bool AddEntry(const ScQueryEntry &rEntry)
Definition: excrecds.cxx:651
OUString getString() const
const sal_uInt8 EXC_AFOPER_GREATER
Definition: excdefs.hxx:52
ScAddress aStart
Definition: address.hxx:500
sal_uInt16 nGrbit
Definition: excrecds.hxx:240
bool IsFiltered(SCCOL nCol)
Definition: excrecds.cxx:1008
ExcBof()
Definition: excrecds.cxx:160
LanguageType GetDocLanguage() const
Returns the document language.
Definition: xlroot.hxx:150
XclExpXmlSheetPr(bool bFitToPages, SCTAB nScTab, const Color &rTabColor, XclExpFilterManager *pManager)
Definition: excrecds.cxx:367
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:223
virtual const sal_uInt8 * GetData() const =0
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:203
const sal_Unicode EXC_BUILTIN_EXTRACT
Definition: xlname.hxx:51
const XclExpRoot & GetRoot() const
Returns the filter root data.
Definition: xestream.hxx:290
const sal_uInt8 EXC_AFOPER_LESSEQUAL
Definition: excdefs.hxx:51
const sal_uInt16 EXC_ID_COUNTRY
Definition: xlconst.hxx:200
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
Definition: document.cxx:307
void InitTabFilter(SCTAB nScTab)
Creates the filter records for the specified sheet.
Definition: excrecds.cxx:1085
const sal_uInt8 EXC_AFTYPE_NOTEMPTY
Definition: excdefs.hxx:45
This class is used to export Excel record streams.
Definition: xestream.hxx:71
const ::std::vector< ScEnhancedProtection > & getEnhancedProtection() const
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xerecord.hxx:383
std::unique_ptr< XclExpString > pText
Definition: excrecds.hxx:344
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:153
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:406
std::unique_ptr< ContentProperties > pData
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:1039
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:171
SC_DLLPUBLIC void GetSortParam(ScSortParam &rSortParam) const
Definition: dbdata.cxx:387
void AppendRecord(RecType *pRec)
Appends a record to the list.
Definition: xerecord.hxx:349
sheet protection state container
XclExpWsbool(bool bFitToPages)
Definition: excrecds.cxx:360
const Type & GetValue() const
Returns the value of the record.
Definition: xerecord.hxx:209
bool AddCondition(ScQueryConnect eConn, sal_uInt8 nType, sal_uInt8 nOp, double fVal, const OUString *pText, bool bSimple=false)
Definition: excrecds.cxx:626
OUString maSaltValue
base64 encoded hash value
static const std::size_t nMyLen
Definition: excrecds.hxx:204
OoxmlVersion getVersion() const
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:104
QueryItemsType & GetQueryItems()
Definition: queryentry.hxx:65
OUString GetScTabName(SCTAB nScTab) const
Returns the Calc name of the specified sheet.
Definition: xelink.cxx:805
XclExpPassHash(const css::uno::Sequence< sal_Int8 > &aHash)
Definition: excrecds.cxx:496
#define STREAM_SEEK_TO_END
ExcFilterCondition aCond[2]
Definition: excrecds.hxx:368
const ContentProperties & rData
const sal_uInt16 EXC_ID_FILTERMODE
Definition: xlconst.hxx:203
sal_uInt16 GetCol() const
Definition: excrecds.hxx:380
size_t size() const
Definition: userlist.cxx:345
SCCOLROW nField
Definition: queryentry.hxx:51
const sal_uInt8 EXC_AFOPER_NOTEQUAL
Definition: excdefs.hxx:53
static const std::size_t nMyLen
Definition: excrecds.hxx:154
ScAddress aEnd
Definition: address.hxx:501
void SetCondition(sal_uInt8 nTp, sal_uInt8 nOp, double fV, const OUString *pT)
Definition: excrecds.cxx:543
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:213
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:338
const sal_uInt16 EXC_AFFLAG_TOP10TOP
Definition: excdefs.hxx:34
bool IsQueryByEmpty() const
Definition: queryentry.cxx:84
rtl::Reference< XclExpFiltermode > m_pFilterMode
Definition: excrecds.hxx:416
const sal_uInt16 EXC_AFFLAG_SIMPLE2
Definition: excdefs.hxx:32
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:189
const sal_uInt8 EXC_AFTYPE_DOUBLE
Definition: excdefs.hxx:40
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:276
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:313
sal_uInt16 nRupYear
Definition: excrecds.hxx:104
std::vector< OUString > maMultiValues
Definition: excrecds.hxx:369
const sal_uInt8 EXC_AFTYPE_STRING
Definition: excdefs.hxx:41
void AddMultiValueEntry(const ScQueryEntry &rEntry)
Definition: excrecds.cxx:779
char const sHash[]
void SaveXml(XclExpXmlStream &rStrm)
Definition: excrecds.cxx:597
OUString maHashValue
"SHA-512", ...
virtual ~ExcAutoFilterRecs() override
Definition: excrecds.cxx:990
bool bUserDef
Definition: sortparam.hxx:54
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: excrecds.cxx:787
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:272
static const std::size_t nMyLen
Definition: excrecds.hxx:273
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
Access to global data from other classes.
Definition: xeroot.hxx:113
Stores individual user-defined sort list.
Definition: userlist.hxx:33
virtual void Save(XclExpStream &rStrm) override
Overwrite this method to do any operation while saving the record.
Definition: excrecds.cxx:1030
bool isOptionEnabled(Option eOption) const
static const char * lcl_GetOperator(sal_uInt8 nOper)
Definition: excrecds.cxx:571
OString aName
Definition: excrecds.hxx:257
void Save(XclExpStream &rStrm)
Definition: excrecds.cxx:551
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
sal_uInt16 nDocType
Definition: excrecds.hxx:101
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:264
OUString maAlgorithmName
XclExpAutofilter(const XclExpRoot &rRoot, sal_uInt16 nC)
Definition: excrecds.cxx:617
int nCount
SC_DLLPUBLIC SCSIZE GetEntryCount() const
Definition: queryparam.cxx:119
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
Definition: queryparam.cxx:124
const sal_uInt8 EXC_AFOPER_EQUAL
Definition: excdefs.hxx:50
OOXML password definitions: algorithmName, hashValue, saltValue, spinCount.
XclExpAutofilterinfo(const ScAddress &rStartPos, SCCOL nScCol)
Definition: excrecds.cxx:521
SCTAB Tab() const
Definition: address.hxx:271
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:218
const sal_uInt16 EXC_AFFLAG_AND
Definition: excdefs.hxx:28
const sal_uInt16 EXC_AFFLAG_TOP10
Definition: excdefs.hxx:33
sax_fastparser::FSHelperPtr & GetCurrentStream()
Definition: xestream.cxx:910
const SCTAB SCTAB_GLOBAL
An invalid Calc sheet index, for common use.
Definition: xlconst.hxx:75
XclExpTabFilterMap maFilterMap
Definition: excrecds.hxx:448
virtual std::size_t GetLen() const =0
bool HasFilterMode(SCTAB nScTab)
Returns whether or not FilterMode is present.
Definition: excrecds.cxx:1102
virtual ~XclExpPassHash() override
Definition: excrecds.cxx:507
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:240
bool bDateCompatibility
Definition: excrecds.hxx:230
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:194
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:245
const sal_uInt8 EXC_AFOPER_NONE
Definition: excdefs.hxx:48
const sal_uInt16 EXC_ID_AUTOFILTERINFO
Definition: xlconst.hxx:209
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:143
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:796
std::vector< std::tuple< ScRange, OUString, bool > > maSortCustomList
Definition: excrecds.hxx:422
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:110
A record with a single value of type Type.
Definition: xerecord.hxx:199
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:142
XclExpProtection(bool bValue)
Definition: excrecds.cxx:413
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:318
sal_uInt64 GetSvStreamPos() const
Returns the absolute position of the system stream.
Definition: xestream.hxx:139
Exc1904(const ScDocument &rDoc)
Definition: excrecds.cxx:252
const sal_uInt16 EXC_ID_PROTECT
Definition: xlconst.hxx:176
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:138
virtual void WriteBody(XclExpStream &rStrm) override
The document country ID.
Definition: excrecds.cxx:353
sal_uInt16 nFlags
Definition: excrecds.hxx:367
bool isEmpty() const
bool IsQueryByNonEmpty() const
Definition: queryentry.cxx:106
Manager that stores all internal defined names (NAME records) of the document.
Definition: xename.hxx:32
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:304
sal_uInt16 nVers
Definition: excrecds.hxx:102
sal_Int16 SCCOL
Definition: types.hxx:22
bool HasCondition() const
Definition: excrecds.cxx:646
sal_uInt16 mnHash
Definition: excrecds.hxx:194
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:326
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
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:73
const OUString & GetString() const
Definition: userlist.hxx:54
static SC_DLLPUBLIC ScUserList * GetUserList()
Definition: global.cxx:274
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record.
Definition: excrecds.cxx:99
XclExpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
Definition: xeroot.cxx:141
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
Definition: xeroot.cxx:75
std::shared_ptr< FastSerializerHelper > FSHelperPtr
void SaveText(XclExpStream &rStrm)
Definition: excrecds.cxx:607
const sal_uInt16 EXC_AFFLAG_ANDORMASK
Definition: excdefs.hxx:30
void WriteByteString(const OString &rString)
Writes string length field and OString buffer.
Definition: xestream.cxx:328
const sal_uInt16 EXC_ID_WINDOWPROTECT
Definition: xlconst.hxx:182
svl::SharedString maString
Definition: queryentry.hxx:41
bool HasFilterMode() const
Definition: excrecds.cxx:1075
XclExpRoot * pER
Definition: root.hxx:66
bool GetBool() const
Returns the Boolean value of the record.
Definition: xerecord.hxx:264
const sal_uInt8 EXC_AFOPER_LESS
Definition: excdefs.hxx:49
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:424
sal_uInt64 m_nStrPos
Definition: excrecds.hxx:238
SCCOL Col() const
Definition: address.hxx:267
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xeroot.hxx:119
bool HasTop10() const
Definition: excrecds.hxx:381
sal_uInt16 InsertBuiltInName(sal_Unicode cBuiltIn, const ScRange &rRange)
Inserts a new built-in defined name, referring to the passed sheet range.
Definition: xename.cxx:807
void SetSvStreamPos(sal_uInt64 nPos)
Sets position of system stream (only allowed outside of records).
Definition: xestream.cxx:368
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:131
XclExpCountry(const XclExpRoot &rRoot)
Definition: excrecds.cxx:344
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:119
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:176
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:333
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:89
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Definition: xerecord.hxx:334
bool IsEmpty() const
Definition: excrecds.hxx:351
const sal_uInt16 EXC_ID_WSBOOL
Definition: xlconst.hxx:188
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:166
const sal_uInt16 EXC_AFFLAG_SIMPLE1
Definition: excdefs.hxx:31
void SetRecHeader(sal_uInt16 nRecId, std::size_t nRecSize)
Sets record ID and size with one call.
Definition: xerecord.cxx:140
static OString lcl_GetValue(sal_uInt8 nType, double fVal, const XclExpString *pStr)
Definition: excrecds.cxx:586
const sal_uInt16 EXC_AFFLAG_OR
Definition: excdefs.hxx:29
static const std::size_t nMyLen
Definition: excrecds.hxx:214
const sal_uInt16 EXC_WSBOOL_DEFAULTFLAGS
Definition: xlconst.hxx:194
void UpdateStreamPos(XclExpStream &rStrm)
Definition: excrecds.cxx:297
bool bHasHeader
Definition: sortparam.hxx:48
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:230
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:114
#define SAL_WARN_IF(condition, area, stream)
const sal_uInt8 EXC_AFTYPE_EMPTY
Definition: excdefs.hxx:44
unsigned char sal_uInt8
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:126
A record without body.
Definition: xerecord.hxx:184
bool hasPassword() const
void RemoveAllRecords()
Removes all records from the list.
Definition: xerecord.hxx:373
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:211
Sheet filter manager.
Definition: excrecds.hxx:426
Always use UCS-2 characters (default: try to compress). BIFF8 only.
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:199
XclExpAutofilterList maFilterList
Definition: excrecds.hxx:415
std::size_t GetTextBytes() const
Definition: excrecds.cxx:538
const sal_uInt8 EXC_AFTYPE_BOOLERR
Definition: excdefs.hxx:42
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
XclExpObjectManager & GetObjectManager() const
Returns the drawing object manager.
Definition: xeroot.cxx:147
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: excrecds.cxx:511
SC_DLLPUBLIC void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: dbdata.cxx:410
XclExpFilterManager(const XclExpRoot &rRoot)
Definition: excrecds.cxx:1080
void DisableEncryption()
Definition: xestream.cxx:363
ScQueryConnect eConnect
Definition: queryentry.hxx:53
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:305
size_t GetSize() const
Definition: xerecord.hxx:328
SC_DLLPUBLIC ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1899
const sal_uInt16 EXC_ID_AUTOFILTER
Definition: xlconst.hxx:212
ExcBundlesheet(const RootData &rRootData, SCTAB nTab)
Definition: excrecds.cxx:310
const sal_uInt8 EXC_AFOPER_GREATEREQUAL
Definition: excdefs.hxx:54
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:370
std::vector< Item > QueryItemsType
Definition: queryentry.hxx:48
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:235
XclExpRecordRef CreateRecord(SCTAB nScTab)
Returns a record object containing all filter records for the specified sheet.
Definition: excrecds.cxx:1090
SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange &rSource) const
Definition: dbdata.cxx:443
void EnableEncryption(bool bEnable=true)
Definition: xestream.cxx:358
XclExpAutofilter * GetByCol(SCCOL nCol)
Definition: excrecds.cxx:994
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:206
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:259
XclExpSheetProtection(bool bValue, SCTAB nTab)
Definition: excrecds.cxx:418
sal_uInt32 mnSpinCount
base64 encoded salt value
sal_uInt16 mnUICountry
Definition: excrecds.hxx:286
const Date & GetNullDate() const
sal_uInt16 mnDocCountry
The UI country ID.
Definition: excrecds.hxx:287
bool IsEmpty() const
Definition: xerecord.hxx:327
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: xerecord.cxx:150
ScQueryOp eOp
Definition: queryentry.hxx:52
const sal_uInt16 EXC_WSBOOL_FITTOPAGE
Definition: xlconst.hxx:192
const sal_uInt16 EXC_ID_PASSWORD
Definition: xlconst.hxx:179
RedlineType meType
ExcAutoFilterRecs(const XclExpRoot &rRoot, SCTAB nTab, const ScDBData *pDefinedData)
Definition: excrecds.cxx:853
FilterType meType
Definition: excrecds.hxx:365
aStr
sal_uInt64 m_nOwnPos
Definition: excrecds.hxx:239
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:33
virtual sal_uInt16 GetNum() const =0
sal_uInt16 AddObj(std::unique_ptr< XclObj > pObjRec)
Definition: xeescher.cxx:1843
const sal_Unicode EXC_BUILTIN_FILTERDATABASE
Definition: xlname.hxx:61
Base class for single records with any content.
Definition: xerecord.hxx:143
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
Record which contains a Boolean value.
Definition: xerecord.hxx:255
rtl::Reference< XclExpAutofilterinfo > m_pFilterInfo
Definition: excrecds.hxx:417
sal_uInt16 nCol
Definition: excrecds.hxx:366
virtual css::uno::Sequence< sal_Int8 > getPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED) const override
ScQueryConnect
Definition: global.hxx:838
void AddRecSize(std::size_t nRecSize)
Adds a size value to the record size prediction.
Definition: xerecord.hxx:166
const sal_uInt8 EXC_AFTYPE_NOTUSED
Definition: excdefs.hxx:38
XclExpFilterManager * mpManager
Definition: excrecds.hxx:314
const sal_uInt16 EXC_AFFLAG_TOP10PERC
Definition: excdefs.hxx:35