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