LCOV - code coverage report
Current view: top level - sc/inc - validat.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 19 0.0 %
Date: 2014-04-14 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef SC_VALIDAT_HXX
      21             : #define SC_VALIDAT_HXX
      22             : 
      23             : #include "conditio.hxx"
      24             : #include <com/sun/star/sheet/TableValidationVisibility.hpp>
      25             : #include "scdllapi.h"
      26             : 
      27             : namespace ValidListType = ::com::sun::star::sheet::TableValidationVisibility;
      28             : 
      29             : namespace sc {
      30             : 
      31             : struct RefUpdateContext;
      32             : 
      33             : }
      34             : 
      35             : class ScPatternAttr;
      36             : class ScTokenArray;
      37             : class ScTypedStrData;
      38             : 
      39             : enum ScValidationMode
      40             : {
      41             :     SC_VALID_ANY,
      42             :     SC_VALID_WHOLE,
      43             :     SC_VALID_DECIMAL,
      44             :     SC_VALID_DATE,
      45             :     SC_VALID_TIME,
      46             :     SC_VALID_TEXTLEN,
      47             :     SC_VALID_LIST,
      48             :     SC_VALID_CUSTOM
      49             : };
      50             : 
      51             : enum ScValidErrorStyle
      52             : {
      53             :     SC_VALERR_STOP,
      54             :     SC_VALERR_WARNING,
      55             :     SC_VALERR_INFO,
      56             :     SC_VALERR_MACRO
      57             : };
      58             : 
      59             : 
      60             : // Entry for validation (only one condition exists)
      61             : 
      62             : 
      63             : class SC_DLLPUBLIC ScValidationData : public ScConditionEntry
      64             : {
      65             : private:
      66             :     sal_uInt32 nKey;               // index in attributes
      67             : 
      68             :     ScValidationMode eDataMode;
      69             :     bool bShowInput;
      70             :     bool bShowError;
      71             :     ScValidErrorStyle eErrorStyle;
      72             :     sal_Int16 mnListType;         // selection list type: none, unsorted, sorted.
      73             :     OUString aInputTitle;
      74             :     OUString aInputMessage;
      75             :     OUString aErrorTitle;
      76             :     OUString aErrorMessage;
      77             : 
      78             :     bool DoMacro( const ScAddress& rPos, const OUString& rInput,
      79             :                                 ScFormulaCell* pCell, Window* pParent ) const;
      80             : 
      81             :     bool DoScript( const ScAddress& rPos, const OUString& rInput,
      82             :                                 ScFormulaCell* pCell, Window* pParent ) const;
      83             : 
      84             :     using ScConditionEntry::operator==;
      85             : 
      86             : public:
      87             :             ScValidationData( ScValidationMode eMode, ScConditionMode eOper,
      88             :                                 const OUString& rExpr1, const OUString& rExpr2,
      89             :                                 ScDocument* pDocument, const ScAddress& rPos,
      90           0 :                                 const OUString& rExprNmsp1 = EMPTY_OUSTRING, const OUString& rExprNmsp2 = EMPTY_OUSTRING,
      91             :                                 formula::FormulaGrammar::Grammar eGrammar1 = formula::FormulaGrammar::GRAM_DEFAULT,
      92             :                                 formula::FormulaGrammar::Grammar eGrammar2 = formula::FormulaGrammar::GRAM_DEFAULT );
      93             :             ScValidationData( ScValidationMode eMode, ScConditionMode eOper,
      94             :                                 const ScTokenArray* pArr1, const ScTokenArray* pArr2,
      95             :                                 ScDocument* pDocument, const ScAddress& rPos );
      96             :             ScValidationData( const ScValidationData& r );
      97             :             ScValidationData( ScDocument* pDocument, const ScValidationData& r );
      98             :     virtual ~ScValidationData();
      99             : 
     100           0 :     ScValidationData* Clone() const     // real copy
     101           0 :                     { return new ScValidationData( GetDocument(), *this ); }
     102           0 :     ScValidationData* Clone(ScDocument* pNew) const SAL_OVERRIDE
     103           0 :                     { return new ScValidationData( pNew, *this ); }
     104             : 
     105             :     void            ResetInput();
     106             :     void            ResetError();
     107             :     void            SetInput( const OUString& rTitle, const OUString& rMsg );
     108             :     void            SetError( const OUString& rTitle, const OUString& rMsg,
     109             :                                 ScValidErrorStyle eStyle );
     110             : 
     111           0 :     bool            GetInput( OUString& rTitle, OUString& rMsg ) const
     112           0 :                         { rTitle = aInputTitle; rMsg = aInputMessage; return bShowInput; }
     113             :     bool            GetErrMsg( OUString& rTitle, OUString& rMsg, ScValidErrorStyle& rStyle ) const;
     114             : 
     115           0 :     bool            HasErrMsg() const       { return bShowError; }
     116             : 
     117           0 :     ScValidationMode GetDataMode() const    { return eDataMode; }
     118             : 
     119           0 :     inline sal_Int16 GetListType() const                { return mnListType; }
     120           0 :     inline void     SetListType( sal_Int16 nListType )  { mnListType = nListType; }
     121             : 
     122             :     /** Returns true, if the validation cell will show a selection list.
     123             :         @descr  Use this instead of GetListType() which returns the raw property
     124             :         regardless of the validation type. */
     125             :     bool            HasSelectionList() const;
     126             :     /** Tries to fill the passed collection with list validation entries.
     127             :         @descr  Fills the list only, if this is a list validation and IsShowList() is enabled.
     128             :         @param rStrings  (out-param) The string list to fill with list validation entires.
     129             :         @return  true = rStrings has been filled with at least one entry. */
     130             :     bool FillSelectionList(std::vector<ScTypedStrData>& rStrings, const ScAddress& rPos) const;
     131             : 
     132             :     //  with string: during input, with cell: for detective / RC_FORCED
     133             :     bool IsDataValid(
     134             :         const OUString& rTest, const ScPatternAttr& rPattern, const ScAddress& rPos ) const;
     135             : 
     136             :     bool IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos ) const;
     137             : 
     138             :                     // TRUE -> break
     139             :     bool DoError( Window* pParent, const OUString& rInput, const ScAddress& rPos ) const;
     140             :     void DoCalcError( ScFormulaCell* pCell ) const;
     141             : 
     142             :     bool IsEmpty() const;
     143           0 :     sal_uInt32      GetKey() const          { return nKey; }
     144           0 :     void            SetKey(sal_uInt32 nNew) { nKey = nNew; }    // only if not inserted!
     145             : 
     146             :     bool            EqualEntries( const ScValidationData& r ) const;    // for undo
     147             : 
     148             :     //  sort (using std::set) by index
     149             :     //  operator== only for sorting
     150             :     bool operator ==( const ScValidationData& r ) const { return nKey == r.nKey; }
     151           0 :     bool operator < ( const ScValidationData& r ) const { return nKey <  r.nKey; }
     152             : 
     153             : private:
     154             :     /** Tries to fill the passed collection with list validation entries.
     155             :         @descr  Fills the list only if it is non-NULL,
     156             :         @param pStrings  (out-param) Optionally NULL, string list to fill with list validation entires.
     157             :         @param pCell     can be NULL if it is not necessary to which element in the list is selected.
     158             :         @param rPos      the base address for relative references.
     159             :         @param rTokArr   Formula token array.
     160             :         @param rMatch    (out-param) the index of the first item that matched, -1 if nothing matched.
     161             :         @return  true = Cell range found, rRange is valid, or an error entry stuffed into the list if pCell==NULL. */
     162             :     bool GetSelectionFromFormula(
     163             :         std::vector<ScTypedStrData>* pStrings, ScRefCellValue& rCell, const ScAddress& rPos,
     164             :         const ScTokenArray& rTokArr, int& rMatch) const;
     165             : 
     166             :     /** Tests, if pCell is equal to what the passed token array represents. */
     167             :     bool IsEqualToTokenArray( ScRefCellValue& rCell, const ScAddress& rPos, const ScTokenArray& rTokArr ) const;
     168             : 
     169             :     /** Tests, if contents of pCell occur in cell range referenced by own formula, or in a string list. */
     170             :     bool IsListValid( ScRefCellValue& rCell, const ScAddress& rPos ) const;
     171             : };
     172             : 
     173             : 
     174             : //  list of contitions:
     175             : 
     176             : 
     177             : struct CompareScValidationDataPtr
     178             : {
     179           0 :   bool operator()( ScValidationData* const& lhs, ScValidationData* const& rhs ) const { return (*lhs)<(*rhs); }
     180             : };
     181             : 
     182             : class ScValidationDataList
     183             : {
     184             : private:
     185             :     typedef std::set<ScValidationData*, CompareScValidationDataPtr> ScValidationDataListDataType;
     186             :     ScValidationDataListDataType maData;
     187             : 
     188             : public:
     189           0 :     ScValidationDataList() {}
     190             :     ScValidationDataList(const ScValidationDataList& rList);
     191             :     ScValidationDataList(ScDocument* pNewDoc, const ScValidationDataList& rList);
     192           0 :     ~ScValidationDataList() {}
     193             : 
     194             :     typedef ScValidationDataListDataType::iterator iterator;
     195             :     typedef ScValidationDataListDataType::const_iterator const_iterator;
     196             : 
     197             :     iterator begin();
     198             :     const_iterator begin() const;
     199             :     iterator end();
     200             :     const_iterator end() const;
     201             : 
     202           0 :     void InsertNew( ScValidationData* pNew )
     203           0 :                 { if (!maData.insert(pNew).second) delete pNew; }
     204             : 
     205             :     ScValidationData* GetData( sal_uInt32 nKey );
     206             : 
     207             :     void CompileXML();
     208             :     void UpdateReference( sc::RefUpdateContext& rCxt );
     209             :     void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
     210             :     void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
     211             :     void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt );
     212             : 
     213             :     bool operator==( const ScValidationDataList& r ) const;      // for ref-undo
     214             : 
     215             :     void clear();
     216             : 
     217             : };
     218             : 
     219             : #endif
     220             : 
     221             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10