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