LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/unoobj - fmtuno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 409 549 74.5 %
Date: 2013-07-09 Functions: 61 82 74.4 %
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             : 
      21             : #include <boost/bind.hpp>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : #include <comphelper/servicehelper.hxx>
      25             : 
      26             : #include <com/sun/star/sheet/ValidationAlertStyle.hpp>
      27             : #include <com/sun/star/sheet/ValidationType.hpp>
      28             : #include <com/sun/star/sheet/TableValidationVisibility.hpp>
      29             : 
      30             : #include "fmtuno.hxx"
      31             : #include "miscuno.hxx"
      32             : #include "validat.hxx"
      33             : #include "document.hxx"
      34             : #include "unonames.hxx"
      35             : #include "styleuno.hxx"     // ScStyleNameConversion
      36             : #include "tokenarray.hxx"
      37             : #include "tokenuno.hxx"
      38             : #include "stylehelper.hxx"
      39             : 
      40             : using namespace ::com::sun::star;
      41             : using namespace ::formula;
      42             : 
      43             : //------------------------------------------------------------------------
      44             : 
      45             : //  Map nur fuer PropertySetInfo
      46             : 
      47          75 : static const SfxItemPropertyMapEntry* lcl_GetValidatePropertyMap()
      48             : {
      49             :     static SfxItemPropertyMapEntry aValidatePropertyMap_Impl[] =
      50             :     {
      51           2 :         {MAP_CHAR_LEN(SC_UNONAME_ERRALSTY), 0,  &getCppuType((sheet::ValidationAlertStyle*)0),  0, 0},
      52           2 :         {MAP_CHAR_LEN(SC_UNONAME_ERRMESS),  0,  &getCppuType((OUString*)0),                0, 0},
      53           2 :         {MAP_CHAR_LEN(SC_UNONAME_ERRTITLE), 0,  &getCppuType((OUString*)0),                0, 0},
      54           2 :         {MAP_CHAR_LEN(SC_UNONAME_IGNOREBL), 0,  &getBooleanCppuType(),                          0, 0},
      55           2 :         {MAP_CHAR_LEN(SC_UNONAME_INPMESS),  0,  &getCppuType((OUString*)0),                0, 0},
      56           2 :         {MAP_CHAR_LEN(SC_UNONAME_INPTITLE), 0,  &getCppuType((OUString*)0),                0, 0},
      57           2 :         {MAP_CHAR_LEN(SC_UNONAME_SHOWERR),  0,  &getBooleanCppuType(),                          0, 0},
      58           2 :         {MAP_CHAR_LEN(SC_UNONAME_SHOWINP),  0,  &getBooleanCppuType(),                          0, 0},
      59           2 :         {MAP_CHAR_LEN(SC_UNONAME_SHOWLIST), 0,  &getCppuType((sal_Int16*)0),                    0, 0},
      60           2 :         {MAP_CHAR_LEN(SC_UNONAME_TYPE),     0,  &getCppuType((sheet::ValidationType*)0),        0, 0},
      61             :         {0,0,0,0,0,0}
      62          95 :     };
      63          75 :     return aValidatePropertyMap_Impl;
      64             : }
      65             : 
      66             : //------------------------------------------------------------------------
      67             : 
      68           0 : SC_SIMPLE_SERVICE_INFO( ScTableConditionalEntry, "ScTableConditionalEntry", "com.sun.star.sheet.TableConditionalEntry" )
      69           0 : SC_SIMPLE_SERVICE_INFO( ScTableConditionalFormat, "ScTableConditionalFormat", "com.sun.star.sheet.TableConditionalFormat" )
      70           0 : SC_SIMPLE_SERVICE_INFO( ScTableValidationObj, "ScTableValidationObj", "com.sun.star.sheet.TableValidation" )
      71             : 
      72             : //------------------------------------------------------------------------
      73             : 
      74           0 : static sal_Int32 lcl_ConditionModeToOperatorNew( ScConditionMode eMode )
      75             : {
      76           0 :     sal_Int32 eOper = sheet::ConditionOperator2::NONE;
      77           0 :     switch (eMode)
      78             :     {
      79           0 :         case SC_COND_EQUAL:         eOper = sheet::ConditionOperator2::EQUAL;           break;
      80           0 :         case SC_COND_LESS:          eOper = sheet::ConditionOperator2::LESS;            break;
      81           0 :         case SC_COND_GREATER:       eOper = sheet::ConditionOperator2::GREATER;         break;
      82           0 :         case SC_COND_EQLESS:        eOper = sheet::ConditionOperator2::LESS_EQUAL;      break;
      83           0 :         case SC_COND_EQGREATER:     eOper = sheet::ConditionOperator2::GREATER_EQUAL;   break;
      84           0 :         case SC_COND_NOTEQUAL:      eOper = sheet::ConditionOperator2::NOT_EQUAL;       break;
      85           0 :         case SC_COND_BETWEEN:       eOper = sheet::ConditionOperator2::BETWEEN;         break;
      86           0 :         case SC_COND_NOTBETWEEN:    eOper = sheet::ConditionOperator2::NOT_BETWEEN;     break;
      87           0 :         case SC_COND_DIRECT:        eOper = sheet::ConditionOperator2::FORMULA;         break;
      88           0 :         case SC_COND_DUPLICATE:     eOper = sheet::ConditionOperator2::DUPLICATE;       break;
      89             :         default:
      90             :         {
      91             :             // added to avoid warnings
      92             :         }
      93             :     }
      94           0 :     return eOper;
      95             : }
      96             : 
      97          12 : static sheet::ConditionOperator lcl_ConditionModeToOperator( ScConditionMode eMode )
      98             : {
      99          12 :     sheet::ConditionOperator eOper = sheet::ConditionOperator_NONE;
     100          12 :     switch (eMode)
     101             :     {
     102           1 :         case SC_COND_EQUAL:         eOper = sheet::ConditionOperator_EQUAL;         break;
     103           0 :         case SC_COND_LESS:          eOper = sheet::ConditionOperator_LESS;          break;
     104           0 :         case SC_COND_GREATER:       eOper = sheet::ConditionOperator_GREATER;       break;
     105           0 :         case SC_COND_EQLESS:        eOper = sheet::ConditionOperator_LESS_EQUAL;    break;
     106           0 :         case SC_COND_EQGREATER:     eOper = sheet::ConditionOperator_GREATER_EQUAL; break;
     107           0 :         case SC_COND_NOTEQUAL:      eOper = sheet::ConditionOperator_NOT_EQUAL;     break;
     108           2 :         case SC_COND_BETWEEN:       eOper = sheet::ConditionOperator_BETWEEN;       break;
     109           0 :         case SC_COND_NOTBETWEEN:    eOper = sheet::ConditionOperator_NOT_BETWEEN;   break;
     110           0 :         case SC_COND_DIRECT:        eOper = sheet::ConditionOperator_FORMULA;       break;
     111             :         default:
     112             :         {
     113             :             // added to avoid warnings
     114             :         }
     115             :     }
     116          12 :     return eOper;
     117             : }
     118             : 
     119           5 : static ScConditionMode lcl_ConditionOperatorToMode( sheet::ConditionOperator eOper )
     120             : {
     121           5 :     ScConditionMode eMode = SC_COND_NONE;
     122           5 :     switch (eOper)
     123             :     {
     124           0 :         case sheet::ConditionOperator_EQUAL:            eMode = SC_COND_EQUAL;      break;
     125           0 :         case sheet::ConditionOperator_LESS:             eMode = SC_COND_LESS;       break;
     126           0 :         case sheet::ConditionOperator_GREATER:          eMode = SC_COND_GREATER;    break;
     127           0 :         case sheet::ConditionOperator_LESS_EQUAL:       eMode = SC_COND_EQLESS;     break;
     128           0 :         case sheet::ConditionOperator_GREATER_EQUAL:    eMode = SC_COND_EQGREATER;  break;
     129           0 :         case sheet::ConditionOperator_NOT_EQUAL:        eMode = SC_COND_NOTEQUAL;   break;
     130           3 :         case sheet::ConditionOperator_BETWEEN:          eMode = SC_COND_BETWEEN;    break;
     131           0 :         case sheet::ConditionOperator_NOT_BETWEEN:      eMode = SC_COND_NOTBETWEEN; break;
     132           0 :         case sheet::ConditionOperator_FORMULA:          eMode = SC_COND_DIRECT;     break;
     133             :         default:
     134             :         {
     135             :             // added to avoid warnings
     136             :         }
     137             :     }
     138           5 :     return eMode;
     139             : }
     140             : 
     141             : //------------------------------------------------------------------------
     142             : 
     143          23 : ScCondFormatEntryItem::ScCondFormatEntryItem() :
     144             :     meGrammar1( FormulaGrammar::GRAM_UNSPECIFIED ),
     145             :     meGrammar2( FormulaGrammar::GRAM_UNSPECIFIED ),
     146          23 :     meMode( SC_COND_NONE )
     147             : {
     148          23 : }
     149             : 
     150             : //------------------------------------------------------------------------
     151             : 
     152          72 : ScTableConditionalFormat::ScTableConditionalFormat(
     153          72 :         ScDocument* pDoc, sal_uLong nKey, SCTAB nTab, FormulaGrammar::Grammar eGrammar)
     154             : {
     155             :     //  Eintrag aus dem Dokument lesen...
     156             : 
     157          72 :     if ( pDoc && nKey )
     158             :     {
     159          44 :         ScConditionalFormatList* pList = pDoc->GetCondFormList(nTab);
     160          44 :         if (pList)
     161             :         {
     162          44 :             const ScConditionalFormat* pFormat = pList->GetFormat( nKey );
     163          44 :             if (pFormat)
     164             :             {
     165             :                 // During save to XML.
     166          44 :                 if (pDoc->IsInExternalReferenceMarking())
     167           0 :                     pFormat->MarkUsedExternalReferences();
     168             : 
     169          44 :                 size_t nEntryCount = pFormat->size();
     170          58 :                 for (size_t i=0; i<nEntryCount; i++)
     171             :                 {
     172          14 :                     ScCondFormatEntryItem aItem;
     173          14 :                     const ScFormatEntry* pFrmtEntry = pFormat->GetEntry(i);
     174          14 :                     if(pFrmtEntry->GetType() != condformat::CONDITION)
     175           6 :                         continue;
     176             : 
     177           8 :                     const ScCondFormatEntry* pFormatEntry = static_cast<const ScCondFormatEntry*>(pFrmtEntry);
     178           8 :                     aItem.meMode = pFormatEntry->GetOperation();
     179           8 :                     aItem.maPos = pFormatEntry->GetValidSrcPos();
     180           8 :                     aItem.maExpr1 = pFormatEntry->GetExpression(aItem.maPos, 0, 0, eGrammar);
     181           8 :                     aItem.maExpr2 = pFormatEntry->GetExpression(aItem.maPos, 1, 0, eGrammar);
     182           8 :                     aItem.meGrammar1 = aItem.meGrammar2 = eGrammar;
     183           8 :                     aItem.maStyle = pFormatEntry->GetStyle();
     184             : 
     185           8 :                     AddEntry_Impl(aItem);
     186           8 :                 }
     187             :             }
     188             :         }
     189             :     }
     190          72 : }
     191             : 
     192             : namespace {
     193             : 
     194          36 : FormulaGrammar::Grammar lclResolveGrammar( FormulaGrammar::Grammar eExtGrammar, FormulaGrammar::Grammar eIntGrammar )
     195             : {
     196          36 :     if( eExtGrammar != FormulaGrammar::GRAM_UNSPECIFIED )
     197          32 :         return eExtGrammar;
     198             :     OSL_ENSURE( eIntGrammar != FormulaGrammar::GRAM_UNSPECIFIED, "lclResolveGrammar - unspecified grammar, using GRAM_PODF_A1" );
     199           4 :     return (eIntGrammar == FormulaGrammar::GRAM_UNSPECIFIED) ? FormulaGrammar::GRAM_PODF_A1 : eIntGrammar;
     200             : }
     201             : 
     202             : } // namespace
     203             : 
     204           8 : void ScTableConditionalFormat::FillFormat( ScConditionalFormat& rFormat,
     205             :         ScDocument* pDoc, FormulaGrammar::Grammar eGrammar) const
     206             : {
     207             :     //  ScConditionalFormat = Core-Struktur, muss leer sein
     208             : 
     209             :     OSL_ENSURE( rFormat.IsEmpty(), "FillFormat: Format nicht leer" );
     210             : 
     211           8 :     std::vector<ScTableConditionalEntry*>::const_iterator iter;
     212          10 :     for (iter = aEntries.begin(); iter != aEntries.end(); ++iter)
     213             :     {
     214           2 :         ScCondFormatEntryItem aData;
     215           2 :         (*iter)->GetData(aData);
     216             : 
     217           2 :         FormulaGrammar::Grammar eGrammar1 = lclResolveGrammar( eGrammar, aData.meGrammar1 );
     218           2 :         FormulaGrammar::Grammar eGrammar2 = lclResolveGrammar( eGrammar, aData.meGrammar2 );
     219             : 
     220             :         ScCondFormatEntry* pCoreEntry = new ScCondFormatEntry( aData.meMode, aData.maExpr1, aData.maExpr2,
     221           2 :             pDoc, aData.maPos, aData.maStyle, aData.maExprNmsp1, aData.maExprNmsp2, eGrammar1, eGrammar2 );
     222             : 
     223           2 :         if ( aData.maPosStr.Len() )
     224           0 :             pCoreEntry->SetSrcString( aData.maPosStr );
     225             : 
     226           2 :         if ( aData.maTokens1.getLength() )
     227             :         {
     228           0 :             ScTokenArray aTokenArray;
     229           0 :             if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aData.maTokens1) )
     230           0 :                 pCoreEntry->SetFormula1(aTokenArray);
     231             :         }
     232             : 
     233           2 :         if ( aData.maTokens2.getLength() )
     234             :         {
     235           0 :             ScTokenArray aTokenArray;
     236           0 :             if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aData.maTokens2) )
     237           0 :                 pCoreEntry->SetFormula2(aTokenArray);
     238             :         }
     239           2 :         rFormat.AddEntry( pCoreEntry );
     240           2 :     }
     241           8 : }
     242             : 
     243         216 : ScTableConditionalFormat::~ScTableConditionalFormat()
     244             : {
     245          72 :     std::for_each(aEntries.begin(),aEntries.end(),boost::bind(&ScTableConditionalEntry::release,_1));
     246         144 : }
     247             : 
     248          15 : void ScTableConditionalFormat::AddEntry_Impl(const ScCondFormatEntryItem& aEntry)
     249             : {
     250          15 :     ScTableConditionalEntry* pNew = new ScTableConditionalEntry(aEntry);
     251          15 :     pNew->acquire();
     252          15 :     aEntries.push_back(pNew);
     253          15 : }
     254             : 
     255             : // XSheetConditionalFormat
     256             : 
     257          16 : ScTableConditionalEntry* ScTableConditionalFormat::GetObjectByIndex_Impl(sal_uInt16 nIndex) const
     258             : {
     259          16 :     return nIndex < aEntries.size() ? aEntries[nIndex] : NULL;
     260             : }
     261             : 
     262           7 : void SAL_CALL ScTableConditionalFormat::addNew(
     263             :                     const uno::Sequence<beans::PropertyValue >& aConditionalEntry )
     264             :                     throw(uno::RuntimeException)
     265             : {
     266           7 :     SolarMutexGuard aGuard;
     267          14 :     ScCondFormatEntryItem aEntry;
     268           7 :     aEntry.meMode = SC_COND_NONE;
     269             : 
     270           7 :     const beans::PropertyValue* pPropArray = aConditionalEntry.getConstArray();
     271           7 :     long nPropCount = aConditionalEntry.getLength();
     272          42 :     for (long i = 0; i < nPropCount; i++)
     273             :     {
     274          35 :         const beans::PropertyValue& rProp = pPropArray[i];
     275             : 
     276          35 :         if ( rProp.Name == SC_UNONAME_OPERATOR )
     277             :         {
     278           7 :             sal_Int32 eOper = ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
     279           7 :             aEntry.meMode = ScConditionEntry::GetModeFromApi( eOper );
     280             :         }
     281          28 :         else if ( rProp.Name == SC_UNONAME_FORMULA1 )
     282             :         {
     283           7 :             OUString aStrVal;
     284          14 :             uno::Sequence<sheet::FormulaToken> aTokens;
     285           7 :             if ( rProp.Value >>= aStrVal )
     286           7 :                 aEntry.maExpr1 = aStrVal;
     287           0 :             else if ( rProp.Value >>= aTokens )
     288             :             {
     289           0 :                 aEntry.maExpr1.Erase();
     290           0 :                 aEntry.maTokens1 = aTokens;
     291           7 :             }
     292             :         }
     293          21 :         else if ( rProp.Name == SC_UNONAME_FORMULA2 )
     294             :         {
     295           7 :             OUString aStrVal;
     296          14 :             uno::Sequence<sheet::FormulaToken> aTokens;
     297           7 :             if ( rProp.Value >>= aStrVal )
     298           7 :                 aEntry.maExpr2 = aStrVal;
     299           0 :             else if ( rProp.Value >>= aTokens )
     300             :             {
     301           0 :                 aEntry.maExpr2.Erase();
     302           0 :                 aEntry.maTokens2 = aTokens;
     303           7 :             }
     304             :         }
     305          14 :         else if ( rProp.Name == SC_UNONAME_SOURCEPOS )
     306             :         {
     307           7 :             table::CellAddress aAddress;
     308           7 :             if ( rProp.Value >>= aAddress )
     309           7 :                 aEntry.maPos = ScAddress( (SCCOL)aAddress.Column, (SCROW)aAddress.Row, aAddress.Sheet );
     310             :         }
     311           7 :         else if ( rProp.Name == SC_UNONAME_SOURCESTR )
     312             :         {
     313           0 :             OUString aStrVal;
     314           0 :             if ( rProp.Value >>= aStrVal )
     315           0 :                 aEntry.maPosStr = String( aStrVal );
     316             :         }
     317           7 :         else if ( rProp.Name == SC_UNONAME_STYLENAME )
     318             :         {
     319           7 :             OUString aStrVal;
     320           7 :             if ( rProp.Value >>= aStrVal )
     321          14 :                 aEntry.maStyle = ScStyleNameConversion::ProgrammaticToDisplayName(
     322          14 :                                                 aStrVal, SFX_STYLE_FAMILY_PARA );
     323             :         }
     324           0 :         else if ( rProp.Name == SC_UNONAME_FORMULANMSP1 )
     325             :         {
     326           0 :             OUString aStrVal;
     327           0 :             if ( rProp.Value >>= aStrVal )
     328           0 :                 aEntry.maExprNmsp1 = aStrVal;
     329             :         }
     330           0 :         else if ( rProp.Name == SC_UNONAME_FORMULANMSP2 )
     331             :         {
     332           0 :             OUString aStrVal;
     333           0 :             if ( rProp.Value >>= aStrVal )
     334           0 :                 aEntry.maExprNmsp2 = aStrVal;
     335             :         }
     336           0 :         else if ( rProp.Name == SC_UNONAME_GRAMMAR1 )
     337             :         {
     338           0 :             sal_Int32 nVal = 0;
     339           0 :             if ( rProp.Value >>= nVal )
     340           0 :                 aEntry.meGrammar1 = static_cast< FormulaGrammar::Grammar >( nVal );
     341             :         }
     342           0 :         else if ( rProp.Name == SC_UNONAME_GRAMMAR2 )
     343             :         {
     344           0 :             sal_Int32 nVal = 0;
     345           0 :             if ( rProp.Value >>= nVal )
     346           0 :                 aEntry.meGrammar2 = static_cast< FormulaGrammar::Grammar >( nVal );
     347             :         }
     348             :         else
     349             :         {
     350             :             OSL_FAIL("falsche Property");
     351             :             //! Exception...
     352             :         }
     353             :     }
     354             : 
     355          14 :     AddEntry_Impl(aEntry);
     356           7 : }
     357             : 
     358           1 : void SAL_CALL ScTableConditionalFormat::removeByIndex( sal_Int32 nIndex )
     359             :                                                 throw(uno::RuntimeException)
     360             : {
     361           1 :     SolarMutexGuard aGuard;
     362             : 
     363           1 :     if (nIndex < static_cast<sal_Int32>(aEntries.size()))
     364             :     {
     365           1 :         std::vector<ScTableConditionalEntry*>::iterator iter = aEntries.begin()+nIndex;
     366             : 
     367           1 :         (*iter)->release();
     368           1 :         aEntries.erase(iter);
     369           1 :     }
     370           1 : }
     371             : 
     372           1 : void SAL_CALL ScTableConditionalFormat::clear() throw(uno::RuntimeException)
     373             : {
     374           1 :     SolarMutexGuard aGuard;
     375             :     std::for_each(aEntries.begin(),aEntries.end(),
     376           1 :                   boost::bind(&ScTableConditionalEntry::release,_1));
     377             : 
     378           1 :     aEntries.clear();
     379           1 : }
     380             : 
     381             : // XEnumerationAccess
     382             : 
     383           2 : uno::Reference<container::XEnumeration> SAL_CALL ScTableConditionalFormat::createEnumeration()
     384             :                                                     throw(uno::RuntimeException)
     385             : {
     386           2 :     SolarMutexGuard aGuard;
     387           2 :     return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.TableConditionalEntryEnumeration"));
     388             : }
     389             : 
     390             : // XIndexAccess
     391             : 
     392          22 : sal_Int32 SAL_CALL ScTableConditionalFormat::getCount() throw(uno::RuntimeException)
     393             : {
     394          22 :     SolarMutexGuard aGuard;
     395          22 :     return aEntries.size();
     396             : }
     397             : 
     398          15 : uno::Any SAL_CALL ScTableConditionalFormat::getByIndex( sal_Int32 nIndex )
     399             :                             throw(lang::IndexOutOfBoundsException,
     400             :                                     lang::WrappedTargetException, uno::RuntimeException)
     401             : {
     402          15 :     SolarMutexGuard aGuard;
     403          30 :     uno::Reference<sheet::XSheetConditionalEntry> xEntry(GetObjectByIndex_Impl((sal_uInt16)nIndex));
     404          15 :     if (xEntry.is())
     405          26 :         return uno::makeAny(xEntry);
     406             :     else
     407          17 :         throw lang::IndexOutOfBoundsException();
     408             : }
     409             : 
     410           1 : uno::Type SAL_CALL ScTableConditionalFormat::getElementType() throw(uno::RuntimeException)
     411             : {
     412           1 :     SolarMutexGuard aGuard;
     413           1 :     return getCppuType((uno::Reference<sheet::XSheetConditionalEntry>*)0);
     414             : }
     415             : 
     416           1 : sal_Bool SAL_CALL ScTableConditionalFormat::hasElements() throw(uno::RuntimeException)
     417             : {
     418           1 :     SolarMutexGuard aGuard;
     419           1 :     return ( getCount() != 0 );
     420             : }
     421             : 
     422             : //  conditional format entries have no real names
     423             : //  -> generate name from index
     424             : 
     425           8 : static OUString lcl_GetEntryNameFromIndex( sal_Int32 nIndex )
     426             : {
     427           8 :     OUString aRet( "Entry" );
     428           8 :     aRet += OUString::valueOf( nIndex );
     429           8 :     return aRet;
     430             : }
     431             : 
     432           2 : uno::Any SAL_CALL ScTableConditionalFormat::getByName( const OUString& aName )
     433             :             throw(container::NoSuchElementException,
     434             :                     lang::WrappedTargetException, uno::RuntimeException)
     435             : {
     436           2 :     SolarMutexGuard aGuard;
     437             : 
     438           4 :     uno::Reference<sheet::XSheetConditionalEntry> xEntry;
     439           2 :     long nCount = aEntries.size();
     440           4 :     for (long i=0; i<nCount; i++)
     441           3 :         if ( aName == lcl_GetEntryNameFromIndex(i) )
     442             :         {
     443           1 :             xEntry.set(GetObjectByIndex_Impl((sal_uInt16)i));
     444           1 :             break;
     445             :         }
     446             : 
     447           2 :     if (xEntry.is())
     448           2 :         return uno::makeAny(xEntry);
     449             :     else
     450           3 :         throw container::NoSuchElementException();
     451             : }
     452             : 
     453           1 : uno::Sequence<OUString> SAL_CALL ScTableConditionalFormat::getElementNames()
     454             :                                                     throw(uno::RuntimeException)
     455             : {
     456           1 :     SolarMutexGuard aGuard;
     457             : 
     458           1 :     long nCount = aEntries.size();
     459           1 :     uno::Sequence<OUString> aNames(nCount);
     460           1 :     OUString* pArray = aNames.getArray();
     461           3 :     for (long i=0; i<nCount; i++)
     462           2 :         pArray[i] = lcl_GetEntryNameFromIndex(i);
     463             : 
     464           1 :     return aNames;
     465             : }
     466             : 
     467           2 : sal_Bool SAL_CALL ScTableConditionalFormat::hasByName( const OUString& aName )
     468             :                                                     throw(uno::RuntimeException)
     469             : {
     470           2 :     SolarMutexGuard aGuard;
     471             : 
     472           2 :     long nCount = aEntries.size();
     473           4 :     for (long i=0; i<nCount; i++)
     474           3 :         if ( aName == lcl_GetEntryNameFromIndex(i) )
     475           1 :             return sal_True;
     476             : 
     477           1 :     return false;
     478             : }
     479             : 
     480             : // XUnoTunnel
     481             : 
     482           8 : sal_Int64 SAL_CALL ScTableConditionalFormat::getSomething(
     483             :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
     484             : {
     485          16 :     if ( rId.getLength() == 16 &&
     486           8 :           0 == memcmp( getUnoTunnelId().getConstArray(),
     487          16 :                                     rId.getConstArray(), 16 ) )
     488             :     {
     489           8 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
     490             :     }
     491           0 :     return 0;
     492             : }
     493             : 
     494             : namespace
     495             : {
     496             :     class theScTableConditionalFormatUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableConditionalFormatUnoTunnelId> {};
     497             : }
     498             : 
     499          16 : const uno::Sequence<sal_Int8>& ScTableConditionalFormat::getUnoTunnelId()
     500             : {
     501          16 :     return theScTableConditionalFormatUnoTunnelId::get().getSeq();
     502             : }
     503             : 
     504           8 : ScTableConditionalFormat* ScTableConditionalFormat::getImplementation(
     505             :                                 const uno::Reference<sheet::XSheetConditionalEntries> xObj )
     506             : {
     507           8 :     ScTableConditionalFormat* pRet = NULL;
     508           8 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
     509           8 :     if (xUT.is())
     510           8 :         pRet = reinterpret_cast<ScTableConditionalFormat*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
     511           8 :     return pRet;
     512             : }
     513             : 
     514             : //------------------------------------------------------------------------
     515             : 
     516          15 : ScTableConditionalEntry::ScTableConditionalEntry(const ScCondFormatEntryItem& aItem) :
     517          15 :     aData( aItem )
     518             : {
     519             :     // #i113668# only store the settings, keep no reference to parent object
     520          15 : }
     521             : 
     522          30 : ScTableConditionalEntry::~ScTableConditionalEntry()
     523             : {
     524          30 : }
     525             : 
     526           2 : void ScTableConditionalEntry::GetData(ScCondFormatEntryItem& rData) const
     527             : {
     528           2 :     rData = aData;
     529           2 : }
     530             : 
     531             : // XSheetCondition
     532             : 
     533          10 : sheet::ConditionOperator SAL_CALL ScTableConditionalEntry::getOperator()
     534             :                                                 throw(uno::RuntimeException)
     535             : {
     536          10 :     SolarMutexGuard aGuard;
     537          10 :     return lcl_ConditionModeToOperator( aData.meMode );
     538             : }
     539             : 
     540           1 : void SAL_CALL ScTableConditionalEntry::setOperator( sheet::ConditionOperator nOperator )
     541             :                                                 throw(uno::RuntimeException)
     542             : {
     543           1 :     SolarMutexGuard aGuard;
     544           1 :     aData.meMode = lcl_ConditionOperatorToMode( nOperator );
     545           1 : }
     546             : 
     547           0 : sal_Int32 SAL_CALL ScTableConditionalEntry::getConditionOperator()
     548             :                                                 throw(uno::RuntimeException)
     549             : {
     550           0 :     SolarMutexGuard aGuard;
     551           0 :     return lcl_ConditionModeToOperatorNew( aData.meMode );
     552             : }
     553             : 
     554           0 : void SAL_CALL ScTableConditionalEntry::setConditionOperator( sal_Int32 nOperator )
     555             :                                                 throw(uno::RuntimeException)
     556             : {
     557           0 :     SolarMutexGuard aGuard;
     558           0 :     aData.meMode = ScConditionEntry::GetModeFromApi( nOperator );
     559           0 : }
     560             : 
     561           2 : OUString SAL_CALL ScTableConditionalEntry::getFormula1() throw(uno::RuntimeException)
     562             : {
     563           2 :     SolarMutexGuard aGuard;
     564           2 :     return aData.maExpr1;
     565             : }
     566             : 
     567           1 : void SAL_CALL ScTableConditionalEntry::setFormula1( const OUString& aFormula1 )
     568             :                                                 throw(uno::RuntimeException)
     569             : {
     570           1 :     SolarMutexGuard aGuard;
     571           1 :     aData.maExpr1 = String( aFormula1 );
     572           1 : }
     573             : 
     574           2 : OUString SAL_CALL ScTableConditionalEntry::getFormula2() throw(uno::RuntimeException)
     575             : {
     576           2 :     SolarMutexGuard aGuard;
     577           2 :     return aData.maExpr2;
     578             : }
     579             : 
     580           1 : void SAL_CALL ScTableConditionalEntry::setFormula2( const OUString& aFormula2 )
     581             :                                                 throw(uno::RuntimeException)
     582             : {
     583           1 :     SolarMutexGuard aGuard;
     584           1 :     aData.maExpr2 = String( aFormula2 );
     585           1 : }
     586             : 
     587           2 : table::CellAddress SAL_CALL ScTableConditionalEntry::getSourcePosition() throw(uno::RuntimeException)
     588             : {
     589           2 :     SolarMutexGuard aGuard;
     590           2 :     table::CellAddress aRet;
     591           2 :     aRet.Column = aData.maPos.Col();
     592           2 :     aRet.Row    = aData.maPos.Row();
     593           2 :     aRet.Sheet  = aData.maPos.Tab();
     594           2 :     return aRet;
     595             : }
     596             : 
     597           1 : void SAL_CALL ScTableConditionalEntry::setSourcePosition( const table::CellAddress& aSourcePosition )
     598             :                                             throw(uno::RuntimeException)
     599             : {
     600           1 :     SolarMutexGuard aGuard;
     601           1 :     aData.maPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet );
     602           1 : }
     603             : 
     604             : // XSheetConditionalEntry
     605             : 
     606          10 : OUString SAL_CALL ScTableConditionalEntry::getStyleName() throw(uno::RuntimeException)
     607             : {
     608          10 :     SolarMutexGuard aGuard;
     609          10 :     return ScStyleNameConversion::DisplayToProgrammaticName( aData.maStyle, SFX_STYLE_FAMILY_PARA );
     610             : }
     611             : 
     612           1 : void SAL_CALL ScTableConditionalEntry::setStyleName( const OUString& aStyleName )
     613             :                                             throw(uno::RuntimeException)
     614             : {
     615           1 :     SolarMutexGuard aGuard;
     616           1 :     aData.maStyle = ScStyleNameConversion::ProgrammaticToDisplayName( aStyleName, SFX_STYLE_FAMILY_PARA );
     617           1 : }
     618             : 
     619             : //------------------------------------------------------------------------
     620             : 
     621          75 : ScTableValidationObj::ScTableValidationObj(ScDocument* pDoc, sal_uLong nKey,
     622             :                                             const formula::FormulaGrammar::Grammar eGrammar) :
     623          75 :     aPropSet( lcl_GetValidatePropertyMap() )
     624             : {
     625             :     //  Eintrag aus dem Dokument lesen...
     626             : 
     627          75 :     sal_Bool bFound = false;
     628          75 :     if ( pDoc && nKey )
     629             :     {
     630          48 :         const ScValidationData* pData = pDoc->GetValidationEntry( nKey );
     631          48 :         if (pData)
     632             :         {
     633          48 :             nMode = sal::static_int_cast<sal_uInt16>( pData->GetOperation() );
     634          48 :             aSrcPos = pData->GetValidSrcPos();  // valid pos for expressions
     635          48 :             aExpr1 = pData->GetExpression( aSrcPos, 0, 0, eGrammar );
     636          48 :             aExpr2 = pData->GetExpression( aSrcPos, 1, 0, eGrammar );
     637          48 :             meGrammar1 = meGrammar2 = eGrammar;
     638          48 :             nValMode = sal::static_int_cast<sal_uInt16>( pData->GetDataMode() );
     639          48 :             bIgnoreBlank = pData->IsIgnoreBlank();
     640          48 :             nShowList = pData->GetListType();
     641          48 :             bShowInput = pData->GetInput( aInputTitle, aInputMessage );
     642             :             ScValidErrorStyle eStyle;
     643          48 :             bShowError = pData->GetErrMsg( aErrorTitle, aErrorMessage, eStyle );
     644          48 :             nErrorStyle = sal::static_int_cast<sal_uInt16>( eStyle );
     645             : 
     646             :             // During save to XML, sheet::ValidationType_ANY formulas are not
     647             :             // saved, even if in the list, see
     648             :             // ScMyValidationsContainer::GetCondition(), so shall not mark
     649             :             // anything in use.
     650          48 :             if (nValMode != SC_VALID_ANY && pDoc->IsInExternalReferenceMarking())
     651           0 :                 pData->MarkUsedExternalReferences();
     652             : 
     653          48 :             bFound = sal_True;
     654             :         }
     655             :     }
     656          75 :     if (!bFound)
     657          27 :         ClearData_Impl();       // Defaults
     658          75 : }
     659             : 
     660          16 : ScValidationData* ScTableValidationObj::CreateValidationData( ScDocument* pDoc,
     661             :                                             formula::FormulaGrammar::Grammar eGrammar ) const
     662             : {
     663             :     //  ScValidationData = Core-Struktur
     664             : 
     665          16 :     FormulaGrammar::Grammar eGrammar1 = lclResolveGrammar( eGrammar, meGrammar1 );
     666          16 :     FormulaGrammar::Grammar eGrammar2 = lclResolveGrammar( eGrammar, meGrammar2 );
     667             : 
     668             :     ScValidationData* pRet = new ScValidationData( (ScValidationMode)nValMode,
     669             :                                                    (ScConditionMode)nMode,
     670             :                                                    aExpr1, aExpr2, pDoc, aSrcPos,
     671             :                                                    maExprNmsp1, maExprNmsp2,
     672          16 :                                                    eGrammar1, eGrammar2 );
     673          16 :     pRet->SetIgnoreBlank(bIgnoreBlank);
     674          16 :     pRet->SetListType(nShowList);
     675             : 
     676          16 :     if ( aTokens1.getLength() )
     677             :     {
     678           0 :         ScTokenArray aTokenArray;
     679           0 :         if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aTokens1) )
     680           0 :             pRet->SetFormula1(aTokenArray);
     681             :     }
     682             : 
     683          16 :     if ( aTokens2.getLength() )
     684             :     {
     685           0 :         ScTokenArray aTokenArray;
     686           0 :         if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aTokens2) )
     687           0 :             pRet->SetFormula2(aTokenArray);
     688             :     }
     689             : 
     690             :     // set strings for error / input even if disabled (and disable afterwards)
     691          16 :     pRet->SetInput( aInputTitle, aInputMessage );
     692          16 :     if (!bShowInput)
     693          14 :         pRet->ResetInput();
     694          16 :     pRet->SetError( aErrorTitle, aErrorMessage, (ScValidErrorStyle)nErrorStyle );
     695          16 :     if (!bShowError)
     696          14 :         pRet->ResetError();
     697             : 
     698          16 :     if ( aPosString.Len() )
     699           0 :         pRet->SetSrcString( aPosString );
     700             : 
     701          16 :     return pRet;
     702             : }
     703             : 
     704          27 : void ScTableValidationObj::ClearData_Impl()
     705             : {
     706          27 :     nMode        = SC_COND_NONE;
     707          27 :     nValMode     = SC_VALID_ANY;
     708          27 :     bIgnoreBlank = sal_True;
     709          27 :     nShowList    = sheet::TableValidationVisibility::UNSORTED;
     710          27 :     bShowInput   = false;
     711          27 :     bShowError   = false;
     712          27 :     nErrorStyle  = SC_VALERR_STOP;
     713          27 :     aSrcPos.Set(0,0,0);
     714          27 :     aExpr1.Erase();
     715          27 :     aExpr2.Erase();
     716          27 :     maExprNmsp1.Erase();
     717          27 :     maExprNmsp2.Erase();
     718          27 :     meGrammar1 = meGrammar2 = FormulaGrammar::GRAM_UNSPECIFIED;  // will be overriden when needed
     719          27 :     aInputTitle.Erase();
     720          27 :     aInputMessage.Erase();
     721          27 :     aErrorTitle.Erase();
     722          27 :     aErrorMessage.Erase();
     723          27 : }
     724             : 
     725         150 : ScTableValidationObj::~ScTableValidationObj()
     726             : {
     727         150 : }
     728             : 
     729             : // XSheetCondition
     730             : 
     731           2 : sheet::ConditionOperator SAL_CALL ScTableValidationObj::getOperator()
     732             :                                                 throw(uno::RuntimeException)
     733             : {
     734           2 :     SolarMutexGuard aGuard;
     735           2 :     return lcl_ConditionModeToOperator( (ScConditionMode)nMode );
     736             : }
     737             : 
     738           4 : void SAL_CALL ScTableValidationObj::setOperator( sheet::ConditionOperator nOperator )
     739             :                                                 throw(uno::RuntimeException)
     740             : {
     741           4 :     SolarMutexGuard aGuard;
     742           4 :     nMode = sal::static_int_cast<sal_uInt16>( lcl_ConditionOperatorToMode( nOperator ) );
     743           4 : }
     744             : 
     745           0 : sal_Int32 SAL_CALL ScTableValidationObj::getConditionOperator()
     746             :                                                 throw(uno::RuntimeException)
     747             : {
     748           0 :     SolarMutexGuard aGuard;
     749           0 :     return lcl_ConditionModeToOperatorNew( (ScConditionMode)nMode );
     750             : }
     751             : 
     752           0 : void SAL_CALL ScTableValidationObj::setConditionOperator( sal_Int32 nOperator )
     753             :                                                 throw(uno::RuntimeException)
     754             : {
     755           0 :     SolarMutexGuard aGuard;
     756           0 :     nMode = sal::static_int_cast<sal_uInt16>( ScConditionEntry::GetModeFromApi( nOperator ) );
     757           0 : }
     758             : 
     759           2 : OUString SAL_CALL ScTableValidationObj::getFormula1() throw(uno::RuntimeException)
     760             : {
     761           2 :     SolarMutexGuard aGuard;
     762           2 :     return aExpr1;
     763             : }
     764             : 
     765           4 : void SAL_CALL ScTableValidationObj::setFormula1( const OUString& aFormula1 )
     766             :                                                 throw(uno::RuntimeException)
     767             : {
     768           4 :     SolarMutexGuard aGuard;
     769           4 :     aExpr1 = String( aFormula1 );
     770           4 : }
     771             : 
     772           2 : OUString SAL_CALL ScTableValidationObj::getFormula2() throw(uno::RuntimeException)
     773             : {
     774           2 :     SolarMutexGuard aGuard;
     775           2 :     return aExpr2;
     776             : }
     777             : 
     778           4 : void SAL_CALL ScTableValidationObj::setFormula2( const OUString& aFormula2 )
     779             :                                                 throw(uno::RuntimeException)
     780             : {
     781           4 :     SolarMutexGuard aGuard;
     782           4 :     aExpr2 = String( aFormula2 );
     783           4 : }
     784             : 
     785           2 : table::CellAddress SAL_CALL ScTableValidationObj::getSourcePosition() throw(uno::RuntimeException)
     786             : {
     787           2 :     SolarMutexGuard aGuard;
     788           2 :     table::CellAddress aRet;
     789           2 :     aRet.Column = aSrcPos.Col();
     790           2 :     aRet.Row    = aSrcPos.Row();
     791           2 :     aRet.Sheet  = aSrcPos.Tab();
     792           2 :     return aRet;
     793             : }
     794             : 
     795           1 : void SAL_CALL ScTableValidationObj::setSourcePosition( const table::CellAddress& aSourcePosition )
     796             :                                             throw(uno::RuntimeException)
     797             : {
     798           1 :     SolarMutexGuard aGuard;
     799           1 :     aSrcPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet );
     800           1 : }
     801             : 
     802           0 : uno::Sequence<sheet::FormulaToken> SAL_CALL ScTableValidationObj::getTokens( sal_Int32 nIndex )
     803             :                                             throw(uno::RuntimeException,lang::IndexOutOfBoundsException)
     804             : {
     805           0 :     SolarMutexGuard aGuard;
     806           0 :     if (nIndex >= 2 || nIndex < 0)
     807           0 :         throw lang::IndexOutOfBoundsException();
     808             : 
     809           0 :     return nIndex == 0 ? aTokens1 : aTokens2;
     810             : }
     811             : 
     812           0 : void SAL_CALL ScTableValidationObj::setTokens( sal_Int32 nIndex, const uno::Sequence<sheet::FormulaToken>& aTokens )
     813             :                                             throw(uno::RuntimeException,lang::IndexOutOfBoundsException)
     814             : {
     815           0 :     SolarMutexGuard aGuard;
     816           0 :     if (nIndex >= 2 || nIndex < 0)
     817           0 :         throw lang::IndexOutOfBoundsException();
     818             : 
     819           0 :     if (nIndex == 0)
     820             :     {
     821           0 :         aTokens1 = aTokens;
     822           0 :         aExpr1.Erase();
     823             :     }
     824           0 :     else if (nIndex == 1)
     825             :     {
     826           0 :         aTokens2 = aTokens;
     827           0 :         aExpr2.Erase();
     828           0 :     }
     829           0 : }
     830             : 
     831           0 : sal_Int32 SAL_CALL ScTableValidationObj::getCount() throw(uno::RuntimeException)
     832             : {
     833           0 :     return 2;
     834             : }
     835             : 
     836           1 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableValidationObj::getPropertySetInfo()
     837             :                                                         throw(uno::RuntimeException)
     838             : {
     839           1 :     SolarMutexGuard aGuard;
     840             :     static uno::Reference<beans::XPropertySetInfo> aRef(
     841           1 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
     842           1 :     return aRef;
     843             : }
     844             : 
     845          43 : void SAL_CALL ScTableValidationObj::setPropertyValue(
     846             :                         const OUString& aPropertyName, const uno::Any& aValue )
     847             :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     848             :                         lang::IllegalArgumentException, lang::WrappedTargetException,
     849             :                         uno::RuntimeException)
     850             : {
     851          43 :     SolarMutexGuard aGuard;
     852          86 :     String aString(aPropertyName);
     853             : 
     854          43 :     if ( aString.EqualsAscii( SC_UNONAME_SHOWINP ) )       bShowInput = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     855          39 :     else if ( aString.EqualsAscii( SC_UNONAME_SHOWERR ) )  bShowError = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     856          34 :     else if ( aString.EqualsAscii( SC_UNONAME_IGNOREBL ) ) bIgnoreBlank = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     857          29 :     else if ( aString.EqualsAscii( SC_UNONAME_SHOWLIST ) ) aValue >>= nShowList;
     858          27 :     else if ( aString.EqualsAscii( SC_UNONAME_INPTITLE ) )
     859             :     {
     860           3 :         OUString aStrVal;
     861           3 :         if ( aValue >>= aStrVal )
     862           3 :             aInputTitle = String( aStrVal );
     863             :     }
     864          24 :     else if ( aString.EqualsAscii( SC_UNONAME_INPMESS ) )
     865             :     {
     866           5 :         OUString aStrVal;
     867           5 :         if ( aValue >>= aStrVal )
     868           5 :             aInputMessage = String( aStrVal );
     869             :     }
     870          19 :     else if ( aString.EqualsAscii( SC_UNONAME_ERRTITLE ) )
     871             :     {
     872           5 :         OUString aStrVal;
     873           5 :         if ( aValue >>= aStrVal )
     874           5 :             aErrorTitle = String( aStrVal );
     875             :     }
     876          14 :     else if ( aString.EqualsAscii( SC_UNONAME_ERRMESS ) )
     877             :     {
     878           4 :         OUString aStrVal;
     879           4 :         if ( aValue >>= aStrVal )
     880           4 :             aErrorMessage = String( aStrVal );
     881             :     }
     882          10 :     else if ( aString.EqualsAscii( SC_UNONAME_TYPE ) )
     883             :     {
     884             :         sheet::ValidationType eType = (sheet::ValidationType)
     885           5 :                                 ScUnoHelpFunctions::GetEnumFromAny( aValue );
     886           5 :         switch (eType)
     887             :         {
     888           2 :             case sheet::ValidationType_ANY:      nValMode = SC_VALID_ANY;     break;
     889           1 :             case sheet::ValidationType_WHOLE:    nValMode = SC_VALID_WHOLE;   break;
     890           0 :             case sheet::ValidationType_DECIMAL:  nValMode = SC_VALID_DECIMAL; break;
     891           1 :             case sheet::ValidationType_DATE:     nValMode = SC_VALID_DATE;    break;
     892           0 :             case sheet::ValidationType_TIME:     nValMode = SC_VALID_TIME;    break;
     893           0 :             case sheet::ValidationType_TEXT_LEN: nValMode = SC_VALID_TEXTLEN; break;
     894           0 :             case sheet::ValidationType_LIST:     nValMode = SC_VALID_LIST;    break;
     895           1 :             case sheet::ValidationType_CUSTOM:   nValMode = SC_VALID_CUSTOM;  break;
     896             :             default:
     897             :             {
     898             :                 // added to avoid warnings
     899             :             }
     900             :         }
     901             :     }
     902           5 :     else if ( aString.EqualsAscii( SC_UNONAME_ERRALSTY ) )
     903             :     {
     904             :         sheet::ValidationAlertStyle eStyle = (sheet::ValidationAlertStyle)
     905           5 :                                 ScUnoHelpFunctions::GetEnumFromAny( aValue );
     906           5 :         switch (eStyle)
     907             :         {
     908           3 :             case sheet::ValidationAlertStyle_STOP:    nErrorStyle = SC_VALERR_STOP;    break;
     909           1 :             case sheet::ValidationAlertStyle_WARNING: nErrorStyle = SC_VALERR_WARNING; break;
     910           1 :             case sheet::ValidationAlertStyle_INFO:    nErrorStyle = SC_VALERR_INFO;    break;
     911           0 :             case sheet::ValidationAlertStyle_MACRO:   nErrorStyle = SC_VALERR_MACRO;   break;
     912             :             default:
     913             :             {
     914             :                 // added to avoid warnings
     915             :             }
     916             :         }
     917             :     }
     918           0 :     else if ( aString.EqualsAscii( SC_UNONAME_SOURCESTR ) )
     919             :     {
     920             :         // internal - only for XML filter, not in PropertySetInfo, only set
     921             : 
     922           0 :         OUString aStrVal;
     923           0 :         if ( aValue >>= aStrVal )
     924           0 :             aPosString = String( aStrVal );
     925             :     }
     926           0 :     else if ( aString.EqualsAscii( SC_UNONAME_FORMULANMSP1 ) )
     927             :     {
     928             :         // internal - only for XML filter, not in PropertySetInfo, only set
     929             : 
     930           0 :         OUString aStrVal;
     931           0 :         if ( aValue >>= aStrVal )
     932           0 :             maExprNmsp1 = aStrVal;
     933             :     }
     934           0 :     else if ( aString.EqualsAscii( SC_UNONAME_FORMULANMSP2 ) )
     935             :     {
     936             :         // internal - only for XML filter, not in PropertySetInfo, only set
     937             : 
     938           0 :         OUString aStrVal;
     939           0 :         if ( aValue >>= aStrVal )
     940           0 :             maExprNmsp2 = aStrVal;
     941             :     }
     942           0 :     else if ( aString.EqualsAscii( SC_UNONAME_GRAMMAR1 ) )
     943             :     {
     944             :         // internal - only for XML filter, not in PropertySetInfo, only set
     945             : 
     946           0 :         sal_Int32 nVal = 0;
     947           0 :         if ( aValue >>= nVal )
     948           0 :             meGrammar1 = static_cast< FormulaGrammar::Grammar >(nVal);
     949             :     }
     950           0 :     else if ( aString.EqualsAscii( SC_UNONAME_GRAMMAR2 ) )
     951             :     {
     952             :         // internal - only for XML filter, not in PropertySetInfo, only set
     953             : 
     954           0 :         sal_Int32 nVal = 0;
     955           0 :         if ( aValue >>= nVal )
     956           0 :             meGrammar2 = static_cast< FormulaGrammar::Grammar >(nVal);
     957          43 :     }
     958          43 : }
     959             : 
     960          61 : uno::Any SAL_CALL ScTableValidationObj::getPropertyValue( const OUString& aPropertyName )
     961             :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     962             :                         uno::RuntimeException)
     963             : {
     964          61 :     SolarMutexGuard aGuard;
     965         122 :     String aString(aPropertyName);
     966          61 :     uno::Any aRet;
     967             : 
     968          61 :     if ( aString.EqualsAscii( SC_UNONAME_SHOWINP ) )       ScUnoHelpFunctions::SetBoolInAny( aRet, bShowInput );
     969          56 :     else if ( aString.EqualsAscii( SC_UNONAME_SHOWERR ) )  ScUnoHelpFunctions::SetBoolInAny( aRet, bShowError );
     970          51 :     else if ( aString.EqualsAscii( SC_UNONAME_IGNOREBL ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, bIgnoreBlank );
     971          46 :     else if ( aString.EqualsAscii( SC_UNONAME_SHOWLIST ) ) aRet <<= nShowList;
     972          41 :     else if ( aString.EqualsAscii( SC_UNONAME_INPTITLE ) ) aRet <<= OUString( aInputTitle );
     973          34 :     else if ( aString.EqualsAscii( SC_UNONAME_INPMESS ) )  aRet <<= OUString( aInputMessage );
     974          27 :     else if ( aString.EqualsAscii( SC_UNONAME_ERRTITLE ) ) aRet <<= OUString( aErrorTitle );
     975          20 :     else if ( aString.EqualsAscii( SC_UNONAME_ERRMESS ) )  aRet <<= OUString( aErrorMessage );
     976          11 :     else if ( aString.EqualsAscii( SC_UNONAME_TYPE ) )
     977             :     {
     978           6 :         sheet::ValidationType eType = sheet::ValidationType_ANY;
     979           6 :         switch (nValMode)
     980             :         {
     981           2 :             case SC_VALID_ANY:      eType = sheet::ValidationType_ANY;      break;
     982           0 :             case SC_VALID_WHOLE:    eType = sheet::ValidationType_WHOLE;    break;
     983           0 :             case SC_VALID_DECIMAL:  eType = sheet::ValidationType_DECIMAL;  break;
     984           2 :             case SC_VALID_DATE:     eType = sheet::ValidationType_DATE;     break;
     985           0 :             case SC_VALID_TIME:     eType = sheet::ValidationType_TIME;     break;
     986           0 :             case SC_VALID_TEXTLEN:  eType = sheet::ValidationType_TEXT_LEN; break;
     987           0 :             case SC_VALID_LIST:     eType = sheet::ValidationType_LIST;     break;
     988           2 :             case SC_VALID_CUSTOM:   eType = sheet::ValidationType_CUSTOM;   break;
     989             :         }
     990           6 :         aRet <<= eType;
     991             :     }
     992           5 :     else if ( aString.EqualsAscii( SC_UNONAME_ERRALSTY ) )
     993             :     {
     994           5 :         sheet::ValidationAlertStyle eStyle = sheet::ValidationAlertStyle_STOP;
     995           5 :         switch (nErrorStyle)
     996             :         {
     997           1 :             case SC_VALERR_STOP:    eStyle = sheet::ValidationAlertStyle_STOP;    break;
     998           2 :             case SC_VALERR_WARNING: eStyle = sheet::ValidationAlertStyle_WARNING; break;
     999           2 :             case SC_VALERR_INFO:    eStyle = sheet::ValidationAlertStyle_INFO;    break;
    1000           0 :             case SC_VALERR_MACRO:   eStyle = sheet::ValidationAlertStyle_MACRO;   break;
    1001             :         }
    1002           5 :         aRet <<= eStyle;
    1003             :     }
    1004             : 
    1005         122 :     return aRet;
    1006             : }
    1007             : 
    1008           0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableValidationObj )
    1009             : 
    1010             : // XUnoTunnel
    1011             : 
    1012          16 : sal_Int64 SAL_CALL ScTableValidationObj::getSomething(
    1013             :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
    1014             : {
    1015          32 :     if ( rId.getLength() == 16 &&
    1016          16 :           0 == memcmp( getUnoTunnelId().getConstArray(),
    1017          32 :                                     rId.getConstArray(), 16 ) )
    1018             :     {
    1019          16 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
    1020             :     }
    1021           0 :     return 0;
    1022             : }
    1023             : 
    1024             : namespace
    1025             : {
    1026             :     class theScTableValidationObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableValidationObjUnoTunnelId> {};
    1027             : }
    1028             : 
    1029          32 : const uno::Sequence<sal_Int8>& ScTableValidationObj::getUnoTunnelId()
    1030             : {
    1031          32 :     return theScTableValidationObjUnoTunnelId::get().getSeq();
    1032             : }
    1033             : 
    1034          16 : ScTableValidationObj* ScTableValidationObj::getImplementation(
    1035             :                                 const uno::Reference<beans::XPropertySet> xObj )
    1036             : {
    1037          16 :     ScTableValidationObj* pRet = NULL;
    1038          16 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
    1039          16 :     if (xUT.is())
    1040          16 :         pRet = reinterpret_cast<ScTableValidationObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
    1041          16 :     return pRet;
    1042          93 : }
    1043             : 
    1044             : //------------------------------------------------------------------------
    1045             : 
    1046             : 
    1047             : 
    1048             : 
    1049             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10