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