/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #ifndef INCLUDED_TOOLS_MULTISEL_HXX #define INCLUDED_TOOLS_MULTISEL_HXX #include #include #include #include #include #define SFX_ENDOFSELECTION SAL_MAX_INT32 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC MultiSelection { private: std::vector< Range > aSels; // array of SV-selections Range aTotRange; // total range of indexes sal_Int32 nCurSubSel; // index in aSels of current selected index sal_Int32 nCurIndex; // current selected entry sal_Int32 nSelCount; // number of selected indexes bool bCurValid; // are nCurIndex and nCurSubSel valid TOOLS_DLLPRIVATE void ImplClear(); TOOLS_DLLPRIVATE sal_Int32 ImplFindSubSelection( sal_Int32 nIndex ) const; TOOLS_DLLPRIVATE void ImplMergeSubSelections( sal_Int32 nPos1, sal_Int32 nPos2 ); public: MultiSelection(); MultiSelection( const MultiSelection& rOrig ); MultiSelection( const Range& rRange ); ~MultiSelection(); MultiSelection& operator= ( const MultiSelection& rOrig ); void SelectAll( bool bSelect = true ); bool Select( sal_Int32 nIndex, bool bSelect = true ); void Select( const Range& rIndexRange, bool bSelect = true ); bool IsSelected( sal_Int32 nIndex ) const; bool IsAllSelected() const { return nSelCount == aTotRange.Len(); } sal_Int32 GetSelectCount() const { return nSelCount; } void SetTotalRange( const Range& rTotRange ); void Insert( sal_Int32 nIndex, sal_Int32 nCount = 1 ); void Remove( sal_Int32 nIndex ); void Reset(); const Range& GetTotalRange() const { return aTotRange; } sal_Int32 FirstSelected(); sal_Int32 LastSelected(); sal_Int32 NextSelected(); sal_Int32 GetRangeCount() const { return aSels.size(); } const Range& GetRange( sal_Int32 nRange ) const { return aSels[nRange]; } }; class SAL_WARN_UNUSED TOOLS_DLLPUBLIC StringRangeEnumerator { struct Range { sal_Int32 nFirst; sal_Int32 nLast; Range( sal_Int32 i_nFirst, sal_Int32 i_nLast ) : nFirst( i_nFirst ), nLast( i_nLast ) {} }; std::vector< StringRangeEnumerator::Range > maSequence; sal_Int32 mnCount; sal_Int32 mnMin; sal_Int32 mnMax; sal_Int32 mnOffset; bool mbValidInput; bool setRange( const OUString& i_rNewRange ); bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence ); void insertJoinedRanges( const std::vector< sal_Int32 >& rNumbers ); bool checkValue( sal_Int32, const std::set< sal_Int32 >* i_pPossibleValues = nullptr ) const; public: class TOOLS_DLLPUBLIC Iterator { const StringRangeEnumerator* pEnumerator; const std::set< sal_Int32 >* pPossibleValues; sal_Int32 nRangeIndex; sal_Int32 nCurrent; friend class StringRangeEnumerator; Iterator( const StringRangeEnumerator* i_pEnum, const std::set< sal_Int32 >* i_pPossibleValues, sal_Int32 i_nRange, sal_Int32 i_nCurrent ) : pEnumerator( i_pEnum ), pPossibleValues( i_pPossibleValues ) , nRangeIndex( i_nRange ), nCurrent( i_nCurrent ) {} public: Iterator& operator++(); sal_Int32 operator*() const { return nCurrent;} bool operator==(const Iterator&) const; bool operator!=(const Iterator& i_rComp) const { return ! (*this == i_rComp); } }; friend class StringRangeEnumerator::Iterator; StringRangeEnumerator( const OUString& i_rInput, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset = -1 ); sal_Int32 size() const { return mnCount; } Iterator begin( const std::set< sal_Int32 >* i_pPossibleValues = nullptr ) const; Iterator end( const std::set< sal_Int32 >* i_pPossibleValues = nullptr ) const; bool hasValue( sal_Int32 nValue, const std::set< sal_Int32 >* i_pPossibleValues = nullptr ) const; /** i_rPageRange: the string to be changed into a sequence of numbers valid format example "5-3,9,9,7-8" ; instead of ',' ';' or ' ' are allowed as well o_rPageVector: the output sequence of numbers i_nLogicalOffset: an offset to be applied to each number in the string before inserting it in the resulting sequence example: a user enters page numbers from 1 to n (since that is logical) of course usable page numbers in code would start from 0 and end at n-1 so the logical offset would be -1 i_nMinNumber: the minimum allowed number i_nMaxNumber: the maximum allowed number @returns: true if the input string was valid, o_rPageVector will contain the resulting sequence false if the input string was invalid, o_rPageVector will contain the sequence that parser is able to extract behavior: - only non-negative sequence numbers are allowed - only non-negative values in the input string are allowed - the string "-3" means the sequence i_nMinNumber to 3 - the string "3-" means the sequence 3 to i_nMaxNumber - the string "-" means the sequence i_nMinNumber to i_nMaxNumber - single number that doesn't fit in [i_nMinNumber,i_nMaxNumber] will be ignored - range that doesn't fit in [i_nMinNumber,i_nMaxNumber] will be adjusted */ static bool getRangesFromString( const OUString& i_rPageRange, std::vector< sal_Int32 >& o_rPageVector, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset = -1, std::set< sal_Int32 > const * i_pPossibleValues = nullptr ); }; #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ >distro/mimo/mimo-6-3 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-07-20cid#1554791 COPY_INSTEAD_OF_MOVECaolán McNamara
and cid#1554819 COPY_INSTEAD_OF_MOVE cid#1554837 COPY_INSTEAD_OF_MOVE cid#1554881 COPY_INSTEAD_OF_MOVE cid#1554882 COPY_INSTEAD_OF_MOVE cid#1554884 COPY_INSTEAD_OF_MOVE cid#1554891 COPY_INSTEAD_OF_MOVE cid#1554892 COPY_INSTEAD_OF_MOVE cid#1554897 COPY_INSTEAD_OF_MOVE cid#1554904 COPY_INSTEAD_OF_MOVE cid#1554918 COPY_INSTEAD_OF_MOVE cid#1554928 COPY_INSTEAD_OF_MOVE cid#1554931 COPY_INSTEAD_OF_MOVE cid#1554944 COPY_INSTEAD_OF_MOVE cid#1554945 COPY_INSTEAD_OF_MOVE cid#1554959 COPY_INSTEAD_OF_MOVE cid#1554960 COPY_INSTEAD_OF_MOVE cid#1554963 COPY_INSTEAD_OF_MOVE cid#1554966 COPY_INSTEAD_OF_MOVE cid#1554969 COPY_INSTEAD_OF_MOVE cid#1554973 COPY_INSTEAD_OF_MOVE cid#1555011 COPY_INSTEAD_OF_MOVE cid#1555012 COPY_INSTEAD_OF_MOVE cid#1555015 COPY_INSTEAD_OF_MOVE cid#1555044 COPY_INSTEAD_OF_MOVE cid#1555051 COPY_INSTEAD_OF_MOVE cid#1555055 COPY_INSTEAD_OF_MOVE cid#1555063 COPY_INSTEAD_OF_MOVE cid#1555068 COPY_INSTEAD_OF_MOVE cid#1555073 COPY_INSTEAD_OF_MOVE cid#1555074 COPY_INSTEAD_OF_MOVE cid#1555078 COPY_INSTEAD_OF_MOVE cid#1555080 COPY_INSTEAD_OF_MOVE cid#1555091 COPY_INSTEAD_OF_MOVE cid#1555099 COPY_INSTEAD_OF_MOVE cid#1555101 COPY_INSTEAD_OF_MOVE cid#1555121 COPY_INSTEAD_OF_MOVE cid#1610739 COPY_INSTEAD_OF_MOVE cid#1608424 COPY_INSTEAD_OF_MOVE cid#1608059 COPY_INSTEAD_OF_MOVE cid#1607952 COPY_INSTEAD_OF_MOVE cid#1607653 COPY_INSTEAD_OF_MOVE cid#1607614 COPY_INSTEAD_OF_MOVE cid#1607592 COPY_INSTEAD_OF_MOVE Change-Id: Ie9f922a9fe1b8001dfab31e2741fe8bd5558e442 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170802 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-06-20loplugin:unusedfieldsNoel Grandin
Change-Id: I4bc67811e228b4806db9f9b9bf9fb0de0eb36de2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169263 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-04-22pivot: handle whole row/column selections, added many testsTomaž Vajngerl
This adds support for selecting whole rows/columns, where the field reference is set but no indices are present. This means that all the data cells apply (selecting the whole thing), which are not subtotals. For this the support for multiple matching and maybe matching results was added (previously max 1 would apply), which would apply the pattern to multiple cells in the pivot table. In addition handle labels of columns with multiple data fields correctly. This also adds many more test scenarios, which all cover the changes mentioned above. Change-Id: Ibcdaa933c69991eaa55a2ad18b9f9a838308d478 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166384 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-04-16pivot: suppprt multiple cell format reference indicesTomaž Vajngerl
This adds support for multiple cell format reference indices, so the same cell format is applied to multiple cells (defined by indices) so that each doesn't need to be defined by its own reference (as they are all the same anyway and only differ by single index). The solution is to create multiple format outputs for one format entry - each for a selection index, but have other data still the same. This is a bit tricky as previously it was one format output for one format entry, which is not the case anymore. Change-Id: I074ac03e7d81e26562a6a6cc395b11cfed16766d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166131 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-04-14ofz#68019 Null-dereference READCaolán McNamara
Change-Id: Ie0c9c5a74e6ae87a0bd4c35320a687458d1d9902 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166074 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-04-13ofz#68019 Null-dereference READCaolán McNamara
Change-Id: I9ad5d907c4739877d51b74ef0f2e275d94119f09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166052 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-04-13pivot: Export Pivot Table "formats" element(s)Tomaž Vajngerl
This change adds the "formats" element tree export for a pivot table. The source are the formats (sc::PivotTableFormats) added to the pivot table - in the ScDPSaveData class. This are currently set on import but in the future hopefully those are also set through the UI. Change-Id: I5ed8f7e8d7ac248b0222a884fb97555ef6bb8427 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166035 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-04-12pivot: PivotTableFormatOutput to resolve and set PT cell formatTomaž Vajngerl
This adds the PivotTableFormatOutput, which main responsibility is to resolve the reference for which the pivot table format is set to. It first prepares the format data into such a structure that it is easier to match with the pivot table fields and data. Then the pivot table data is filled during the output, where we remember the cell positions of the pivot table output. The last step is to resolve the pivot table format references with the filled data, where the cell formats are applied to the output. PivotTableFormatsImportExport was added to test the correctnes of the functionality. Change-Id: Ie67ea15b3aa74739f15937800d03d256b8f68277 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165992 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-04-12pivot: use ScPatternAttr not styles for pivot table cell formatTomaž Vajngerl
Get the ItemSet from the Dxf instead of creating a style from it, then create a new ScPatterAttr, which is then transported to the pivot table and used there. Change-Id: I2ed886d0dd986b587e37330a39d6cd465b3bcf12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165686 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-04-11pivot: forward pivot table format data into the pivot table modelTomaž Vajngerl
The purpuse of this is to lay out the foundation for the support of pivot table formatting. This adds the code to forward the formatting information from the OOXML import into the pivot table model and uses it in a use case to set the row and column labels in the pivot table output (DPOutput). In the follow up commits the support will be extended to support more use cases with tests. Change-Id: Idf23884b32167bdbad69bc67358ccf7f14566db6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164710 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-04-11pivot: Import Pivot Table "formats" element(s)Tomaž Vajngerl
This reads the "formats" element that is a subelement of OOXML "pivotTableDefinition" element and is used to define the custom cell format of a pivot table output. Change-Id: Ice0d489d78860ef04388c59810d9f97c5cdb983e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164708 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>