xref: /trunk/main/sc/inc/cellsuno.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_CELLSUNO_HXX
25 #define SC_CELLSUNO_HXX
26 
27 #include "global.hxx"           // ScRange, ScAddress
28 #include "rangelst.hxx"         // ScRangeList
29 
30 #include "formula/grammar.hxx"
31 #include <svl/lstner.hxx>
32 #include <svl/listener.hxx>
33 #include <svl/itemprop.hxx>
34 #include <com/sun/star/table/XTableChartsSupplier.hpp>
35 #include <com/sun/star/chart/XChartDataArray.hpp>
36 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
37 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
38 #include <com/sun/star/sheet/XSheetCellRange.hpp>
39 #include <com/sun/star/sheet/XFormulaQuery.hpp>
40 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
41 #include <com/sun/star/sheet/XSheetOperation.hpp>
42 #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
43 #include <com/sun/star/sheet/XCellFormatRangesSupplier.hpp>
44 #include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp>
45 #include <com/sun/star/sheet/XCellRangesQuery.hpp>
46 #include <com/sun/star/sheet/XSheetFilterableEx.hpp>
47 #include <com/sun/star/sheet/XSpreadsheet.hpp>
48 #include <com/sun/star/sheet/XSheetPageBreak.hpp>
49 #include <com/sun/star/sheet/XCellRangeMovement.hpp>
50 #include <com/sun/star/text/XText.hpp>
51 #include <com/sun/star/sheet/XPrintAreas.hpp>
52 #include <com/sun/star/sheet/XSheetLinkable.hpp>
53 #include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
54 #include <com/sun/star/sheet/XArrayFormulaRange.hpp>
55 #include <com/sun/star/sheet/XCellRangeData.hpp>
56 #include <com/sun/star/sheet/XCellRangeFormula.hpp>
57 #include <com/sun/star/sheet/XCellSeries.hpp>
58 #include <com/sun/star/sheet/XMultipleOperation.hpp>
59 #include <com/sun/star/sheet/XFormulaTokens.hpp>
60 #include <com/sun/star/sheet/XArrayFormulaTokens.hpp>
61 #include <com/sun/star/sheet/XCellAddressable.hpp>
62 #include <com/sun/star/util/XReplaceable.hpp>
63 #include <com/sun/star/util/XIndent.hpp>
64 #include <com/sun/star/lang/XServiceInfo.hpp>
65 #include <com/sun/star/container/XNameContainer.hpp>
66 #include <com/sun/star/util/XMergeable.hpp>
67 #include <com/sun/star/table/XAutoFormattable.hpp>
68 #include <com/sun/star/util/XSortable.hpp>
69 #include <com/sun/star/util/XImportable.hpp>
70 #include <com/sun/star/table/XColumnRowRange.hpp>
71 #include <com/sun/star/table/BorderLine.hpp>
72 #include <com/sun/star/table/TableBorder.hpp>
73 #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
74 #include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
75 #include <com/sun/star/sheet/XScenariosSupplier.hpp>
76 #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
77 #include <com/sun/star/sheet/XSheetAuditing.hpp>
78 #include <com/sun/star/sheet/XSheetOutline.hpp>
79 #include <com/sun/star/util/XProtectable.hpp>
80 #include <com/sun/star/sheet/XScenario.hpp>
81 #include <com/sun/star/sheet/XScenarioEnhanced.hpp>
82 #include <com/sun/star/util/XModifyBroadcaster.hpp>
83 #include <com/sun/star/beans/XPropertyState.hpp>
84 #include <com/sun/star/beans/XMultiPropertySet.hpp>
85 #include <com/sun/star/lang/XUnoTunnel.hpp>
86 #include <com/sun/star/document/XActionLockable.hpp>
87 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
88 #include <com/sun/star/sheet/XExternalSheetName.hpp>
89 #include <com/sun/star/document/XEventsSupplier.hpp>
90 #include <cppuhelper/implbase2.hxx>
91 #include <cppuhelper/implbase3.hxx>
92 
93 #ifndef __SGI_STL_VECTOR
94 #include <vector>
95 #endif
96 
97 class ScDocShell;
98 class ScMarkData;
99 class ScMemChart;
100 class ScPrintRangeSaver;
101 class ScAttrRectIterator;
102 class ScCellRangeObj;
103 class SvxUnoText;
104 class ScLinkListener;
105 class ScPatternAttr;
106 class SvxBorderLine;
107 class SvxBoxItem;
108 class SvxBoxInfoItem;
109 class SvxItemPropertySet;
110 
111 class ScLinkListener : public SvtListener
112 {
113     Link    aLink;
114 public:
ScLinkListener(const Link & rL)115                     ScLinkListener(const Link& rL) : aLink(rL) {}
116     virtual         ~ScLinkListener();
117     virtual void    Notify( SvtBroadcaster& rBC, const SfxHint& rHint );
118 };
119 
120 typedef ::com::sun::star::uno::Reference<
121             ::com::sun::star::util::XModifyListener >* XModifyListenerPtr;
122 SV_DECL_PTRARR_DEL( XModifyListenerArr_Impl, XModifyListenerPtr, 4, 4 )
123 
124 class ScNamedEntry;
125 typedef ScNamedEntry* ScNamedEntryPtr;
126 SV_DECL_PTRARR_DEL( ScNamedEntryArr_Impl, ScNamedEntryPtr, 4, 4 )
127 
128 
129 //  ScCellRangesBase - Basisklasse fuer ScCellRangesObj (mit Index-Access)
130 //                                  und ScCellRangeObj (ohne Index-Access)
131 
132 //  XServiceInfo ist in den Ableitungen implementiert
133 
134 class ScHelperFunctions
135 {
136 public:
137     static const SvxBorderLine* GetBorderLine( SvxBorderLine& rLine, const com::sun::star::table::BorderLine& rStruct );
138     static void FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const com::sun::star::table::TableBorder& rBorder );
139     static void FillBorderLine( com::sun::star::table::BorderLine& rStruct, const SvxBorderLine* pLine );
140     static void FillTableBorder( com::sun::star::table::TableBorder& rBorder,
141                             const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner );
142     static void ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
143                         const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner );
144 };
145 
146 namespace ooo
147 {
148     namespace vba {
149         namespace excel {
150     class ScVbaCellRangeAccess;  // Vba Helper class
151     }
152     }
153 }
154 
155 class SC_DLLPUBLIC ScCellRangesBase : public com::sun::star::beans::XPropertySet,
156                          public com::sun::star::beans::XMultiPropertySet,
157                          public com::sun::star::beans::XPropertyState,
158                          public com::sun::star::sheet::XSheetOperation,
159                          public com::sun::star::chart::XChartDataArray,
160                          public com::sun::star::util::XIndent,
161                          public com::sun::star::sheet::XCellRangesQuery,
162                          public com::sun::star::sheet::XFormulaQuery,
163                          public com::sun::star::util::XReplaceable,
164                          public com::sun::star::util::XModifyBroadcaster,
165                          public com::sun::star::lang::XServiceInfo,
166                          public com::sun::star::lang::XUnoTunnel,
167                          public com::sun::star::lang::XTypeProvider,
168                          public com::sun::star::beans::XTolerantMultiPropertySet,
169                          public cppu::OWeakObject,
170                          public SfxListener
171 {
172     friend class ScTabViewObj;      // fuer select()
173     friend class ScTableSheetObj;   // fuer createCursorByRange()
174     friend class ooo::vba::excel::ScVbaCellRangeAccess;
175 
176 private:
177     const SfxItemPropertySet* pPropSet;
178     ScDocShell*             pDocShell;
179     ScLinkListener*         pValueListener;
180     ScPatternAttr*          pCurrentFlat;
181     ScPatternAttr*          pCurrentDeep;
182     SfxItemSet*             pCurrentDataSet;
183     SfxItemSet*             pNoDfltCurrentDataSet;
184     ScMarkData*             pMarkData;
185     ScRangeList             aRanges;
186     sal_Int64               nObjectId;
187     sal_Bool                    bChartColAsHdr;
188     sal_Bool                    bChartRowAsHdr;
189     sal_Bool                    bCursorOnly;
190     sal_Bool                    bGotDataChangedHint;
191     XModifyListenerArr_Impl aValueListeners;
192 
193     DECL_LINK( ValueListenerHdl, SfxHint* );
194 
195 private:
196     void            PaintRanges_Impl( sal_uInt16 nPart );
197     ScRangeListRef  GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const;
198     void            ForceChartListener_Impl();
199     ScMemChart*     CreateMemChart_Impl() const;
200 
201     const ScPatternAttr*    GetCurrentAttrsFlat();
202     const ScPatternAttr*    GetCurrentAttrsDeep();
203     SfxItemSet*             GetCurrentDataSet(bool bNoDflt = false);
204     void                    ForgetMarkData();
205     void                    ForgetCurrentAttrs();
206 
207     com::sun::star::uno::Reference<com::sun::star::sheet::XSheetCellRanges>
208                             QueryDifferences_Impl(const com::sun::star::table::CellAddress& aCompare,
209                                                     sal_Bool bColumnDiff);
210     com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
211                             Find_Impl(const com::sun::star::uno::Reference<
212                                         com::sun::star::util::XSearchDescriptor>& xDesc,
213                                     const ScAddress* pLastPos);
214 
215 protected:
216     const ScMarkData*       GetMarkData();
217 
218     // GetItemPropertyMap for derived classes must contain all entries, including base class
219     virtual const SfxItemPropertyMap* GetItemPropertyMap();
220     virtual ::com::sun::star::beans::PropertyState GetOnePropertyState(
221                                 sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry );
222     virtual void            GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
223                                 ::com::sun::star::uno::Any& );
224     virtual void            SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
225                                                 const ::com::sun::star::uno::Any& aValue );
226 
227 public:
228                             ScCellRangesBase();     // fuer SMART_REFLECTION Krempel
229                             ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR);
230                             ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR);
231     virtual                 ~ScCellRangesBase();
232 
233     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
234                                 const ::com::sun::star::uno::Type & rType );
235     virtual void SAL_CALL   acquire() throw();
236     virtual void SAL_CALL   release() throw();
237 
238     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
239     virtual void            RefChanged();
240 
241                             // aus Ableitungen, aber auch per getImplementation
GetDocShell() const242     ScDocShell*             GetDocShell() const     { return pDocShell; }
243     ScDocument*             GetDocument() const;
GetRangeList() const244     const ScRangeList&      GetRangeList() const    { return aRanges; }
245     void                    AddRange(const ScRange& rRange, const sal_Bool bMergeRanges);
246 
247                             // per Service erzeugtes Objekt zum Leben erwecken:
248     void                    InitInsertRange(ScDocShell* pDocSh, const ScRange& rR);
249 
250     void                    SetNewRange(const ScRange& rNew);   // fuer Cursor
251     void                    SetNewRanges(const ScRangeList& rNew);
252 
253     void                    SetCursorOnly(sal_Bool bSet);
IsCursorOnly() const254     sal_Bool                    IsCursorOnly() const            { return bCursorOnly; }
255 
256                             // XSheetOperation
257     virtual double SAL_CALL computeFunction( ::com::sun::star::sheet::GeneralFunction nFunction );
258     virtual void SAL_CALL   clearContents( sal_Int32 nContentFlags );
259 
260                             // XPropertySet
261     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
262                             SAL_CALL getPropertySetInfo();
263     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
264                                     const ::com::sun::star::uno::Any& aValue );
265     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
266                                     const ::rtl::OUString& PropertyName );
267     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
268                                     const ::com::sun::star::uno::Reference<
269                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener );
270     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
271                                     const ::com::sun::star::uno::Reference<
272                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener );
273     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
274                                     const ::com::sun::star::uno::Reference<
275                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
276     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
277                                     const ::com::sun::star::uno::Reference<
278                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
279 
280                             // XMultiPropertySet
281     virtual void SAL_CALL   setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
282                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues );
283     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
284                             getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames );
285     virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
286                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener );
287     virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener );
288     virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
289                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener );
290 
291                             // XTolerantMultiPropertySet
292     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL
293         setPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
294                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues );
295     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL
296         getPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames );
297     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL
298         getDirectPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames );
299 
300                             // XPropertyState
301     virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(
302                                     const ::rtl::OUString& PropertyName );
303     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL
304                             getPropertyStates( const ::com::sun::star::uno::Sequence<
305                                         ::rtl::OUString >& aPropertyName );
306     virtual void SAL_CALL   setPropertyToDefault( const ::rtl::OUString& PropertyName );
307     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
308                                     const ::rtl::OUString& aPropertyName );
309 
310                             // XIndent
311     virtual void SAL_CALL   decrementIndent();
312     virtual void SAL_CALL   incrementIndent();
313 
314                             // XChartData
315     virtual void SAL_CALL   addChartDataChangeEventListener(
316                                 const ::com::sun::star::uno::Reference<
317                                     ::com::sun::star::chart::XChartDataChangeEventListener >& aListener );
318     virtual void SAL_CALL   removeChartDataChangeEventListener( const ::com::sun::star::uno::Reference<
319                                     ::com::sun::star::chart::XChartDataChangeEventListener >& aListener );
320     virtual double SAL_CALL getNotANumber();
321     virtual sal_Bool SAL_CALL isNotANumber( double nNumber );
322 
323                             // XChartDataArray
324     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL
325                             getData();
326     virtual void SAL_CALL   setData( const ::com::sun::star::uno::Sequence<
327                                 ::com::sun::star::uno::Sequence< double > >& aData );
328     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowDescriptions();
329     virtual void SAL_CALL setRowDescriptions( const ::com::sun::star::uno::Sequence<
330                                 ::rtl::OUString >& aRowDescriptions );
331     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getColumnDescriptions();
332     virtual void SAL_CALL   setColumnDescriptions( const ::com::sun::star::uno::Sequence<
333                                 ::rtl::OUString >& aColumnDescriptions );
334 
335                             // XCellRangesQuery
336     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
337                             queryVisibleCells();
338     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
339                             queryEmptyCells();
340     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
341                             queryContentCells( sal_Int16 nContentFlags );
342     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
343                             queryFormulaCells( sal_Int32 nResultFlags );
344     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
345                             queryColumnDifferences(
346                                 const ::com::sun::star::table::CellAddress& aCompare );
347     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
348                             queryRowDifferences(
349                                 const ::com::sun::star::table::CellAddress& aCompare );
350     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
351                             queryIntersection(
352                                 const ::com::sun::star::table::CellRangeAddress& aRange );
353 
354                             // XFormulaQuery
355     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
356                             queryDependents( sal_Bool bRecursive );
357     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellRanges > SAL_CALL
358                             queryPrecedents( sal_Bool bRecursive );
359 
360                             // XSearchable
361     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL
362                             createSearchDescriptor();
363     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL
364                             findAll( const ::com::sun::star::uno::Reference<
365                                 ::com::sun::star::util::XSearchDescriptor >& xDesc );
366     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
367                             findFirst( const ::com::sun::star::uno::Reference<
368                                 ::com::sun::star::util::XSearchDescriptor >& xDesc );
369     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
370                             findNext( const ::com::sun::star::uno::Reference<
371                                         ::com::sun::star::uno::XInterface >& xStartAt,
372                                       const ::com::sun::star::uno::Reference<
373                                         ::com::sun::star::util::XSearchDescriptor >& xDesc );
374 
375                             // XReplaceable
376     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XReplaceDescriptor > SAL_CALL
377                             createReplaceDescriptor();
378     virtual sal_Int32 SAL_CALL replaceAll( const ::com::sun::star::uno::Reference<
379                                 ::com::sun::star::util::XSearchDescriptor >& xDesc );
380 
381                             // XModifyBroadcaster
382     virtual void SAL_CALL   addModifyListener( const ::com::sun::star::uno::Reference<
383                                     ::com::sun::star::util::XModifyListener >& aListener );
384     virtual void SAL_CALL   removeModifyListener( const ::com::sun::star::uno::Reference<
385                                     ::com::sun::star::util::XModifyListener >& aListener );
386 
387                             // XServiceInfo
388     virtual ::rtl::OUString SAL_CALL getImplementationName();
389     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
390     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
391 
392                             // XUnoTunnel
393     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
394                                     sal_Int8 >& aIdentifier );
395 
396     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
397     static ScCellRangesBase* getImplementation( const com::sun::star::uno::Reference<
398                                     com::sun::star::uno::XInterface> xObj );
399 
400                             // XTypeProvider
401     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes();
402     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
403 };
404 
405 
406 class SC_DLLPUBLIC ScCellRangesObj : public ScCellRangesBase,
407                         public com::sun::star::sheet::XSheetCellRangeContainer,
408                         public com::sun::star::container::XNameContainer,
409                         public com::sun::star::container::XEnumerationAccess
410 {
411 private:
412     ScNamedEntryArr_Impl    aNamedEntries;
413 
414     ScCellRangeObj*         GetObjectByIndex_Impl(sal_Int32 nIndex) const;
415 
416 public:
417                             ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR);
418     virtual                 ~ScCellRangesObj();
419 
420     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
421                                 const ::com::sun::star::uno::Type & rType );
422     virtual void SAL_CALL   acquire() throw();
423     virtual void SAL_CALL   release() throw();
424 
425     virtual void            RefChanged();
426 
427                             // XSheetCellRanges
428     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > SAL_CALL
429                             getCells();
430     virtual ::rtl::OUString SAL_CALL getRangeAddressesAsString();
431     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress > SAL_CALL
432                             getRangeAddresses();
433 
434                             // XSheetCellRangeContainer
435     virtual void SAL_CALL   addRangeAddress( const ::com::sun::star::table::CellRangeAddress& rRange,
436                                         sal_Bool bMergeRanges );
437     virtual void SAL_CALL   removeRangeAddress( const ::com::sun::star::table::CellRangeAddress& rRange );
438     virtual void SAL_CALL   addRangeAddresses( const ::com::sun::star::uno::Sequence<
439                                         ::com::sun::star::table::CellRangeAddress >& rRanges,
440                                         sal_Bool bMergeRanges );
441     virtual void SAL_CALL   removeRangeAddresses( const ::com::sun::star::uno::Sequence<
442                                         ::com::sun::star::table::CellRangeAddress >& rRanges );
443 
444                             // XNameContainer
445     virtual void SAL_CALL   insertByName( const ::rtl::OUString& aName,
446                                 const ::com::sun::star::uno::Any& aElement );
447     virtual void SAL_CALL   removeByName( const ::rtl::OUString& Name );
448 
449                             // XNameReplace
450     virtual void SAL_CALL   replaceByName( const ::rtl::OUString& aName,
451                                 const ::com::sun::star::uno::Any& aElement );
452 
453                             // XNameAccess
454     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName );
455     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames();
456     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName );
457 
458                             // XIndexAccess
459     virtual sal_Int32 SAL_CALL getCount();
460     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index );
461 
462                             // XElementAccess
463     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
464     virtual sal_Bool SAL_CALL hasElements();
465 
466                             // XEnumerationAccess
467     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
468                             createEnumeration();
469 
470                             // XServiceInfo
471     virtual ::rtl::OUString SAL_CALL getImplementationName();
472     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
473     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
474 
475                             // XTypeProvider
476     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes();
477     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
478 };
479 
480 
481 class SC_DLLPUBLIC ScCellRangeObj : public ScCellRangesBase,
482                        public com::sun::star::sheet::XCellRangeAddressable,
483                        public com::sun::star::sheet::XSheetCellRange,
484                        public com::sun::star::sheet::XArrayFormulaRange,
485                        public com::sun::star::sheet::XArrayFormulaTokens,
486                        public com::sun::star::sheet::XCellRangeData,
487                        public com::sun::star::sheet::XCellRangeFormula,
488                        public com::sun::star::sheet::XMultipleOperation,
489                        public com::sun::star::util::XMergeable,
490                        public com::sun::star::sheet::XCellSeries,
491                        public com::sun::star::table::XAutoFormattable,
492                        public com::sun::star::util::XSortable,
493                        public com::sun::star::sheet::XSheetFilterableEx,
494                        public com::sun::star::sheet::XSubTotalCalculatable,
495                        public com::sun::star::util::XImportable,
496                        public com::sun::star::sheet::XCellFormatRangesSupplier,
497                        public com::sun::star::sheet::XUniqueCellFormatRangesSupplier,
498                        public com::sun::star::table::XColumnRowRange
499 {
500 private:
501     const SfxItemPropertySet*       pRangePropSet;
502     ScRange                 aRange;
503 
504 protected:
GetRange() const505     const ScRange&          GetRange() const    { return aRange; }
506     virtual const SfxItemPropertyMap* GetItemPropertyMap();
507     virtual void GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
508                                 ::com::sun::star::uno::Any& );
509     virtual void            SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
510                                                 const ::com::sun::star::uno::Any& aValue );
511 
512     ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell >
513                             GetCellByPosition_Impl( sal_Int32 nColumn, sal_Int32 nRow );
514 
515             void            SetArrayFormula_Impl( const rtl::OUString& rFormula,
516                                 const rtl::OUString& rFormulaNmsp,
517                                 const formula::FormulaGrammar::Grammar eGrammar );
518 
519 public:
520                             ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR);
521     virtual                 ~ScCellRangeObj();
522 
523                             // uses ObjectShell from document, if set (returns NULL otherwise)
524     static com::sun::star::uno::Reference<com::sun::star::table::XCellRange>
525                             CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR );
526 
527     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
528                                 const ::com::sun::star::uno::Type & rType );
529     virtual void SAL_CALL   acquire() throw();
530     virtual void SAL_CALL   release() throw();
531 
532     virtual void            RefChanged();
533 
534                             // via getImplementation()
535     virtual void            SetArrayFormulaWithGrammar( const ::rtl::OUString& rFormula,
536                                     const ::rtl::OUString& rFormulaNmsp,
537                                     const formula::FormulaGrammar::Grammar );
538 
539     // XCellRange ist Basisklasse von XSheetCellRange und XSheetOperation
540 //  operator XCellRangeRef() const  { return (XSheetCellRange*)this; }
541 
542                             // XCellRangeAddressable
543     virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getRangeAddress();
544 
545                             // XSheetCellRange
546     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > SAL_CALL
547                             getSpreadsheet();
548 
549                             // XArrayFormulaRange
550     virtual ::rtl::OUString SAL_CALL getArrayFormula();
551     virtual void SAL_CALL   setArrayFormula( const ::rtl::OUString& aFormula );
552 
553                             // XArrayFormulaTokens
554     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL getArrayTokens();
555     virtual void SAL_CALL   setArrayTokens( const ::com::sun::star::uno::Sequence<
556                                     ::com::sun::star::sheet::FormulaToken >& aTokens );
557 
558                             // XCellRangeData
559     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<
560                             ::com::sun::star::uno::Any > > SAL_CALL getDataArray();
561     virtual void SAL_CALL   setDataArray( const ::com::sun::star::uno::Sequence<
562                                 ::com::sun::star::uno::Sequence<
563                                     ::com::sun::star::uno::Any > >& aArray );
564 
565                             // XCellRangeFormula
566     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<
567                             ::rtl::OUString > > SAL_CALL getFormulaArray();
568     virtual void SAL_CALL   setFormulaArray( const ::com::sun::star::uno::Sequence<
569                                 ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aArray );
570 
571                             // XMultipleOperation
572     virtual void SAL_CALL   setTableOperation(
573                                 const ::com::sun::star::table::CellRangeAddress& aFormulaRange,
574                                 ::com::sun::star::sheet::TableOperationMode nMode,
575                                 const ::com::sun::star::table::CellAddress& aColumnCell,
576                                 const ::com::sun::star::table::CellAddress& aRowCell );
577 
578                             // XMergeable
579     virtual void SAL_CALL   merge( sal_Bool bMerge );
580     virtual sal_Bool SAL_CALL getIsMerged();
581 
582                             // XCellSeries
583     virtual void SAL_CALL   fillSeries( ::com::sun::star::sheet::FillDirection nFillDirection,
584                                 ::com::sun::star::sheet::FillMode nFillMode,
585                                 ::com::sun::star::sheet::FillDateMode nFillDateMode,
586                                 double fStep, double fEndValue );
587     virtual void SAL_CALL   fillAuto( ::com::sun::star::sheet::FillDirection nFillDirection,
588                                 sal_Int32 nSourceCount );
589 
590                             // XAutoFormattable
591     virtual void SAL_CALL   autoFormat( const ::rtl::OUString& aName );
592 
593                             // XSortable
594     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
595                             createSortDescriptor();
596     virtual void SAL_CALL   sort( const ::com::sun::star::uno::Sequence<
597                                 ::com::sun::star::beans::PropertyValue >& xDescriptor );
598 
599                             // XSheetFilterableEx
600     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetFilterDescriptor > SAL_CALL
601                             createFilterDescriptorByObject( const ::com::sun::star::uno::Reference<
602                                 ::com::sun::star::sheet::XSheetFilterable >& xObject );
603 
604                             // XSheetFilterable
605     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetFilterDescriptor > SAL_CALL
606                             createFilterDescriptor( sal_Bool bEmpty );
607     virtual void SAL_CALL   filter( const ::com::sun::star::uno::Reference<
608                                 ::com::sun::star::sheet::XSheetFilterDescriptor >& xDescriptor );
609 
610                             // XSubTotalCalculatable
611     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSubTotalDescriptor > SAL_CALL
612                             createSubTotalDescriptor( sal_Bool bEmpty );
613     virtual void SAL_CALL   applySubTotals( const ::com::sun::star::uno::Reference<
614                                 ::com::sun::star::sheet::XSubTotalDescriptor >& xDescriptor,
615                                 sal_Bool bReplace );
616     virtual void SAL_CALL   removeSubTotals();
617 
618                             // XImportable
619     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
620                             createImportDescriptor( sal_Bool bEmpty );
621     virtual void SAL_CALL   doImport( const ::com::sun::star::uno::Sequence<
622                                 ::com::sun::star::beans::PropertyValue >& aDescriptor );
623 
624                             // XCellFormatRangesSupplier
625     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL
626                             getCellFormatRanges();
627 
628                             // XUniqueCellFormatRangesSupplier
629     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL
630                             getUniqueCellFormatRanges();
631 
632                             // XColumnRowRange
633     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTableColumns > SAL_CALL
634                             getColumns();
635     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTableRows > SAL_CALL
636                             getRows();
637 
638                             // XCellRange
639     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL
640                             getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow );
641     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL
642                             getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop,
643                                 sal_Int32 nRight, sal_Int32 nBottom );
644     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL
645                             getCellRangeByName( const ::rtl::OUString& aRange );
646     ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
647                             getCellRangeByName( const ::rtl::OUString& aRange,  const ScAddress::Details& rDetails );
648 
649                             // XPropertySet ueberladen wegen Range-Properties
650     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
651                             SAL_CALL getPropertySetInfo();
652 
653                             // XServiceInfo
654     virtual ::rtl::OUString SAL_CALL getImplementationName();
655     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
656     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
657 
658                             // XTypeProvider
659     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes();
660     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
661 };
662 
663 
664 //! really derive cell from range?
665 
666 class SC_DLLPUBLIC ScCellObj : public ScCellRangeObj,
667                   public com::sun::star::text::XText,
668                   public com::sun::star::container::XEnumerationAccess,
669                   public com::sun::star::table::XCell,
670                   public com::sun::star::sheet::XFormulaTokens,
671                   public com::sun::star::sheet::XCellAddressable,
672                   public com::sun::star::sheet::XSheetAnnotationAnchor,
673                   public com::sun::star::text::XTextFieldsSupplier,
674                     public com::sun::star::document::XActionLockable
675 {
676 private:
677     SvxUnoText*             pUnoText;
678     const SfxItemPropertySet*   pCellPropSet;
679     ScAddress               aCellPos;
680     sal_Int16               nActionLockCount;
681 
682 private:
683     String      GetInputString_Impl(sal_Bool bEnglish) const;
684     String      GetOutputString_Impl() const;
685     void        SetString_Impl(const String& rString, sal_Bool bInterpret, sal_Bool bEnglish);
686     double      GetValue_Impl() const;
687     void        SetValue_Impl(double fValue);
688     com::sun::star::table::CellContentType GetResultType_Impl();
689 
690 protected:
691     virtual const SfxItemPropertyMap* GetItemPropertyMap();
692     virtual void GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
693                                 ::com::sun::star::uno::Any& );
694     virtual void            SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
695                                                 const ::com::sun::star::uno::Any& aValue );
696 
697 public:
698     static const SvxItemPropertySet* GetEditPropertySet();
699     static const SfxItemPropertyMap* GetCellPropertyMap();
700 
701                             ScCellObj(ScDocShell* pDocSh, const ScAddress& rP);
702     virtual                 ~ScCellObj();
703 
704     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
705                                 const ::com::sun::star::uno::Type & rType );
706     virtual void SAL_CALL   acquire() throw();
707     virtual void SAL_CALL   release() throw();
708 
709     virtual void            RefChanged();
710 
711     SvxUnoText&             GetUnoText();
712 
713                             // XML import needs to set results at formula cells,
714                             // not meant for any other purpose.
715     void                    SetFormulaResultString( const ::rtl::OUString& rResult );
716     void                    SetFormulaResultDouble( double fResult );
717     void                    SetFormulaWithGrammar( const ::rtl::OUString& rFormula,
718                                 const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar );
GetPosition() const719     const ScAddress&        GetPosition() const { return aCellPos; }
720 
721     void                    InputEnglishString( const ::rtl::OUString& rText );
722 
723                             // XText
724     virtual void SAL_CALL   insertTextContent( const ::com::sun::star::uno::Reference<
725                                     ::com::sun::star::text::XTextRange >& xRange,
726                                 const ::com::sun::star::uno::Reference<
727                                     ::com::sun::star::text::XTextContent >& xContent,
728                                 sal_Bool bAbsorb );
729     virtual void SAL_CALL   removeTextContent( const ::com::sun::star::uno::Reference<
730                                 ::com::sun::star::text::XTextContent >& xContent );
731 
732                             // XSimpleText
733     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
734                             createTextCursor();
735     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
736                             createTextCursorByRange( const ::com::sun::star::uno::Reference<
737                                         ::com::sun::star::text::XTextRange >& aTextPosition );
738     virtual void SAL_CALL   insertString( const ::com::sun::star::uno::Reference<
739                                         ::com::sun::star::text::XTextRange >& xRange,
740                                         const ::rtl::OUString& aString, sal_Bool bAbsorb );
741     virtual void SAL_CALL   insertControlCharacter( const ::com::sun::star::uno::Reference<
742                                         ::com::sun::star::text::XTextRange >& xRange,
743                                         sal_Int16 nControlCharacter, sal_Bool bAbsorb );
744 
745                             // XTextRange
746     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
747                             getText();
748     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
749                             getStart();
750     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
751                             getEnd();
752     virtual ::rtl::OUString SAL_CALL getString();
753     virtual void SAL_CALL   setString( const ::rtl::OUString& aString );
754 
755                             // XEnumerationAccess
756     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
757                             createEnumeration();
758 
759                             // XElementAccess
760     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
761     virtual sal_Bool SAL_CALL hasElements();
762 
763                             // XCell
764     virtual ::rtl::OUString SAL_CALL getFormula();
765     virtual void SAL_CALL   setFormula( const ::rtl::OUString& aFormula );
766     virtual double SAL_CALL getValue();
767     virtual void SAL_CALL   setValue( double nValue );
768     virtual ::com::sun::star::table::CellContentType SAL_CALL getType();
769     virtual sal_Int32 SAL_CALL getError();
770 
771                             // XFormulaTokens
772     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken > SAL_CALL getTokens();
773     virtual void SAL_CALL   setTokens( const ::com::sun::star::uno::Sequence<
774                                     ::com::sun::star::sheet::FormulaToken >& aTokens );
775 
776                             // XCellAddressable
777     virtual ::com::sun::star::table::CellAddress SAL_CALL getCellAddress();
778 
779                             // XSheetAnnotationAnchor
780     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetAnnotation > SAL_CALL
781                             getAnnotation();
782 
783                             // XTextFieldsSupplier
784     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > SAL_CALL
785                             getTextFields();
786     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
787                             getTextFieldMasters();
788 
789                             // XPropertySet ueberladen wegen Zell-Properties
790     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
791                             SAL_CALL getPropertySetInfo();
792 
793                             // XServiceInfo
794     virtual ::rtl::OUString SAL_CALL getImplementationName();
795     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
796     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
797 
798                             // XTypeProvider
799     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes();
800     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
801 
802                             // XActionLockable
803     virtual sal_Bool SAL_CALL isActionLocked();
804     virtual void SAL_CALL   addActionLock();
805     virtual void SAL_CALL   removeActionLock();
806     virtual void SAL_CALL   setActionLocks( sal_Int16 nLock );
807     virtual sal_Int16 SAL_CALL resetActionLocks();
808 
809     static String       GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aPos);
810 };
811 
812 
813 class ScTableSheetObj : public ScCellRangeObj,
814                         public com::sun::star::sheet::XSpreadsheet,
815                         public com::sun::star::container::XNamed,
816                         public com::sun::star::sheet::XSheetPageBreak,
817                         public com::sun::star::sheet::XCellRangeMovement,
818                         public com::sun::star::table::XTableChartsSupplier,
819                         public com::sun::star::sheet::XDataPilotTablesSupplier,
820                         public com::sun::star::sheet::XScenariosSupplier,
821                         public com::sun::star::sheet::XSheetAnnotationsSupplier,
822                         public com::sun::star::drawing::XDrawPageSupplier,
823                         public com::sun::star::sheet::XPrintAreas,
824                         public com::sun::star::sheet::XSheetLinkable,
825                         public com::sun::star::sheet::XSheetAuditing,
826                         public com::sun::star::sheet::XSheetOutline,
827                         public com::sun::star::util::XProtectable,
828                         public com::sun::star::sheet::XScenario,
829                         public com::sun::star::sheet::XScenarioEnhanced,
830                         public com::sun::star::sheet::XExternalSheetName,
831                         public com::sun::star::document::XEventsSupplier
832 {
833     friend class ScTableSheetsObj;      // fuer insertByName()
834 
835 private:
836     const SfxItemPropertySet*       pSheetPropSet;
837 
838     SCTAB                   GetTab_Impl() const;
839     void                    PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges );
840 
841 protected:
842     virtual const SfxItemPropertyMap* GetItemPropertyMap();
843     virtual void GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
844                                 ::com::sun::star::uno::Any& );
845     virtual void            SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
846                                                 const ::com::sun::star::uno::Any& aValue );
847 
848 public:
849                             ScTableSheetObj(ScDocShell* pDocSh, SCTAB nTab);
850     virtual                 ~ScTableSheetObj();
851 
852     void                    InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab);
853 
854     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
855                                 const ::com::sun::star::uno::Type & rType );
856     virtual void SAL_CALL   acquire() throw();
857     virtual void SAL_CALL   release() throw();
858 
859                             // XSpreadsheet
860     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellCursor >
861                             SAL_CALL createCursor();
862     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetCellCursor > SAL_CALL
863                             createCursorByRange( const ::com::sun::star::uno::Reference<
864                                 ::com::sun::star::sheet::XSheetCellRange >& aRange );
865 
866                             // XSheetCellRange
867     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > SAL_CALL
868                             getSpreadsheet();
869 
870                             // XCellRange
871     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL
872                             getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow );
873     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL
874                             getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop,
875                                 sal_Int32 nRight, sal_Int32 nBottom );
876     using ScCellRangeObj::getCellRangeByName;
877     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL
878                             getCellRangeByName( const ::rtl::OUString& aRange );
879 
880                             // XNamed
881     virtual ::rtl::OUString SAL_CALL getName();
882     virtual void SAL_CALL   setName( const ::rtl::OUString& aName );
883 
884                             // XSheetPageBreak
885     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::TablePageBreakData > SAL_CALL
886                             getColumnPageBreaks();
887     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::TablePageBreakData > SAL_CALL
888                             getRowPageBreaks();
889     virtual void SAL_CALL   removeAllManualPageBreaks();
890 
891                             // XCellRangeMovement
892     virtual void SAL_CALL   insertCells( const ::com::sun::star::table::CellRangeAddress& aRange,
893                                 ::com::sun::star::sheet::CellInsertMode nMode );
894     virtual void SAL_CALL   removeRange( const ::com::sun::star::table::CellRangeAddress& aRange,
895                                 ::com::sun::star::sheet::CellDeleteMode nMode );
896     virtual void SAL_CALL   moveRange( const ::com::sun::star::table::CellAddress& aDestination,
897                                 const ::com::sun::star::table::CellRangeAddress& aSource );
898     virtual void SAL_CALL   copyRange( const ::com::sun::star::table::CellAddress& aDestination,
899                                 const ::com::sun::star::table::CellRangeAddress& aSource );
900 
901                             // XTableChartsSupplier
902     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTableCharts > SAL_CALL
903                             getCharts();
904 
905                             // XDataPilotTablesSupplier
906     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDataPilotTables > SAL_CALL
907                             getDataPilotTables();
908 
909                             // XScenariosSupplier
910     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XScenarios > SAL_CALL
911                             getScenarios();
912 
913                             // XSheetAnnotationsSupplier
914     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetAnnotations > SAL_CALL
915                             getAnnotations();
916 
917                             // XDrawPageSupplier
918     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL
919                             getDrawPage();
920 
921                             // XPrintAreas
922     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress > SAL_CALL
923                             getPrintAreas();
924     virtual void SAL_CALL setPrintAreas( const ::com::sun::star::uno::Sequence<
925                                 ::com::sun::star::table::CellRangeAddress >& aPrintAreas );
926     virtual sal_Bool SAL_CALL getPrintTitleColumns();
927     virtual void SAL_CALL   setPrintTitleColumns( sal_Bool bPrintTitleColumns );
928     virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getTitleColumns();
929     virtual void SAL_CALL   setTitleColumns(
930                                 const ::com::sun::star::table::CellRangeAddress& aTitleColumns );
931     virtual sal_Bool SAL_CALL getPrintTitleRows();
932     virtual void SAL_CALL   setPrintTitleRows( sal_Bool bPrintTitleRows );
933     virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getTitleRows();
934     virtual void SAL_CALL   setTitleRows(
935                                 const ::com::sun::star::table::CellRangeAddress& aTitleRows );
936 
937                             // XSheetLinkable
938     virtual ::com::sun::star::sheet::SheetLinkMode SAL_CALL getLinkMode();
939     virtual void SAL_CALL   setLinkMode( ::com::sun::star::sheet::SheetLinkMode nLinkMode );
940     virtual ::rtl::OUString SAL_CALL getLinkUrl();
941     virtual void SAL_CALL   setLinkUrl( const ::rtl::OUString& aLinkUrl );
942     virtual ::rtl::OUString SAL_CALL getLinkSheetName();
943     virtual void SAL_CALL   setLinkSheetName( const ::rtl::OUString& aLinkSheetName );
944     virtual void SAL_CALL   link( const ::rtl::OUString& aUrl,
945                                 const ::rtl::OUString& aSheetName,
946                                 const ::rtl::OUString& aFilterName,
947                                 const ::rtl::OUString& aFilterOptions,
948                                 ::com::sun::star::sheet::SheetLinkMode nMode );
949 
950                             // XSheetAuditing
951     virtual sal_Bool SAL_CALL hideDependents( const ::com::sun::star::table::CellAddress& aPosition );
952     virtual sal_Bool SAL_CALL hidePrecedents( const ::com::sun::star::table::CellAddress& aPosition );
953     virtual sal_Bool SAL_CALL showDependents( const ::com::sun::star::table::CellAddress& aPosition );
954     virtual sal_Bool SAL_CALL showPrecedents( const ::com::sun::star::table::CellAddress& aPosition );
955     virtual sal_Bool SAL_CALL showErrors( const ::com::sun::star::table::CellAddress& aPosition );
956     virtual sal_Bool SAL_CALL showInvalid();
957     virtual void SAL_CALL   clearArrows();
958 
959                             // XSheetOutline
960     virtual void SAL_CALL   group( const ::com::sun::star::table::CellRangeAddress& aRange,
961                                 ::com::sun::star::table::TableOrientation nOrientation );
962     virtual void SAL_CALL   ungroup( const ::com::sun::star::table::CellRangeAddress& aRange,
963                                 ::com::sun::star::table::TableOrientation nOrientation );
964     virtual void SAL_CALL   autoOutline( const ::com::sun::star::table::CellRangeAddress& aRange );
965     virtual void SAL_CALL   clearOutline();
966     virtual void SAL_CALL   hideDetail( const ::com::sun::star::table::CellRangeAddress& aRange );
967     virtual void SAL_CALL   showDetail( const ::com::sun::star::table::CellRangeAddress& aRange );
968     virtual void SAL_CALL   showLevel( sal_Int16 nLevel,
969                                 ::com::sun::star::table::TableOrientation nOrientation );
970 
971                             // XProtectable
972     virtual void SAL_CALL   protect( const ::rtl::OUString& aPassword );
973     virtual void SAL_CALL   unprotect( const ::rtl::OUString& aPassword );
974     virtual sal_Bool SAL_CALL isProtected();
975 
976                             // XScenario
977     virtual sal_Bool SAL_CALL getIsScenario();
978     virtual ::rtl::OUString SAL_CALL getScenarioComment();
979     virtual void SAL_CALL   setScenarioComment( const ::rtl::OUString& aScenarioComment );
980     virtual void SAL_CALL   addRanges( const ::com::sun::star::uno::Sequence<
981                                 ::com::sun::star::table::CellRangeAddress >& aRanges );
982     virtual void SAL_CALL   apply();
983                             // XScenarioEnhanced
984     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress > SAL_CALL
985                             getRanges(  );
986 
987                             // XExternalSheetName
988     virtual void SAL_CALL   setExternalName( const ::rtl::OUString& aUrl, const ::rtl::OUString& aSheetName );
989 
990                             // XEventsSupplier
991     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents();
992 
993                             // XPropertySet ueberladen wegen Sheet-Properties
994     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
995                             SAL_CALL getPropertySetInfo();
996 
997                             // XServiceInfo
998     virtual ::rtl::OUString SAL_CALL getImplementationName();
999     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1000     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1001 
1002                             // XUnoTunnel
1003     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
1004                                     sal_Int8 >& aIdentifier );
1005 
1006     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
1007     static ScTableSheetObj* getImplementation( const com::sun::star::uno::Reference<
1008                                     com::sun::star::uno::XInterface> xObj );
1009 
1010                             // XTypeProvider
1011     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes();
1012     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
1013 };
1014 
1015 
1016 class ScTableColumnObj : public ScCellRangeObj,
1017                          public com::sun::star::container::XNamed
1018 {
1019 private:
1020     const SfxItemPropertySet*       pColPropSet;
1021 
1022 protected:
1023     virtual const SfxItemPropertyMap* GetItemPropertyMap();
1024     virtual void GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
1025                                 ::com::sun::star::uno::Any& );
1026     virtual void            SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
1027                                                 const ::com::sun::star::uno::Any& aValue );
1028 
1029 public:
1030                             ScTableColumnObj(ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab);
1031     virtual                 ~ScTableColumnObj();
1032 
1033     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
1034                                 const ::com::sun::star::uno::Type & rType );
1035     virtual void SAL_CALL   acquire() throw();
1036     virtual void SAL_CALL   release() throw();
1037 
1038                             // XNamed
1039     virtual ::rtl::OUString SAL_CALL getName();
1040     virtual void SAL_CALL   setName( const ::rtl::OUString& aName );
1041 
1042                             // XPropertySet ueberladen wegen Spalten-Properties
1043     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
1044                             SAL_CALL getPropertySetInfo();
1045 
1046                             // XServiceInfo
1047     virtual ::rtl::OUString SAL_CALL getImplementationName();
1048     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1049     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1050 
1051                             // XTypeProvider
1052     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes();
1053     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
1054 };
1055 
1056 
1057 class ScTableRowObj : public ScCellRangeObj
1058 {
1059 private:
1060     const SfxItemPropertySet*       pRowPropSet;
1061 
1062 protected:
1063     virtual const SfxItemPropertyMap* GetItemPropertyMap();
1064     virtual void GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
1065                                 ::com::sun::star::uno::Any& );
1066     virtual void            SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
1067                                                 const ::com::sun::star::uno::Any& aValue );
1068 
1069 public:
1070                             ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab);
1071     virtual                 ~ScTableRowObj();
1072 
1073                             // XPropertySet ueberladen wegen Zeilen-Properties
1074     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
1075                             SAL_CALL getPropertySetInfo();
1076 
1077                             // XServiceInfo
1078     virtual ::rtl::OUString SAL_CALL getImplementationName();
1079     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1080     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1081 };
1082 
1083 
1084 class ScCellsObj : public cppu::WeakImplHelper2<
1085                             com::sun::star::container::XEnumerationAccess,
1086                             com::sun::star::lang::XServiceInfo >,
1087                         public SfxListener
1088 {
1089 private:
1090     ScDocShell*             pDocShell;
1091     ScRangeList             aRanges;
1092 
1093 public:
1094                             ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR);
1095     virtual                 ~ScCellsObj();
1096 
1097     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
1098 
1099                             // XEnumerationAccess
1100     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
1101                             createEnumeration();
1102 
1103                             // XElementAccess
1104     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
1105     virtual sal_Bool SAL_CALL hasElements();
1106 
1107                             // XServiceInfo
1108     virtual ::rtl::OUString SAL_CALL getImplementationName();
1109     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1110     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1111 };
1112 
1113 
1114 class ScCellsEnumeration : public cppu::WeakImplHelper2<
1115                                 com::sun::star::container::XEnumeration,
1116                                 com::sun::star::lang::XServiceInfo >,
1117                             public SfxListener
1118 {
1119 private:
1120     ScDocShell*             pDocShell;
1121     ScRangeList             aRanges;
1122     ScAddress               aPos;
1123     ScMarkData*             pMark;
1124     sal_Bool                    bAtEnd;
1125 
1126 private:
1127     void                    Advance_Impl();
1128     void                    CheckPos_Impl();
1129 
1130 public:
1131                             ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR);
1132     virtual                 ~ScCellsEnumeration();
1133 
1134     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
1135 
1136                             // XEnumeration
1137     virtual sal_Bool SAL_CALL hasMoreElements();
1138     virtual ::com::sun::star::uno::Any SAL_CALL nextElement();
1139 
1140                             // XServiceInfo
1141     virtual ::rtl::OUString SAL_CALL getImplementationName();
1142     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1143     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1144 };
1145 
1146 class ScCellFormatsObj : public cppu::WeakImplHelper3<
1147                             com::sun::star::container::XIndexAccess,
1148                             com::sun::star::container::XEnumerationAccess,
1149                             com::sun::star::lang::XServiceInfo >,
1150                         public SfxListener
1151 {
1152 private:
1153     ScDocShell*             pDocShell;
1154     ScRange                 aTotalRange;
1155 
1156 private:
1157     ScCellRangeObj*         GetObjectByIndex_Impl(long nIndex) const;
1158 
1159 public:
1160                             ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rR);
1161     virtual                 ~ScCellFormatsObj();
1162 
1163     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
1164 
1165                             // XIndexAccess
1166     virtual sal_Int32 SAL_CALL getCount();
1167     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index );
1168 
1169                             // XEnumerationAccess
1170     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
1171                             createEnumeration();
1172 
1173                             // XElementAccess
1174     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
1175     virtual sal_Bool SAL_CALL hasElements();
1176 
1177                             // XServiceInfo
1178     virtual ::rtl::OUString SAL_CALL getImplementationName();
1179     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1180     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1181 };
1182 
1183 
1184 class ScCellFormatsEnumeration : public cppu::WeakImplHelper2<
1185                                     com::sun::star::container::XEnumeration,
1186                                     com::sun::star::lang::XServiceInfo >,
1187                                  public SfxListener
1188 {
1189 private:
1190     ScDocShell*             pDocShell;
1191     SCTAB                   nTab;
1192     ScAttrRectIterator*     pIter;
1193     ScRange                 aNext;
1194     sal_Bool                    bAtEnd;
1195     sal_Bool                    bDirty;
1196 
1197 private:
1198     void                    Advance_Impl();
1199     ScCellRangeObj*         NextObject_Impl();
1200 
1201 public:
1202                             ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rR);
1203     virtual                 ~ScCellFormatsEnumeration();
1204 
1205     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
1206 
1207                             // XEnumeration
1208     virtual sal_Bool SAL_CALL hasMoreElements();
1209     virtual ::com::sun::star::uno::Any SAL_CALL nextElement();
1210 
1211                             // XServiceInfo
1212     virtual ::rtl::OUString SAL_CALL getImplementationName();
1213     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1214     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1215 };
1216 
1217 typedef std::vector< ScRangeList > ScMyRangeLists;
1218 
1219 class ScUniqueCellFormatsObj : public cppu::WeakImplHelper3<
1220                             com::sun::star::container::XIndexAccess,
1221                             com::sun::star::container::XEnumerationAccess,
1222                             com::sun::star::lang::XServiceInfo >,
1223                         public SfxListener
1224 {
1225 private:
1226     ScDocShell*                     pDocShell;
1227     ScRange                         aTotalRange;
1228     ScMyRangeLists                  aRangeLists;
1229 
1230 private:
1231     void                            GetObjects_Impl();
1232 
1233 public:
1234                             ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rR);
1235     virtual                 ~ScUniqueCellFormatsObj();
1236 
1237     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
1238 
1239                             // XIndexAccess
1240     virtual sal_Int32 SAL_CALL getCount();
1241     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index );
1242 
1243                             // XEnumerationAccess
1244     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
1245                             createEnumeration();
1246 
1247                             // XElementAccess
1248     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
1249     virtual sal_Bool SAL_CALL hasElements();
1250 
1251                             // XServiceInfo
1252     virtual ::rtl::OUString SAL_CALL getImplementationName();
1253     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1254     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1255 };
1256 
1257 class ScUniqueCellFormatsEnumeration : public cppu::WeakImplHelper2<
1258                                     com::sun::star::container::XEnumeration,
1259                                     com::sun::star::lang::XServiceInfo >,
1260                                  public SfxListener
1261 {
1262 private:
1263     ScMyRangeLists                  aRangeLists;
1264     ScDocShell*                     pDocShell;
1265     sal_Int32                       nCurrentPosition;
1266 
1267 public:
1268                             ScUniqueCellFormatsEnumeration(ScDocShell* pDocShell, const ScMyRangeLists& rRangeLists);
1269     virtual                 ~ScUniqueCellFormatsEnumeration();
1270 
1271     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
1272 
1273                             // XEnumeration
1274     virtual sal_Bool SAL_CALL hasMoreElements();
1275     virtual ::com::sun::star::uno::Any SAL_CALL nextElement();
1276 
1277                             // XServiceInfo
1278     virtual ::rtl::OUString SAL_CALL getImplementationName();
1279     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
1280     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
1281 };
1282 
1283 
1284 #endif
1285