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