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