1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_FMTUNO_HXX 29 #define SC_FMTUNO_HXX 30 31 #include "address.hxx" 32 #include "conditio.hxx" 33 #include <formula/grammar.hxx> 34 #include <tools/list.hxx> 35 #include <svl/itemprop.hxx> 36 #include <com/sun/star/sheet/XSheetConditionalEntries.hpp> 37 #include <com/sun/star/sheet/XSheetCondition.hpp> 38 #include <com/sun/star/sheet/XSheetConditionalEntry.hpp> 39 #include <com/sun/star/lang/XServiceInfo.hpp> 40 #include <com/sun/star/container/XNameAccess.hpp> 41 #include <com/sun/star/container/XEnumerationAccess.hpp> 42 #include <com/sun/star/lang/XUnoTunnel.hpp> 43 #include <com/sun/star/beans/XPropertySet.hpp> 44 45 #include <com/sun/star/sheet/XMultiFormulaTokens.hpp> 46 #include <com/sun/star/sheet/FormulaToken.hpp> 47 #include <cppuhelper/implbase3.hxx> 48 #include <cppuhelper/implbase4.hxx> 49 #include <cppuhelper/implbase5.hxx> 50 51 52 class ScDocument; 53 class ScTableConditionalEntry; 54 class ScConditionalFormat; 55 class ScValidationData; 56 57 58 struct ScCondFormatEntryItem 59 { 60 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > maTokens1; 61 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > maTokens2; 62 String maExpr1; 63 String maExpr2; 64 String maExprNmsp1; 65 String maExprNmsp2; 66 String maPosStr; // formula position as text 67 String maStyle; // display name as stored in ScStyleSheet 68 ScAddress maPos; 69 formula::FormulaGrammar::Grammar meGrammar1; // grammar used with maExpr1 70 formula::FormulaGrammar::Grammar meGrammar2; // grammar used with maExpr2 71 ScConditionMode meMode; 72 73 // Make sure the grammar is initialized for API calls. 74 ScCondFormatEntryItem(); 75 }; 76 77 class ScTableConditionalFormat : public cppu::WeakImplHelper5< 78 com::sun::star::sheet::XSheetConditionalEntries, 79 com::sun::star::container::XNameAccess, 80 com::sun::star::container::XEnumerationAccess, 81 com::sun::star::lang::XUnoTunnel, 82 com::sun::star::lang::XServiceInfo > 83 { 84 private: 85 List aEntries; 86 87 ScTableConditionalEntry* GetObjectByIndex_Impl(sal_uInt16 nIndex) const; 88 void AddEntry_Impl(const ScCondFormatEntryItem& aEntry); 89 90 ScTableConditionalFormat(); // disable 91 public: 92 ScTableConditionalFormat(ScDocument* pDoc, sal_uLong nKey, 93 formula::FormulaGrammar::Grammar eGrammar); 94 virtual ~ScTableConditionalFormat(); 95 96 void FillFormat( ScConditionalFormat& rFormat, ScDocument* pDoc, 97 formula::FormulaGrammar::Grammar eGrammar) const; 98 99 // XSheetConditionalEntries 100 virtual void SAL_CALL addNew( const ::com::sun::star::uno::Sequence< 101 ::com::sun::star::beans::PropertyValue >& aConditionalEntry ) 102 throw(::com::sun::star::uno::RuntimeException); 103 virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) 104 throw(::com::sun::star::uno::RuntimeException); 105 virtual void SAL_CALL clear() throw(::com::sun::star::uno::RuntimeException); 106 107 // XIndexAccess 108 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); 109 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) 110 throw(::com::sun::star::lang::IndexOutOfBoundsException, 111 ::com::sun::star::lang::WrappedTargetException, 112 ::com::sun::star::uno::RuntimeException); 113 114 // XNameAccess 115 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) 116 throw(::com::sun::star::container::NoSuchElementException, 117 ::com::sun::star::lang::WrappedTargetException, 118 ::com::sun::star::uno::RuntimeException); 119 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 120 throw(::com::sun::star::uno::RuntimeException); 121 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) 122 throw(::com::sun::star::uno::RuntimeException); 123 124 // XEnumerationAccess 125 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL 126 createEnumeration() throw(::com::sun::star::uno::RuntimeException); 127 128 // XElementAccess 129 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 130 throw(::com::sun::star::uno::RuntimeException); 131 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); 132 133 // XUnoTunnel 134 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< 135 sal_Int8 >& aIdentifier ) 136 throw(::com::sun::star::uno::RuntimeException); 137 138 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); 139 static ScTableConditionalFormat* getImplementation( const com::sun::star::uno::Reference< 140 com::sun::star::sheet::XSheetConditionalEntries> xObj ); 141 142 // XServiceInfo 143 virtual ::rtl::OUString SAL_CALL getImplementationName() 144 throw(::com::sun::star::uno::RuntimeException); 145 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 146 throw(::com::sun::star::uno::RuntimeException); 147 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 148 throw(::com::sun::star::uno::RuntimeException); 149 }; 150 151 152 153 class ScTableConditionalEntry : public cppu::WeakImplHelper3< 154 com::sun::star::sheet::XSheetCondition, 155 com::sun::star::sheet::XSheetConditionalEntry, 156 com::sun::star::lang::XServiceInfo > 157 { 158 private: 159 ScCondFormatEntryItem aData; 160 161 ScTableConditionalEntry(); // disabled 162 public: 163 ScTableConditionalEntry(const ScCondFormatEntryItem& aItem); 164 virtual ~ScTableConditionalEntry(); 165 166 void GetData(ScCondFormatEntryItem& rData) const; 167 168 // XSheetCondition 169 virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator() 170 throw(::com::sun::star::uno::RuntimeException); 171 virtual void SAL_CALL setOperator( ::com::sun::star::sheet::ConditionOperator nOperator ) 172 throw(::com::sun::star::uno::RuntimeException); 173 virtual ::rtl::OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException); 174 virtual void SAL_CALL setFormula1( const ::rtl::OUString& aFormula1 ) 175 throw(::com::sun::star::uno::RuntimeException); 176 virtual ::rtl::OUString SAL_CALL getFormula2() throw(::com::sun::star::uno::RuntimeException); 177 virtual void SAL_CALL setFormula2( const ::rtl::OUString& aFormula2 ) 178 throw(::com::sun::star::uno::RuntimeException); 179 virtual ::com::sun::star::table::CellAddress SAL_CALL getSourcePosition() 180 throw(::com::sun::star::uno::RuntimeException); 181 virtual void SAL_CALL setSourcePosition( const ::com::sun::star::table::CellAddress& aSourcePosition ) 182 throw(::com::sun::star::uno::RuntimeException); 183 184 // XSheetConditionalEntry 185 virtual ::rtl::OUString SAL_CALL getStyleName() throw(::com::sun::star::uno::RuntimeException); 186 virtual void SAL_CALL setStyleName( const ::rtl::OUString& aStyleName ) 187 throw(::com::sun::star::uno::RuntimeException); 188 189 // XServiceInfo 190 virtual ::rtl::OUString SAL_CALL getImplementationName() 191 throw(::com::sun::star::uno::RuntimeException); 192 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 193 throw(::com::sun::star::uno::RuntimeException); 194 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 195 throw(::com::sun::star::uno::RuntimeException); 196 }; 197 198 199 200 class ScTableValidationObj : public cppu::WeakImplHelper5< 201 com::sun::star::sheet::XSheetCondition, 202 com::sun::star::sheet::XMultiFormulaTokens, 203 com::sun::star::beans::XPropertySet, 204 com::sun::star::lang::XUnoTunnel, 205 com::sun::star::lang::XServiceInfo > 206 { 207 private: 208 SfxItemPropertySet aPropSet; 209 sal_uInt16 nMode; // enum ScConditionMode 210 String aExpr1; 211 String aExpr2; 212 String maExprNmsp1; 213 String maExprNmsp2; 214 formula::FormulaGrammar::Grammar meGrammar1; // grammar used with aExpr1 and aExpr2 215 formula::FormulaGrammar::Grammar meGrammar2; // grammar used with aExpr1 and aExpr2 216 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens1; 217 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > aTokens2; 218 ScAddress aSrcPos; 219 String aPosString; // formula position as text 220 sal_uInt16 nValMode; // enum ScValidationMode 221 sal_Bool bIgnoreBlank; 222 sal_Int16 nShowList; 223 sal_Bool bShowInput; 224 String aInputTitle; 225 String aInputMessage; 226 sal_Bool bShowError; 227 sal_uInt16 nErrorStyle; // enum ScValidErrorStyle 228 String aErrorTitle; 229 String aErrorMessage; 230 231 void ClearData_Impl(); 232 233 ScTableValidationObj(); // disabled 234 public: 235 ScTableValidationObj(ScDocument* pDoc, sal_uLong nKey, 236 const formula::FormulaGrammar::Grammar eGrammar); 237 virtual ~ScTableValidationObj(); 238 239 ScValidationData* CreateValidationData( ScDocument* pDoc, 240 formula::FormulaGrammar::Grammar eGrammar ) const; 241 242 // XSheetCondition 243 virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator() 244 throw(::com::sun::star::uno::RuntimeException); 245 virtual void SAL_CALL setOperator( ::com::sun::star::sheet::ConditionOperator nOperator ) 246 throw(::com::sun::star::uno::RuntimeException); 247 virtual ::rtl::OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException); 248 virtual void SAL_CALL setFormula1( const ::rtl::OUString& aFormula1 ) 249 throw(::com::sun::star::uno::RuntimeException); 250 virtual ::rtl::OUString SAL_CALL getFormula2() throw(::com::sun::star::uno::RuntimeException); 251 virtual void SAL_CALL setFormula2( const ::rtl::OUString& aFormula2 ) 252 throw(::com::sun::star::uno::RuntimeException); 253 virtual ::com::sun::star::table::CellAddress SAL_CALL getSourcePosition() 254 throw(::com::sun::star::uno::RuntimeException); 255 virtual void SAL_CALL setSourcePosition( const ::com::sun::star::table::CellAddress& aSourcePosition ) 256 throw(::com::sun::star::uno::RuntimeException); 257 258 // XMultiFormulaTokens 259 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > 260 SAL_CALL getTokens( sal_Int32 nIndex ) 261 throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IndexOutOfBoundsException); 262 virtual void SAL_CALL setTokens( sal_Int32 nIndex, 263 const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& aTokens ) 264 throw(::com::sun::star::uno::RuntimeException,::com::sun::star::lang::IndexOutOfBoundsException); 265 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); 266 267 // XPropertySet 268 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 269 SAL_CALL getPropertySetInfo() 270 throw(::com::sun::star::uno::RuntimeException); 271 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, 272 const ::com::sun::star::uno::Any& aValue ) 273 throw(::com::sun::star::beans::UnknownPropertyException, 274 ::com::sun::star::beans::PropertyVetoException, 275 ::com::sun::star::lang::IllegalArgumentException, 276 ::com::sun::star::lang::WrappedTargetException, 277 ::com::sun::star::uno::RuntimeException); 278 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 279 const ::rtl::OUString& PropertyName ) 280 throw(::com::sun::star::beans::UnknownPropertyException, 281 ::com::sun::star::lang::WrappedTargetException, 282 ::com::sun::star::uno::RuntimeException); 283 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, 284 const ::com::sun::star::uno::Reference< 285 ::com::sun::star::beans::XPropertyChangeListener >& xListener ) 286 throw(::com::sun::star::beans::UnknownPropertyException, 287 ::com::sun::star::lang::WrappedTargetException, 288 ::com::sun::star::uno::RuntimeException); 289 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, 290 const ::com::sun::star::uno::Reference< 291 ::com::sun::star::beans::XPropertyChangeListener >& aListener ) 292 throw(::com::sun::star::beans::UnknownPropertyException, 293 ::com::sun::star::lang::WrappedTargetException, 294 ::com::sun::star::uno::RuntimeException); 295 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, 296 const ::com::sun::star::uno::Reference< 297 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 298 throw(::com::sun::star::beans::UnknownPropertyException, 299 ::com::sun::star::lang::WrappedTargetException, 300 ::com::sun::star::uno::RuntimeException); 301 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, 302 const ::com::sun::star::uno::Reference< 303 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 304 throw(::com::sun::star::beans::UnknownPropertyException, 305 ::com::sun::star::lang::WrappedTargetException, 306 ::com::sun::star::uno::RuntimeException); 307 308 // XUnoTunnel 309 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< 310 sal_Int8 >& aIdentifier ) 311 throw(::com::sun::star::uno::RuntimeException); 312 313 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); 314 static ScTableValidationObj* getImplementation( const com::sun::star::uno::Reference< 315 com::sun::star::beans::XPropertySet> xObj ); 316 317 // XServiceInfo 318 virtual ::rtl::OUString SAL_CALL getImplementationName() 319 throw(::com::sun::star::uno::RuntimeException); 320 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 321 throw(::com::sun::star::uno::RuntimeException); 322 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 323 throw(::com::sun::star::uno::RuntimeException); 324 }; 325 326 327 #endif 328 329