32#include <document.hxx>
35#include <oox/token/tokens.hxx>
55using ::com::sun::star::uno::Sequence;
59 0x5c, 0x00, 0x20, 0x00, 0x04,
'C',
'a',
'l',
'c',
60 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
61 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
62 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
68 0x40, 0x00, 0x02, 0x00, 0x00, 0x00,
69 0x8d, 0x00, 0x02, 0x00, 0x00, 0x00,
74 0x0e, 0x00, 0x02, 0x00, 0x01, 0x00,
75 0xda, 0x00, 0x02, 0x00, 0x00, 0x00
81 0x0d, 0x00, 0x02, 0x00, 0x01, 0x00,
82 0x0c, 0x00, 0x02, 0x00, 0x64, 0x00,
83 0x0f, 0x00, 0x02, 0x00, 0x01, 0x00,
84 0x11, 0x00, 0x02, 0x00, 0x00, 0x00,
85 0x10, 0x00, 0x08, 0x00, 0xfc, 0xa9, 0xf1, 0xd2, 0x4d,
87 0x5f, 0x00, 0x02, 0x00, 0x01, 0x00
144 rStrm << static_cast<sal_uInt16>(
bVal ? 0x0001 : 0x0000);
259 bVal = (rDate ==
Date( 1, 1, 1904 ));
279 rStrm.WriteAttributes(XML_date1904, ToPsz(
bVal));
288 nGrbit( rRootData.pER->GetTabInfo().IsVisibleTab( nTabNum ) ? 0x0000 : 0x0001 ),
304 rStrm.DisableEncryption();
305 rStrm << static_cast<sal_uInt32>(
m_nStrPos);
306 rStrm.EnableEncryption();
318 OSL_ENSURE( sTabName.getLength() < 256,
"ExcBundlesheet::ExcBundlesheet - table name too long" );
325 rStrm << sal_uInt32(0x00000000)
332 return 7 + std::min(
aName.getLength(), sal_Int32(255) );
372 mnScTab(nScTab), mpManager(pManager), mbFitToPage(bFitToPages), maTabColor(rTabColor) {}
377 rWorksheet->startElement( XML_sheetPr,
396 rWorksheet->singleElement(XML_pageSetUpPr,
400 rWorksheet->endElement( XML_sheetPr );
412 rStrm.WriteAttributes(XML_lockWindows, ToPsz(
GetBool()));
442 std::optional<OString>
sHash;
443 if (aHash.getLength() >= 2)
445 sHash = OString::number(
451 rWorksheet->singleElement( XML_sheetProtection,
456 XML_sheet, ToPsz(
true ),
478 rWorksheet->startElement(XML_protectedRanges);
479 for (
const auto& rProt : rProts)
481 SAL_WARN_IF( rProt.maSecurityDescriptorXML.isEmpty() && !rProt.maSecurityDescriptor.empty(),
482 "sc.filter",
"XclExpSheetProtection::SaveXml: losing BIFF security descriptor");
483 rWorksheet->singleElement( XML_protectedRange,
485 XML_securityDescriptor,
sax_fastparser::UseIf(rProt.maSecurityDescriptorXML, !rProt.maSecurityDescriptorXML.isEmpty()),
490 XML_password,
sax_fastparser::UseIf(OString::number(rProt.mnPasswordVerifier, 16), rProt.mnPasswordVerifier != 0),
491 XML_algorithmName,
sax_fastparser::UseIf(rProt.maPasswordHash.maAlgorithmName, !rProt.maPasswordHash.maAlgorithmName.isEmpty()),
492 XML_hashValue,
sax_fastparser::UseIf(rProt.maPasswordHash.maHashValue, !rProt.maPasswordHash.maHashValue.isEmpty()),
493 XML_saltValue,
sax_fastparser::UseIf(rProt.maPasswordHash.maSaltValue, !rProt.maPasswordHash.maSaltValue.isEmpty()),
494 XML_spinCount,
sax_fastparser::UseIf(OString::number(rProt.maPasswordHash.mnSpinCount), rProt.maPasswordHash.mnSpinCount != 0),
497 rWorksheet->endElement( XML_protectedRanges);
504 if (aHash.getLength() >= 2)
506 mnHash = ((aHash[0] << 8) & 0xFFFF);
507 mnHash |= (aHash[1] & 0xFF);
527 maStartPos( rStartPos )
543 return pText ? (1 +
pText->GetBufferSize()) : 0;
558 OSL_ENSURE(
pText,
"ExcFilterCondition::Save() -- pText is NULL!");
559 rStrm << sal_uInt32(0) << static_cast<sal_uInt8>(
pText->Len()) << sal_uInt16(0) <<
sal_uInt8(0);
562 rStrm << sal_uInt32(0) << sal_uInt32(0);
576 default:
return "**none**";
593 rStrm.GetCurrentStream()->singleElement( XML_customFilter,
602 OSL_ENSURE(
pText,
"ExcFilterCondition::SaveText() -- pText is NULL!" );
613 bIsButtonHidden( false ),
615 bHasBlankValue( false )
620 const OUString* pText,
bool bSimple )
622 if( !
aCond[ 1 ].IsEmpty() )
666 bool bConflict =
false;
677 sText =
"*" + sText +
"*";
711 sal_uInt16 nNewFlags = 0x0000;
730 bConflict =
HasTop10() && bNewTop10;
739 if (fVal < 0) fVal = 0;
740 if (fVal >= 501) fVal = 500;
742 nFlags |= (nNewFlags |
static_cast<sal_uInt16
>(fVal) << 7);
784 for (
const auto& rItem : rItems)
786 if( rItem.maString.isEmpty() )
797 for (
const auto& rItem : rItems)
803 if (
GetDxfs().GetDxfByColor(rItem.maColor) == -1)
824 std::optional<OString> sHiddenButtonValue;
826 sHiddenButtonValue =
"1";
828 rWorksheet->startElement( XML_filterColumn,
829 XML_colId, OString::number(
nCol),
830 XML_hiddenButton, sHiddenButtonValue
839 rWorksheet->singleElement( XML_top10,
842 XML_val, OString::number(
nFlags >> 7)
848 rWorksheet->startElement(XML_customFilters, XML_and,
852 rWorksheet->endElement(XML_customFilters);
866 pAttrList->add(XML_cellColor, OString::number(1));
870 pAttrList->add(XML_cellColor, OString::number(0));
872 pAttrList->add(XML_dxfId, OString::number(
GetDxfs().GetDxfByColor(
color)));
873 rWorksheet->singleElement(XML_colorFilter, pAttrList);
879 rWorksheet->singleElement(XML_filters, XML_blank,
"1");
885 rWorksheet->startElement(XML_filters, XML_blank,
"1");
887 rWorksheet->startElement(XML_filters);
891 if( !rMultiValue.second )
893 rWorksheet->singleElement(XML_filter, XML_val, rMultiValue.first);
899 sal_Int32 aDateGroup[3] = { XML_year, XML_month, XML_day };
901 for (
size_t i = 0;
idx >= 0 &&
i < 3;
i++)
903 OString kw =
aStr.getToken(0,
'-',
idx);
907 pAttrList->add(aDateGroup[
i], kw);
912 pAttrList->add(XML_dateTimeGrouping,
"day");
913 rWorksheet->singleElement(XML_dateGroupItem, pAttrList);
916 rWorksheet->endElement(XML_filters);
922 rWorksheet->endElement( XML_filterColumn );
932 bool bAdvanced =
false;
937 bAdvanced =
pData->GetAdvancedQuerySource( aAdvRange );
938 bFound = (
pData->HasQueryParam() ||
pData->HasAutoFilter() || bAdvanced);
944 pData->GetQueryParam( aParam );
961 if( !pDefinedData && aAdvRange.
aStart.
Tab() == nTab )
969 if( !pDefinedData && aDestRange.
aStart.
Tab() == nTab )
978 bool bConflict =
false;
979 bool bContLoop =
true;
986 for(
SCSIZE nEntry = 0; !bConflict && bContLoop && (nEntry < aParam.
GetEntryCount()); nEntry++ )
995 bool bIsButtonHidden = !( nFlag &
ScMF::Auto );
1002 bConflict = (nEntry > 1) && bHasOr;
1005 (nFirstField != rEntry.
nField);
1007 bConflict = pFilter->
AddEntry( rEntry );
1011 sal_uInt16 nColId = 0;
1012 for (
auto nCol = aRange.
aStart.
Col(); nCol <= aRange.
aEnd.
Col(); nCol++, nColId++ )
1015 bool bIsButtonHidden = !( nFlag &
ScMF::Auto );
1016 if ( bIsButtonHidden )
1020 bool bFilterFound =
false;
1024 if( xFilter->GetCol() ==
static_cast<sal_uInt16
>(nCol) )
1026 bFilterFound =
true;
1030 if ( !bFilterFound )
1033 xFilter->SetButtonHidden(
true );
1043 bConflict = xFilter->HasCondition() && xFilter->HasTop10();
1059 pData->GetSortParam( aSortParam );
1074 bool bSortAscending=
true;
1075 for (
const auto & rKey : aSortParam.
maKeyState)
1079 nField = rKey.nField;
1080 bSortAscending = rKey.bAscending;
1089 const OUString aItemList = rData.
GetString();
1107 if( xFilter->GetCol() ==
static_cast<sal_uInt16
>(nCol) )
1108 return xFilter.get();
1112 return xFilter.get();
1163 if (std::get<2>(rSortCriteria))
1164 rWorksheet->singleElement(XML_sortCondition,
1166 std::get<0>(rSortCriteria)),
1167 XML_descending,
"1",
1168 XML_customList, std::get<1>(rSortCriteria));
1170 rWorksheet->singleElement(XML_sortCondition,
1172 std::get<0>(rSortCriteria)),
1173 XML_customList, std::get<1>(rSortCriteria));
1176 rWorksheet->endElement(XML_sortState);
1179 rWorksheet->endElement( XML_autoFilter );
1200 XclExpTabFilterMap::iterator aIt =
maFilterMap.find( nScTab );
1211 XclExpTabFilterMap::iterator aIt =
maFilterMap.find( nScTab );
1214 return aIt->second->HasFilterMode();
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 ...
Exc1904(const ScDocument &rDoc)
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual sal_uInt16 GetNum() const override
std::vector< std::tuple< ScRange, OUString, bool > > maSortCustomList
ExcAutoFilterRecs(const XclExpRoot &rRoot, SCTAB nTab, const ScDBData *pDefinedData)
XclExpAutofilter * GetByCol(SCCOL nCol)
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpAutofilterList maFilterList
bool HasFilterMode() const
virtual void Save(XclExpStream &rStrm) override
Overwrite this method to do any operation while saving the record.
rtl::Reference< XclExpFiltermode > m_pFilterMode
rtl::Reference< XclExpAutofilterinfo > m_pFilterInfo
bool IsFiltered(SCCOL nCol)
virtual ~ExcAutoFilterRecs() override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetLen() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetLen() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual std::size_t GetLen() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual sal_uInt16 GetNum() const override
void UpdateStreamPos(XclExpStream &rStrm)
ExcBundlesheet(const RootData &rRootData, SCTAB nTab)
virtual std::size_t GetLen() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
virtual sal_uInt16 GetNum() const override
virtual const sal_uInt8 * GetData() const =0
virtual std::size_t GetLen() const override
virtual const sal_uInt8 * GetData() const override
static const sal_uInt8 pMyData[]
static const std::size_t nMyLen
static const std::size_t nMyLen
static const sal_uInt8 pMyData[]
virtual std::size_t GetLen() const override
virtual const sal_uInt8 * GetData() const override
virtual std::size_t GetLen() const override
static const sal_uInt8 pMyData[]
virtual const sal_uInt8 * GetData() const override
static const std::size_t nMyLen
static const sal_uInt8 pMyData[]
virtual const sal_uInt8 * GetData() const override
virtual std::size_t GetLen() const override
static const std::size_t nMyLen
virtual sal_uInt16 GetNum() const override
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
virtual std::size_t GetLen() const override
virtual std::size_t GetLen() const override
virtual sal_uInt16 GetNum() const override
void Save(XclExpStream &rStrm)
void SaveXml(XclExpXmlStream &rStrm)
std::size_t GetTextBytes() const
void SetCondition(sal_uInt8 nTp, sal_uInt8 nOp, const OUString *pT)
std::unique_ptr< XclExpString > pText
void SaveText(XclExpStream &rStrm)
virtual sal_uInt16 GetNum() const =0
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
virtual std::size_t GetLen() const =0
virtual void SaveCont(XclExpStream &rStrm)
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record.
void IncCol(SCCOL nDelta=1)
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
static SC_DLLPUBLIC ScUserList * GetUserList()
sheet protection state container
bool isOptionEnabled(Option eOption) const
virtual css::uno::Sequence< sal_Int8 > getPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED) const override
const ::std::vector< ScEnhancedProtection > & getEnhancedProtection() const
Stores individual user-defined sort list.
const OUString & GetString() const
Collection of user-defined sort lists.
virtual void SaveXml(XclExpXmlStream &rStrm) override
ExcFilterCondition aCond[2]
bool HasCondition() const
XclExpAutofilter(const XclExpRoot &rRoot, sal_uInt16 nC, bool bIsEmpty=false)
void SetButtonHidden(bool bValue)
std::vector< std::pair<::Color, bool > > maColorValues
void AddColorEntry(const ScQueryEntry &rEntry)
std::vector< std::pair< OUString, bool > > maMultiValues
bool AddCondition(ScQueryConnect eConn, sal_uInt8 nType, sal_uInt8 nOp, const OUString *pText, bool bSimple=false)
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
void AddMultiValueEntry(const ScQueryEntry &rEntry)
sal_uInt16 GetCol() const
bool AddEntry(const ScQueryEntry &rEntry)
XclExpAutofilterinfo(const ScAddress &rStartPos, SCCOL nScCol)
Record which contains a Boolean value.
bool GetBool() const
Returns the Boolean value of the record.
sal_uInt16 mnDocCountry
The UI country ID.
XclExpCountry(const XclExpRoot &rRoot)
virtual void WriteBody(XclExpStream &rStrm) override
The document country ID.
void addColor(Color aColor)
bool HasFilterMode(SCTAB nScTab)
Returns whether or not FilterMode is present.
XclExpRecordRef CreateRecord(SCTAB nScTab)
Returns a record object containing all filter records for the specified sheet.
XclExpFilterManager(const XclExpRoot &rRoot)
void InitTabFilter(SCTAB nScTab)
Creates the filter records for the specified sheet.
XclExpTabFilterMap maFilterMap
Manager that stores all internal defined names (NAME records) of the document.
sal_uInt16 InsertBuiltInName(sal_Unicode cBuiltIn, const ScRange &rRange)
Inserts a new built-in defined name, referring to the passed sheet range.
sal_uInt16 AddObj(std::unique_ptr< XclObj > pObjRec)
XclExpPassHash(const css::uno::Sequence< sal_Int8 > &aHash)
virtual ~XclExpPassHash() override
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
XclExpProtection(bool bValue)
virtual void SaveXml(XclExpXmlStream &rStrm) override
void RemoveAllRecords()
Removes all records from the list.
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
void AppendRecord(RecType *pRec)
Appends a record to the list.
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Base class for single records with any content.
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
void SetRecHeader(sal_uInt16 nRecId, std::size_t nRecSize)
Sets record ID and size with one call.
void AddRecSize(std::size_t nRecSize)
Adds a size value to the record size prediction.
Access to global data from other classes.
XclExpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
XclExpObjectManager & GetObjectManager() const
Returns the drawing object manager.
XclExpDxfs & GetDxfs() const
Returns the differential formatting list.
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
XclExpSheetProtection(bool bValue, SCTAB nTab)
virtual void SaveXml(XclExpXmlStream &rStrm) override
This class is used to export Excel record streams.
This class stores an unformatted or formatted string for Excel export.
OUString GetScTabName(SCTAB nScTab) const
Returns the Calc name of the specified sheet.
A record with a single value of type Type.
const Type & GetValue() const
Returns the value of the record.
void SetValue(const Type &rValue)
Sets a new record value.
XclExpWindowProtection(bool bValue)
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpWsbool(bool bFitToPages)
XclExpFilterManager * mpManager
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpXmlSheetPr(bool bFitToPages, SCTAB nScTab, const Color &rTabColor, XclExpFilterManager *pManager)
LanguageType GetDocLanguage() const
Returns the document language.
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
static OString ToOString(const Color &rColor)
static rtl::Reference< FastAttributeList > createAttrList()
const OUString & getString() const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
const sal_uInt16 EXC_AFFLAG_AND
const sal_uInt8 EXC_AFOPER_NOTEQUAL
const sal_uInt16 EXC_AFFLAG_TOP10TOP
const sal_uInt16 EXC_AFFLAG_TOP10
const sal_uInt16 EXC_AFFLAG_SIMPLE2
const sal_uInt16 EXC_AFFLAG_TOP10PERC
const sal_uInt8 EXC_AFOPER_LESS
const sal_uInt16 EXC_AFFLAG_OR
const sal_uInt8 EXC_AFOPER_GREATEREQUAL
const sal_uInt8 EXC_AFTYPE_STRING
const sal_uInt8 EXC_AFOPER_NONE
const sal_uInt16 EXC_AFFLAG_ANDORMASK
const sal_uInt8 EXC_AFOPER_GREATER
const sal_uInt8 EXC_AFOPER_LESSEQUAL
const sal_uInt16 EXC_AFFLAG_SIMPLE1
const sal_uInt8 EXC_AFOPER_EQUAL
const sal_uInt8 EXC_AFTYPE_NOTEMPTY
const sal_uInt8 EXC_AFTYPE_EMPTY
const sal_uInt8 EXC_AFTYPE_NOTUSED
static const char * lcl_GetOperator(sal_uInt8 nOper)
static OString lcl_GetValue(sal_uInt8 nType, const XclExpString *pStr)
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const char * UseIf(const char *s, bool bUse)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
#define STREAM_SEEK_TO_END
OOXML password definitions: algorithmName, hashValue, saltValue, spinCount.
OUString maSaltValue
base64 encoded hash value
OUString maHashValue
"SHA-512", ...
sal_uInt32 mnSpinCount
base64 encoded salt value
svl::SharedString maString
Each instance of this struct represents a single filtering criteria.
bool IsQueryByNonEmpty() const
bool IsQueryByTextColor() const
std::vector< Item > QueryItemsType
bool IsQueryByEmpty() const
bool IsQueryByBackgroundColor() const
QueryItemsType & GetQueryItems()
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
SC_DLLPUBLIC SCSIZE GetEntryCount() const
::std::vector< ScSortKeyState > maKeyState
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
const sal_uInt16 EXC_ID_PROTECT
const sal_uInt16 EXC_ID_AUTOFILTER
const sal_uInt16 EXC_ID_AUTOFILTERINFO
const sal_uInt16 EXC_WSBOOL_DEFAULTFLAGS
const sal_uInt16 EXC_ID_COUNTRY
const SCTAB SCTAB_GLOBAL
An invalid Calc sheet index, for common use.
const sal_uInt16 EXC_ID_WINDOWPROTECT
const sal_uInt16 EXC_ID_PASSWORD
const sal_uInt16 EXC_ID_FILTERMODE
const sal_uInt16 EXC_WSBOOL_FITTOPAGE
const sal_uInt16 EXC_ID_WSBOOL
const sal_Unicode EXC_BUILTIN_EXTRACT
const sal_Unicode EXC_BUILTIN_FILTERDATABASE
const sal_Unicode EXC_BUILTIN_CRITERIA
@ EightBitLength
Always use UCS-2 characters (default: try to compress). BIFF8 only.