1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docuno.cxx,v $
10 * $Revision: 1.68.52.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include "scitems.hxx"
37 #include <svx/fmdpage.hxx>
38 #include <svx/fmview.hxx>
39 #include <svx/svditer.hxx>
40 #include <svx/svdpage.hxx>
41 #include <svx/svxids.hrc>
43 #include <svtools/numuno.hxx>
44 #include <svtools/smplhint.hxx>
45 #include <svtools/undoopt.hxx>
46 #include <sfx2/printer.hxx>
47 #include <sfx2/bindings.hxx>
48 #include <vcl/pdfextoutdevdata.hxx>
49 #include <vcl/waitobj.hxx>
50 #include <unotools/charclass.hxx>
51 #include <tools/multisel.hxx>
52 #include <toolkit/awt/vclxdevice.hxx>
54 #include <float.h> // DBL_MAX
56 #include <com/sun/star/util/Date.hpp>
57 #include <com/sun/star/sheet/XNamedRanges.hpp>
58 #include <com/sun/star/sheet/XLabelRanges.hpp>
59 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
60 #include <com/sun/star/script/XLibraryContainer.hpp>
61 #include <com/sun/star/lang/XInitialization.hpp>
62 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
63 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
64 #include <com/sun/star/script/XInvocation.hpp>
65 #include <com/sun/star/reflection/XIdlClassProvider.hpp>
66 #include <comphelper/processfactory.hxx>
69 #include "cellsuno.hxx"
70 #include "nameuno.hxx"
71 #include "datauno.hxx"
72 #include "miscuno.hxx"
73 #include "notesuno.hxx"
74 #include "styleuno.hxx"
75 #include "linkuno.hxx"
76 #include "servuno.hxx"
77 #include "targuno.hxx"
78 #include "convuno.hxx"
80 #include "forbiuno.hxx"
83 #include "docfunc.hxx"
84 #include "dociter.hxx"
86 #include "drwlayer.hxx"
87 #include "rangeutl.hxx"
88 #include "markdata.hxx"
89 #include "docoptio.hxx"
90 #include "unoguard.hxx"
91 #include "unonames.hxx"
92 #include "shapeuno.hxx"
93 #include "printfun.hxx"
94 #include "pfuncache.hxx"
96 #include "rangeutl.hxx"
97 #include "ViewSettingsSequenceDefines.hxx"
99 #ifndef _SVX_UNOSHAPE_HXX
100 #include <svx/unoshape.hxx>
103 #include <com/sun/star/document/XVbaEventsHelper.hpp>
104 #include <com/sun/star/document/VbaEventId.hpp>
105 using namespace com::sun::star
;
106 using namespace com::sun::star::document::VbaEventId
;
108 #define SC_UNO_VBADOCOBJ "ThisVBADocObj" // perhaps we want to actually make this ThisWorkbook ?
109 //------------------------------------------------------------------------
111 // alles ohne Which-ID, Map nur fuer PropertySetInfo
113 //! umbenennen, sind nicht mehr nur Options
114 const SfxItemPropertyMapEntry
* lcl_GetDocOptPropertyMap()
116 static SfxItemPropertyMapEntry aDocOptPropertyMap_Impl
[] =
118 {MAP_CHAR_LEN(SC_UNO_APPLYFMDES
), 0, &getBooleanCppuType(), 0, 0},
119 {MAP_CHAR_LEN(SC_UNO_AREALINKS
), 0, &getCppuType((uno::Reference
<sheet::XAreaLinks
>*)0), 0, 0},
120 {MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC
), 0, &getBooleanCppuType(), 0, 0},
121 {MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES
), 0, &getCppuType((uno::Reference
< script::XLibraryContainer
>*)0), beans::PropertyAttribute::READONLY
, 0},
122 {MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES
), 0, &getCppuType((uno::Reference
< script::XLibraryContainer
>*)0), beans::PropertyAttribute::READONLY
, 0},
123 {MAP_CHAR_LEN(SC_UNO_VBADOCOBJ
), 0, &getCppuType((beans::PropertyValue
*)0), beans::PropertyAttribute::READONLY
, 0},
124 {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN
), PROP_UNO_CALCASSHOWN
, &getBooleanCppuType(), 0, 0},
125 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL
), 0, &getCppuType((lang::Locale
*)0), 0, 0},
126 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL
), 0, &getCppuType((lang::Locale
*)0), 0, 0},
127 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL
), 0, &getCppuType((lang::Locale
*)0), 0, 0},
128 {MAP_CHAR_LEN(SC_UNO_COLLABELRNG
), 0, &getCppuType((uno::Reference
<sheet::XLabelRanges
>*)0), 0, 0},
129 {MAP_CHAR_LEN(SC_UNO_DDELINKS
), 0, &getCppuType((uno::Reference
<container::XNameAccess
>*)0), 0, 0},
130 {MAP_CHAR_LEN(SC_UNO_DEFTABSTOP
), PROP_UNO_DEFTABSTOP
, &getCppuType((sal_Int16
*)0), 0, 0},
131 {MAP_CHAR_LEN(SC_UNO_EXTERNALDOCLINKS
), 0, &getCppuType((uno::Reference
<sheet::XExternalDocLinks
>*)0), 0, 0},
132 {MAP_CHAR_LEN(SC_UNO_FORBIDDEN
), 0, &getCppuType((uno::Reference
<i18n::XForbiddenCharacters
>*)0), beans::PropertyAttribute::READONLY
, 0},
133 {MAP_CHAR_LEN(SC_UNO_HASDRAWPAGES
), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY
, 0},
134 {MAP_CHAR_LEN(SC_UNO_IGNORECASE
), PROP_UNO_IGNORECASE
, &getBooleanCppuType(), 0, 0},
135 {MAP_CHAR_LEN(SC_UNO_ITERENABLED
), PROP_UNO_ITERENABLED
, &getBooleanCppuType(), 0, 0},
136 {MAP_CHAR_LEN(SC_UNO_ITERCOUNT
), PROP_UNO_ITERCOUNT
, &getCppuType((sal_Int32
*)0), 0, 0},
137 {MAP_CHAR_LEN(SC_UNO_ITEREPSILON
), PROP_UNO_ITEREPSILON
, &getCppuType((double*)0), 0, 0},
138 {MAP_CHAR_LEN(SC_UNO_LOOKUPLABELS
), PROP_UNO_LOOKUPLABELS
, &getBooleanCppuType(), 0, 0},
139 {MAP_CHAR_LEN(SC_UNO_MATCHWHOLE
), PROP_UNO_MATCHWHOLE
, &getBooleanCppuType(), 0, 0},
140 {MAP_CHAR_LEN(SC_UNO_NAMEDRANGES
), 0, &getCppuType((uno::Reference
<sheet::XNamedRanges
>*)0), 0, 0},
141 {MAP_CHAR_LEN(SC_UNO_DATABASERNG
), 0, &getCppuType((uno::Reference
<sheet::XDatabaseRanges
>*)0), 0, 0},
142 {MAP_CHAR_LEN(SC_UNO_NULLDATE
), PROP_UNO_NULLDATE
, &getCppuType((util::Date
*)0), 0, 0},
143 {MAP_CHAR_LEN(SC_UNO_ROWLABELRNG
), 0, &getCppuType((uno::Reference
<sheet::XLabelRanges
>*)0), 0, 0},
144 {MAP_CHAR_LEN(SC_UNO_SHEETLINKS
), 0, &getCppuType((uno::Reference
<container::XNameAccess
>*)0), 0, 0},
145 {MAP_CHAR_LEN(SC_UNO_SPELLONLINE
), PROP_UNO_SPELLONLINE
, &getBooleanCppuType(), 0, 0},
146 {MAP_CHAR_LEN(SC_UNO_STANDARDDEC
), PROP_UNO_STANDARDDEC
, &getCppuType((sal_Int16
*)0), 0, 0},
147 {MAP_CHAR_LEN(SC_UNO_REGEXENABLED
), PROP_UNO_REGEXENABLED
, &getBooleanCppuType(), 0, 0},
148 {MAP_CHAR_LEN(SC_UNO_RUNTIMEUID
), 0, &getCppuType(static_cast< const rtl::OUString
* >(0)), beans::PropertyAttribute::READONLY
, 0},
149 {MAP_CHAR_LEN(SC_UNO_HASVALIDSIGNATURES
),0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY
, 0},
150 {MAP_CHAR_LEN(SC_UNO_ISLOADED
), 0, &getBooleanCppuType(), 0, 0},
151 {MAP_CHAR_LEN(SC_UNO_ISUNDOENABLED
), 0, &getBooleanCppuType(), 0, 0},
152 {MAP_CHAR_LEN(SC_UNO_ISADJUSTHEIGHTENABLED
), 0, &getBooleanCppuType(), 0, 0},
153 {MAP_CHAR_LEN(SC_UNO_ISEXECUTELINKENABLED
), 0, &getBooleanCppuType(), 0, 0},
154 {MAP_CHAR_LEN(SC_UNO_ISCHANGEREADONLYENABLED
), 0, &getBooleanCppuType(), 0, 0},
155 {MAP_CHAR_LEN(SC_UNO_REFERENCEDEVICE
), 0, &getCppuType((uno::Reference
<awt::XDevice
>*)0), beans::PropertyAttribute::READONLY
, 0},
156 {MAP_CHAR_LEN("BuildId"), 0, &::getCppuType(static_cast< const rtl::OUString
* >(0)), 0, 0},
160 return aDocOptPropertyMap_Impl
;
163 //! StandardDecimals als Property und vom NumberFormatter ????????
165 const SfxItemPropertyMapEntry
* lcl_GetColumnsPropertyMap()
167 static SfxItemPropertyMapEntry aColumnsPropertyMap_Impl
[] =
169 {MAP_CHAR_LEN(SC_UNONAME_MANPAGE
), 0, &getBooleanCppuType(), 0, 0 },
170 {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE
), 0, &getBooleanCppuType(), 0, 0 },
171 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS
), 0, &getBooleanCppuType(), 0, 0 },
172 {MAP_CHAR_LEN(SC_UNONAME_OWIDTH
), 0, &getBooleanCppuType(), 0, 0 },
173 {MAP_CHAR_LEN(SC_UNONAME_CELLWID
), 0, &getCppuType((sal_Int32
*)0), 0, 0 },
176 return aColumnsPropertyMap_Impl
;
179 const SfxItemPropertyMapEntry
* lcl_GetRowsPropertyMap()
181 static SfxItemPropertyMapEntry aRowsPropertyMap_Impl
[] =
183 {MAP_CHAR_LEN(SC_UNONAME_CELLHGT
), 0, &getCppuType((sal_Int32
*)0), 0, 0 },
184 {MAP_CHAR_LEN(SC_UNONAME_CELLFILT
), 0, &getBooleanCppuType(), 0, 0 },
185 {MAP_CHAR_LEN(SC_UNONAME_OHEIGHT
), 0, &getBooleanCppuType(), 0, 0 },
186 {MAP_CHAR_LEN(SC_UNONAME_MANPAGE
), 0, &getBooleanCppuType(), 0, 0 },
187 {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE
), 0, &getBooleanCppuType(), 0, 0 },
188 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS
), 0, &getBooleanCppuType(), 0, 0 },
189 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK
), ATTR_BACKGROUND
, &::getCppuType((const sal_Int32
*)0), 0, MID_BACK_COLOR
},
190 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN
), ATTR_BACKGROUND
, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT
},
191 // not sorted, not used with SfxItemPropertyMapEntry::GetByName
194 return aRowsPropertyMap_Impl
;
197 //! move these functions to a header file
198 inline long TwipsToHMM(long nTwips
) { return (nTwips
* 127 + 36) / 72; }
199 inline long HMMToTwips(long nHMM
) { return (nHMM
* 72 + 63) / 127; }
201 //------------------------------------------------------------------------
203 #define SCMODELOBJ_SERVICE "com.sun.star.sheet.SpreadsheetDocument"
204 #define SCDOCSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetDocumentSettings"
205 #define SCDOC_SERVICE "com.sun.star.document.OfficeDocument"
207 SC_SIMPLE_SERVICE_INFO( ScAnnotationsObj
, "ScAnnotationsObj", "com.sun.star.sheet.CellAnnotations" )
208 SC_SIMPLE_SERVICE_INFO( ScDrawPagesObj
, "ScDrawPagesObj", "com.sun.star.drawing.DrawPages" )
209 SC_SIMPLE_SERVICE_INFO( ScScenariosObj
, "ScScenariosObj", "com.sun.star.sheet.Scenarios" )
210 SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettingsObj
, "ScSpreadsheetSettingsObj", "com.sun.star.sheet.SpreadsheetDocumentSettings" )
211 SC_SIMPLE_SERVICE_INFO( ScTableColumnsObj
, "ScTableColumnsObj", "com.sun.star.table.TableColumns" )
212 SC_SIMPLE_SERVICE_INFO( ScTableRowsObj
, "ScTableRowsObj", "com.sun.star.table.TableRows" )
213 SC_SIMPLE_SERVICE_INFO( ScTableSheetsObj
, "ScTableSheetsObj", "com.sun.star.sheet.Spreadsheets" )
215 //------------------------------------------------------------------------
218 void ScModelObj::CreateAndSet(ScDocShell
* pDocSh
)
221 pDocSh
->SetBaseModel( new ScModelObj(pDocSh
) );
224 ScModelObj::ScModelObj( ScDocShell
* pDocSh
) :
225 SfxBaseModel( pDocSh
),
226 aPropSet( lcl_GetDocOptPropertyMap() ),
228 pPrintFuncCache( NULL
),
229 maChangesListeners( m_aMutex
),
230 mnXlsWriteProtPass( 0 )
232 // pDocShell may be NULL if this is the base of a ScDocOptionsObj
235 pDocShell
->GetDocument()->AddUnoObject(*this); // SfxModel is derived from SfxListener
239 ScModelObj::~ScModelObj()
242 pDocShell
->GetDocument()->RemoveUnoObject(*this);
245 xNumberAgg
->setDelegator(uno::Reference
<uno::XInterface
>());
247 delete pPrintFuncCache
;
250 uno::Reference
< uno::XAggregation
> ScModelObj::GetFormatter()
252 if ( !xNumberAgg
.is() )
254 // setDelegator veraendert den RefCount, darum eine Referenz selber halten
255 // (direkt am m_refCount, um sich beim release nicht selbst zu loeschen)
256 comphelper::increment( m_refCount
);
257 // waehrend des queryInterface braucht man ein Ref auf das
258 // SvNumberFormatsSupplierObj, sonst wird es geloescht.
259 uno::Reference
<util::XNumberFormatsSupplier
> xFormatter(new SvNumberFormatsSupplierObj(pDocShell
->GetDocument()->GetFormatTable() ));
261 xNumberAgg
.set(uno::Reference
<uno::XAggregation
>( xFormatter
, uno::UNO_QUERY
));
262 // extra block to force deletion of the temporary before setDelegator
265 // beim setDelegator darf die zusaetzliche Ref nicht mehr existieren
269 xNumberAgg
->setDelegator( (cppu::OWeakObject
*)this );
270 comphelper::decrement( m_refCount
);
271 } // if ( !xNumberAgg.is() )
275 ScDocument
* ScModelObj::GetDocument() const
278 return pDocShell
->GetDocument();
282 SfxObjectShell
* ScModelObj::GetEmbeddedObject() const
287 void ScModelObj::UpdateAllRowHeights(const ScMarkData
* pTabMark
)
290 pDocShell
->UpdateAllRowHeights(pTabMark
);
293 void ScModelObj::BeforeXMLLoading()
296 pDocShell
->BeforeXMLLoading();
299 void ScModelObj::AfterXMLLoading(sal_Bool bRet
)
302 pDocShell
->AfterXMLLoading(bRet
);
305 ScSheetSaveData
* ScModelObj::GetSheetSaveData()
308 return pDocShell
->GetSheetSaveData();
312 uno::Any SAL_CALL
ScModelObj::queryInterface( const uno::Type
& rType
)
313 throw(uno::RuntimeException
)
315 SC_QUERYINTERFACE( sheet::XSpreadsheetDocument
)
316 SC_QUERYINTERFACE( document::XActionLockable
)
317 SC_QUERYINTERFACE( sheet::XCalculatable
)
318 SC_QUERYINTERFACE( util::XProtectable
)
319 SC_QUERYINTERFACE( drawing::XDrawPagesSupplier
)
320 SC_QUERYINTERFACE( sheet::XGoalSeek
)
321 SC_QUERYINTERFACE( sheet::XConsolidatable
)
322 SC_QUERYINTERFACE( sheet::XDocumentAuditing
)
323 SC_QUERYINTERFACE( style::XStyleFamiliesSupplier
)
324 SC_QUERYINTERFACE( view::XRenderable
)
325 SC_QUERYINTERFACE( document::XLinkTargetSupplier
)
326 SC_QUERYINTERFACE( beans::XPropertySet
)
327 SC_QUERYINTERFACE( document::XDocumentEventCompatibleHelper
)
328 SC_QUERYINTERFACE( lang::XMultiServiceFactory
)
329 SC_QUERYINTERFACE( lang::XServiceInfo
)
330 SC_QUERYINTERFACE( util::XChangesNotifier
)
332 uno::Any
aRet(SfxBaseModel::queryInterface( rType
));
333 if ( !aRet
.hasValue()
334 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::document::XDocumentEventBroadcaster
>*)0)
335 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::frame::XController
>*)0)
336 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::frame::XFrame
>*)0)
337 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::script::XInvocation
>*)0)
338 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::reflection::XIdlClassProvider
>*)0)
339 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::beans::XFastPropertySet
>*)0)
340 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::awt::XWindow
>*)0))
343 if ( xNumberAgg
.is() )
344 aRet
= xNumberAgg
->queryAggregation( rType
);
350 void SAL_CALL
ScModelObj::acquire() throw()
352 SfxBaseModel::acquire();
355 void SAL_CALL
ScModelObj::release() throw()
357 SfxBaseModel::release();
360 uno::Sequence
<uno::Type
> SAL_CALL
ScModelObj::getTypes() throw(uno::RuntimeException
)
362 static uno::Sequence
<uno::Type
> aTypes
;
363 if ( aTypes
.getLength() == 0 )
365 uno::Sequence
<uno::Type
> aParentTypes(SfxBaseModel::getTypes());
366 long nParentLen
= aParentTypes
.getLength();
367 const uno::Type
* pParentPtr
= aParentTypes
.getConstArray();
369 uno::Sequence
<uno::Type
> aAggTypes
;
370 if ( GetFormatter().is() )
372 const uno::Type
& rProvType
= ::getCppuType((uno::Reference
<lang::XTypeProvider
>*) 0);
373 uno::Any
aNumProv(xNumberAgg
->queryAggregation(rProvType
));
374 if(aNumProv
.getValueType() == rProvType
)
376 uno::Reference
<lang::XTypeProvider
> xNumProv(
377 *(uno::Reference
<lang::XTypeProvider
>*)aNumProv
.getValue());
378 aAggTypes
= xNumProv
->getTypes();
381 long nAggLen
= aAggTypes
.getLength();
382 const uno::Type
* pAggPtr
= aAggTypes
.getConstArray();
384 const long nThisLen
= 15;
385 aTypes
.realloc( nParentLen
+ nAggLen
+ nThisLen
);
386 uno::Type
* pPtr
= aTypes
.getArray();
387 pPtr
[nParentLen
+ 0] = getCppuType((const uno::Reference
<sheet::XSpreadsheetDocument
>*)0);
388 pPtr
[nParentLen
+ 1] = getCppuType((const uno::Reference
<document::XActionLockable
>*)0);
389 pPtr
[nParentLen
+ 2] = getCppuType((const uno::Reference
<sheet::XCalculatable
>*)0);
390 pPtr
[nParentLen
+ 3] = getCppuType((const uno::Reference
<util::XProtectable
>*)0);
391 pPtr
[nParentLen
+ 4] = getCppuType((const uno::Reference
<drawing::XDrawPagesSupplier
>*)0);
392 pPtr
[nParentLen
+ 5] = getCppuType((const uno::Reference
<sheet::XGoalSeek
>*)0);
393 pPtr
[nParentLen
+ 6] = getCppuType((const uno::Reference
<sheet::XConsolidatable
>*)0);
394 pPtr
[nParentLen
+ 7] = getCppuType((const uno::Reference
<sheet::XDocumentAuditing
>*)0);
395 pPtr
[nParentLen
+ 8] = getCppuType((const uno::Reference
<style::XStyleFamiliesSupplier
>*)0);
396 pPtr
[nParentLen
+ 9] = getCppuType((const uno::Reference
<view::XRenderable
>*)0);
397 pPtr
[nParentLen
+10] = getCppuType((const uno::Reference
<document::XLinkTargetSupplier
>*)0);
398 pPtr
[nParentLen
+11] = getCppuType((const uno::Reference
<beans::XPropertySet
>*)0);
399 pPtr
[nParentLen
+12] = getCppuType((const uno::Reference
<lang::XMultiServiceFactory
>*)0);
400 pPtr
[nParentLen
+13] = getCppuType((const uno::Reference
<lang::XServiceInfo
>*)0);
401 pPtr
[nParentLen
+14] = getCppuType((const uno::Reference
<util::XChangesNotifier
>*)0);
404 for (i
=0; i
<nParentLen
; i
++)
405 pPtr
[i
] = pParentPtr
[i
]; // parent types first
407 for (i
=0; i
<nAggLen
; i
++)
408 pPtr
[nParentLen
+nThisLen
+i
] = pAggPtr
[i
]; // aggregated types last
413 uno::Sequence
<sal_Int8
> SAL_CALL
ScModelObj::getImplementationId()
414 throw(uno::RuntimeException
)
416 static uno::Sequence
< sal_Int8
> aId
;
417 if( aId
.getLength() == 0 )
420 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
425 void ScModelObj::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
427 // Not interested in reference update hints here
429 if ( rHint
.ISA( SfxSimpleHint
) )
431 ULONG nId
= ((const SfxSimpleHint
&)rHint
).GetId();
432 if ( nId
== SFX_HINT_DYING
)
434 pDocShell
= NULL
; // has become invalid
437 SvNumberFormatsSupplierObj
* pNumFmt
=
438 SvNumberFormatsSupplierObj::getImplementation(
439 uno::Reference
<util::XNumberFormatsSupplier
>(xNumberAgg
, uno::UNO_QUERY
) );
441 pNumFmt
->SetNumberFormatter( NULL
);
444 DELETEZ( pPrintFuncCache
); // must be deleted because it has a pointer to the DocShell
446 else if ( nId
== SFX_HINT_DATACHANGED
)
448 // cached data for rendering become invalid when contents change
449 // (if a broadcast is added to SetDrawModified, is has to be tested here, too)
451 DELETEZ( pPrintFuncCache
);
454 else if ( rHint
.ISA( ScPointerChangedHint
) )
456 USHORT nFlags
= ((const ScPointerChangedHint
&)rHint
).GetFlags();
457 if (nFlags
& SC_POINTERCHANGED_NUMFMT
)
459 // NumberFormatter-Pointer am Uno-Objekt neu setzen
461 if (GetFormatter().is())
463 SvNumberFormatsSupplierObj
* pNumFmt
=
464 SvNumberFormatsSupplierObj::getImplementation(
465 uno::Reference
<util::XNumberFormatsSupplier
>(xNumberAgg
, uno::UNO_QUERY
) );
466 if ( pNumFmt
&& pDocShell
)
467 pNumFmt
->SetNumberFormatter( pDocShell
->GetDocument()->GetFormatTable() );
472 // always call parent - SfxBaseModel might need to handle the same hints again
473 SfxBaseModel::Notify( rBC
, rHint
); // SfxBaseModel is derived from SfxListener
476 // XSpreadsheetDocument
478 uno::Reference
<sheet::XSpreadsheets
> SAL_CALL
ScModelObj::getSheets() throw(uno::RuntimeException
)
482 return new ScTableSheetsObj(pDocShell
);
486 // XStyleFamiliesSupplier
488 uno::Reference
<container::XNameAccess
> SAL_CALL
ScModelObj::getStyleFamilies()
489 throw(uno::RuntimeException
)
493 return new ScStyleFamiliesObj(pDocShell
);
499 OutputDevice
* lcl_GetRenderDevice( const uno::Sequence
<beans::PropertyValue
>& rOptions
)
501 OutputDevice
* pRet
= NULL
;
502 const beans::PropertyValue
* pPropArray
= rOptions
.getConstArray();
503 long nPropCount
= rOptions
.getLength();
504 for (long i
= 0; i
< nPropCount
; i
++)
506 const beans::PropertyValue
& rProp
= pPropArray
[i
];
507 String
aPropName(rProp
.Name
);
509 if (aPropName
.EqualsAscii( SC_UNONAME_RENDERDEV
))
511 uno::Reference
<awt::XDevice
> xRenderDevice(rProp
.Value
, uno::UNO_QUERY
);
512 if ( xRenderDevice
.is() )
514 VCLXDevice
* pDevice
= VCLXDevice::GetImplementation( xRenderDevice
);
517 pRet
= pDevice
->GetOutputDevice();
518 pRet
->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
526 bool lcl_ParseTarget( const String
& rTarget
, ScRange
& rTargetRange
, Rectangle
& rTargetRect
,
527 bool& rIsSheet
, ScDocument
* pDoc
, SCTAB nSourceTab
)
529 // test in same order as in SID_CURRENTCELL execute
532 ScRangeUtil aRangeUtil
;
534 sal_Int32 nNumeric
= 0;
536 bool bRangeValid
= false;
537 bool bRectValid
= false;
539 if ( rTargetRange
.Parse( rTarget
, pDoc
) & SCA_VALID
)
541 bRangeValid
= true; // range reference
543 else if ( aAddress
.Parse( rTarget
, pDoc
) & SCA_VALID
)
545 rTargetRange
= aAddress
;
546 bRangeValid
= true; // cell reference
548 else if ( aRangeUtil
.MakeRangeFromName( rTarget
, pDoc
, nSourceTab
, rTargetRange
, RUTL_NAMES
) ||
549 aRangeUtil
.MakeRangeFromName( rTarget
, pDoc
, nSourceTab
, rTargetRange
, RUTL_DBASE
) )
551 bRangeValid
= true; // named range or database range
553 else if ( ByteString( rTarget
, RTL_TEXTENCODING_ASCII_US
).IsNumericAscii() &&
554 ( nNumeric
= rTarget
.ToInt32() ) > 0 && nNumeric
<= MAXROW
+1 )
556 // row number is always mapped to cell A(row) on the same sheet
557 rTargetRange
= ScAddress( 0, (SCROW
)(nNumeric
-1), nSourceTab
); // target row number is 1-based
558 bRangeValid
= true; // row number
560 else if ( pDoc
->GetTable( rTarget
, nNameTab
) )
562 rTargetRange
= ScAddress(0,0,nNameTab
);
563 bRangeValid
= true; // sheet name
564 rIsSheet
= true; // needs special handling (first page of the sheet)
568 // look for named drawing object
570 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
573 SCTAB nTabCount
= pDoc
->GetTableCount();
574 for (SCTAB i
=0; i
<nTabCount
&& !bRangeValid
; i
++)
576 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(i
));
577 DBG_ASSERT(pPage
,"Page ?");
580 SdrObjListIter
aIter( *pPage
, IM_DEEPWITHGROUPS
);
581 SdrObject
* pObject
= aIter
.Next();
582 while (pObject
&& !bRangeValid
)
584 if ( ScDrawLayer::GetVisibleName( pObject
) == rTarget
)
586 rTargetRect
= pObject
->GetLogicRect(); // 1/100th mm
587 rTargetRange
= pDoc
->GetRange( i
, rTargetRect
); // underlying cells
588 bRangeValid
= bRectValid
= true; // rectangle is valid
590 pObject
= aIter
.Next();
596 if ( bRangeValid
&& !bRectValid
)
598 // get rectangle for cell range
599 rTargetRect
= pDoc
->GetMMRect( rTargetRange
.aStart
.Col(), rTargetRange
.aStart
.Row(),
600 rTargetRange
.aEnd
.Col(), rTargetRange
.aEnd
.Row(),
601 rTargetRange
.aStart
.Tab() );
607 BOOL
ScModelObj::FillRenderMarkData( const uno::Any
& aSelection
, ScMarkData
& rMark
,
608 ScPrintSelectionStatus
& rStatus
) const
610 DBG_ASSERT( !rMark
.IsMarked() && !rMark
.IsMultiMarked(), "FillRenderMarkData: MarkData must be empty" );
611 DBG_ASSERT( pDocShell
, "FillRenderMarkData: DocShell must be set" );
615 uno::Reference
<uno::XInterface
> xInterface(aSelection
, uno::UNO_QUERY
);
616 if ( xInterface
.is() )
618 ScCellRangesBase
* pSelObj
= ScCellRangesBase::getImplementation( xInterface
);
619 uno::Reference
< drawing::XShapes
> xShapes( xInterface
, uno::UNO_QUERY
);
621 if ( pSelObj
&& pSelObj
->GetDocShell() == pDocShell
)
623 BOOL bSheet
= ( ScTableSheetObj::getImplementation( xInterface
) != NULL
);
624 BOOL bCursor
= pSelObj
->IsCursorOnly();
625 const ScRangeList
& rRanges
= pSelObj
->GetRangeList();
627 rMark
.MarkFromRangeList( rRanges
, FALSE
);
628 rMark
.MarkToSimple();
630 if ( rMark
.IsMarked() && !rMark
.IsMultiMarked() )
632 // a sheet object is treated like an empty selection: print the used area of the sheet
634 if ( bCursor
|| bSheet
) // nothing selected -> use whole tables
636 rMark
.ResetMark(); // doesn't change table selection
637 rStatus
.SetMode( SC_PRINTSEL_CURSOR
);
640 rStatus
.SetMode( SC_PRINTSEL_RANGE
);
642 rStatus
.SetRanges( rRanges
);
645 // multi selection isn't supported
647 else if( xShapes
.is() )
649 //print a selected ole object
650 uno::Reference
< container::XIndexAccess
> xIndexAccess( xShapes
, uno::UNO_QUERY
);
651 if( xIndexAccess
.is() )
653 // multi selection isn't supported yet
654 uno::Reference
< drawing::XShape
> xShape( xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
655 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
658 SdrObject
*pSdrObj
= pShape
->GetSdrObject();
661 ScDocument
* pDoc
= pDocShell
->GetDocument();
662 if( pDoc
&& pSdrObj
)
664 Rectangle aObjRect
= pSdrObj
->GetCurrentBoundRect();
665 SCTAB nCurrentTab
= ScDocShell::GetCurTab();
666 ScRange aRange
= pDoc
->GetRange( nCurrentTab
, aObjRect
);
667 rMark
.SetMarkArea( aRange
);
669 if( rMark
.IsMarked() && !rMark
.IsMultiMarked() )
671 rStatus
.SetMode( SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
);
679 else if ( ScModelObj::getImplementation( xInterface
) == this )
681 // render the whole document
682 // -> no selection, all sheets
684 SCTAB nTabCount
= pDocShell
->GetDocument()->GetTableCount();
685 for (SCTAB nTab
= 0; nTab
< nTabCount
; nTab
++)
686 rMark
.SelectTable( nTab
, TRUE
);
687 rStatus
.SetMode( SC_PRINTSEL_DOCUMENT
);
690 // other selection types aren't supported
697 sal_Int32 SAL_CALL
ScModelObj::getRendererCount( const uno::Any
& aSelection
,
698 const uno::Sequence
<beans::PropertyValue
>& /* xOptions */ )
699 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
703 throw uno::RuntimeException();
706 ScPrintSelectionStatus aStatus
;
707 if ( !FillRenderMarkData( aSelection
, aMark
, aStatus
) )
710 // The same ScPrintFuncCache object in pPrintFuncCache is used as long as
711 // the same selection is used (aStatus) and the document isn't changed
712 // (pPrintFuncCache is cleared in Notify handler)
714 if ( !pPrintFuncCache
|| !pPrintFuncCache
->IsSameSelection( aStatus
) )
716 delete pPrintFuncCache
;
717 pPrintFuncCache
= new ScPrintFuncCache( pDocShell
, aMark
, aStatus
);
719 return pPrintFuncCache
->GetPageCount();
722 uno::Sequence
<beans::PropertyValue
> SAL_CALL
ScModelObj::getRenderer( sal_Int32 nRenderer
,
723 const uno::Any
& aSelection
, const uno::Sequence
<beans::PropertyValue
>& /* xOptions */ )
724 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
728 throw uno::RuntimeException();
731 ScPrintSelectionStatus aStatus
;
732 if ( !FillRenderMarkData( aSelection
, aMark
, aStatus
) )
733 throw lang::IllegalArgumentException();
735 if ( !pPrintFuncCache
|| !pPrintFuncCache
->IsSameSelection( aStatus
) )
737 delete pPrintFuncCache
;
738 pPrintFuncCache
= new ScPrintFuncCache( pDocShell
, aMark
, aStatus
);
740 long nTotalPages
= pPrintFuncCache
->GetPageCount();
741 if ( nRenderer
>= nTotalPages
)
742 throw lang::IllegalArgumentException();
744 // printer is used as device (just for page layout), draw view is not needed
746 SCTAB nTab
= pPrintFuncCache
->GetTabForPage( nRenderer
);
749 const ScRange
* pSelRange
= NULL
;
750 if ( aMark
.IsMarked() )
752 aMark
.GetMarkArea( aRange
);
755 ScPrintFunc
aFunc( pDocShell
, pDocShell
->GetPrinter(), nTab
,
756 pPrintFuncCache
->GetFirstAttr(nTab
), nTotalPages
, pSelRange
);
757 aFunc
.SetRenderFlag( TRUE
);
759 Range
aPageRange( nRenderer
+1, nRenderer
+1 );
760 MultiSelection
aPage( aPageRange
);
761 aPage
.SetTotalRange( Range(0,RANGE_MAX
) );
762 aPage
.Select( aPageRange
);
764 long nDisplayStart
= pPrintFuncCache
->GetDisplayStart( nTab
);
765 long nTabStart
= pPrintFuncCache
->GetTabStart( nTab
);
767 (void)aFunc
.DoPrint( aPage
, nTabStart
, nDisplayStart
, FALSE
, NULL
, NULL
);
770 BOOL bWasCellRange
= aFunc
.GetLastSourceRange( aCellRange
);
771 Size aTwips
= aFunc
.GetPageSize();
772 awt::Size
aPageSize( TwipsToHMM( aTwips
.Width() ), TwipsToHMM( aTwips
.Height() ) );
774 long nPropCount
= bWasCellRange
? 2 : 1;
775 uno::Sequence
<beans::PropertyValue
> aSequence(nPropCount
);
776 beans::PropertyValue
* pArray
= aSequence
.getArray();
777 pArray
[0].Name
= rtl::OUString::createFromAscii( SC_UNONAME_PAGESIZE
);
778 pArray
[0].Value
<<= aPageSize
;
781 table::CellRangeAddress
aRangeAddress( nTab
,
782 aCellRange
.aStart
.Col(), aCellRange
.aStart
.Row(),
783 aCellRange
.aEnd
.Col(), aCellRange
.aEnd
.Row() );
784 pArray
[1].Name
= rtl::OUString::createFromAscii( SC_UNONAME_SOURCERANGE
);
785 pArray
[1].Value
<<= aRangeAddress
;
790 void SAL_CALL
ScModelObj::render( sal_Int32 nRenderer
, const uno::Any
& aSelection
,
791 const uno::Sequence
<beans::PropertyValue
>& rOptions
)
792 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
796 throw uno::RuntimeException();
799 ScPrintSelectionStatus aStatus
;
800 if ( !FillRenderMarkData( aSelection
, aMark
, aStatus
) )
801 throw lang::IllegalArgumentException();
803 if ( !pPrintFuncCache
|| !pPrintFuncCache
->IsSameSelection( aStatus
) )
805 delete pPrintFuncCache
;
806 pPrintFuncCache
= new ScPrintFuncCache( pDocShell
, aMark
, aStatus
);
808 long nTotalPages
= pPrintFuncCache
->GetPageCount();
809 if ( nRenderer
>= nTotalPages
)
810 throw lang::IllegalArgumentException();
812 OutputDevice
* pDev
= lcl_GetRenderDevice( rOptions
);
814 throw lang::IllegalArgumentException();
816 SCTAB nTab
= pPrintFuncCache
->GetTabForPage( nRenderer
);
817 ScDocument
* pDoc
= pDocShell
->GetDocument();
819 FmFormView
* pDrawView
= NULL
;
820 Rectangle
aFull( 0, 0, LONG_MAX
, LONG_MAX
);
823 ScDrawLayer
* pModel
= pDoc
->GetDrawLayer();
827 pDrawView
= new FmFormView( pModel
, pDev
);
828 pDrawView
->ShowSdrPage(pDrawView
->GetModel()->GetPage(nTab
));
829 pDrawView
->SetPrintPreview( TRUE
);
833 const ScRange
* pSelRange
= NULL
;
834 if ( aMark
.IsMarked() )
836 aMark
.GetMarkArea( aRange
);
840 // to increase performance, ScPrintState might be used here for subsequent
841 // pages of the same sheet
843 ScPrintFunc
aFunc( pDev
, pDocShell
, nTab
, pPrintFuncCache
->GetFirstAttr(nTab
), nTotalPages
, pSelRange
);
844 aFunc
.SetDrawView( pDrawView
);
845 aFunc
.SetRenderFlag( TRUE
);
846 if( aStatus
.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
)
847 aFunc
.SetExclusivelyDrawOleAndDrawObjects();
849 Range
aPageRange( nRenderer
+1, nRenderer
+1 );
850 MultiSelection
aPage( aPageRange
);
851 aPage
.SetTotalRange( Range(0,RANGE_MAX
) );
852 aPage
.Select( aPageRange
);
854 long nDisplayStart
= pPrintFuncCache
->GetDisplayStart( nTab
);
855 long nTabStart
= pPrintFuncCache
->GetTabStart( nTab
);
857 if ( nRenderer
== nTabStart
)
859 // first page of a sheet: add outline item for the sheet name
861 vcl::PDFExtOutDevData
* pPDFData
= PTR_CAST( vcl::PDFExtOutDevData
, pDev
->GetExtOutDevData() );
862 if ( pPDFData
&& pPDFData
->GetIsExportBookmarks() )
864 // the sheet starts at the top of the page
865 Rectangle
aArea( pDev
->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
866 sal_Int32 nDestID
= pPDFData
->CreateDest( aArea
);
868 pDoc
->GetName( nTab
, aTabName
);
869 sal_Int32 nParent
= -1; // top-level
870 pPDFData
->CreateOutlineItem( nParent
, aTabName
, nDestID
);
873 // add the named destination stuff
874 if( pPDFData
->GetIsExportNamedDestinations() )
876 Rectangle
aArea( pDev
->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
878 pDoc
->GetName( nTab
, aTabName
);
879 //need the PDF page number here
880 pPDFData
->CreateNamedDest( aTabName
, aArea
);
885 (void)aFunc
.DoPrint( aPage
, nTabStart
, nDisplayStart
, TRUE
, NULL
, NULL
);
887 // resolve the hyperlinks for PDF export
889 vcl::PDFExtOutDevData
* pPDFData
= PTR_CAST( vcl::PDFExtOutDevData
, pDev
->GetExtOutDevData() );
892 // iterate over the hyperlinks that were output for this page
894 std::vector
< vcl::PDFExtOutDevBookmarkEntry
>& rBookmarks
= pPDFData
->GetBookmarks();
895 std::vector
< vcl::PDFExtOutDevBookmarkEntry
>::iterator aIter
= rBookmarks
.begin();
896 std::vector
< vcl::PDFExtOutDevBookmarkEntry
>::iterator aIEnd
= rBookmarks
.end();
897 while ( aIter
!= aIEnd
)
899 rtl::OUString aBookmark
= aIter
->aBookmark
;
900 if ( aBookmark
.toChar() == (sal_Unicode
) '#' )
902 // try to resolve internal link
904 String
aTarget( aBookmark
.copy( 1 ) );
906 ScRange aTargetRange
;
907 Rectangle aTargetRect
; // 1/100th mm
908 bool bIsSheet
= false;
909 bool bValid
= lcl_ParseTarget( aTarget
, aTargetRange
, aTargetRect
, bIsSheet
, pDoc
, nTab
);
913 sal_Int32 nPage
= -1;
917 // Get first page for sheet (if nothing from that sheet is printed,
918 // this page can show a different sheet)
919 nPage
= pPrintFuncCache
->GetTabStart( aTargetRange
.aStart
.Tab() );
920 aArea
= pDev
->PixelToLogic( Rectangle( 0,0,0,0 ) );
924 pPrintFuncCache
->InitLocations( aMark
, pDev
); // does nothing if already initialized
926 ScPrintPageLocation aLocation
;
927 if ( pPrintFuncCache
->FindLocation( aTargetRange
.aStart
, aLocation
) )
929 nPage
= aLocation
.nPage
;
931 // get the rectangle of the page's cell range in 1/100th mm
932 ScRange aLocRange
= aLocation
.aCellRange
;
933 Rectangle aLocationMM
= pDoc
->GetMMRect(
934 aLocRange
.aStart
.Col(), aLocRange
.aStart
.Row(),
935 aLocRange
.aEnd
.Col(), aLocRange
.aEnd
.Row(),
936 aLocRange
.aStart
.Tab() );
937 Rectangle aLocationPixel
= aLocation
.aRectangle
;
939 // Scale and move the target rectangle from aLocationMM to aLocationPixel,
940 // to get the target rectangle in pixels.
942 Fraction
aScaleX( aLocationPixel
.GetWidth(), aLocationMM
.GetWidth() );
943 Fraction
aScaleY( aLocationPixel
.GetHeight(), aLocationMM
.GetHeight() );
945 long nX1
= aLocationPixel
.Left() + (long)
946 ( Fraction( aTargetRect
.Left() - aLocationMM
.Left(), 1 ) * aScaleX
);
947 long nX2
= aLocationPixel
.Left() + (long)
948 ( Fraction( aTargetRect
.Right() - aLocationMM
.Left(), 1 ) * aScaleX
);
949 long nY1
= aLocationPixel
.Top() + (long)
950 ( Fraction( aTargetRect
.Top() - aLocationMM
.Top(), 1 ) * aScaleY
);
951 long nY2
= aLocationPixel
.Top() + (long)
952 ( Fraction( aTargetRect
.Bottom() - aLocationMM
.Top(), 1 ) * aScaleY
);
954 if ( nX1
> aLocationPixel
.Right() ) nX1
= aLocationPixel
.Right();
955 if ( nX2
> aLocationPixel
.Right() ) nX2
= aLocationPixel
.Right();
956 if ( nY1
> aLocationPixel
.Bottom() ) nY1
= aLocationPixel
.Bottom();
957 if ( nY2
> aLocationPixel
.Bottom() ) nY2
= aLocationPixel
.Bottom();
959 // The link target area is interpreted using the device's MapMode at
960 // the time of the CreateDest call, so PixelToLogic can be used here,
961 // regardless of the MapMode that is actually selected.
963 aArea
= pDev
->PixelToLogic( Rectangle( nX1
, nY1
, nX2
, nY2
) );
968 pPDFData
->SetLinkDest( aIter
->nLinkId
, pPDFData
->CreateDest( aArea
, nPage
) );
973 // external link, use as-is
974 pPDFData
->SetLinkURL( aIter
->nLinkId
, aBookmark
);
984 // XLinkTargetSupplier
986 uno::Reference
<container::XNameAccess
> SAL_CALL
ScModelObj::getLinks() throw(uno::RuntimeException
)
990 return new ScLinkTargetTypesObj(pDocShell
);
996 sal_Bool SAL_CALL
ScModelObj::isActionLocked() throw(uno::RuntimeException
)
999 BOOL bLocked
= FALSE
;
1001 bLocked
= ( pDocShell
->GetLockCount() != 0 );
1005 void SAL_CALL
ScModelObj::addActionLock() throw(uno::RuntimeException
)
1009 pDocShell
->LockDocument();
1012 void SAL_CALL
ScModelObj::removeActionLock() throw(uno::RuntimeException
)
1016 pDocShell
->UnlockDocument();
1019 void SAL_CALL
ScModelObj::setActionLocks( sal_Int16 nLock
) throw(uno::RuntimeException
)
1023 pDocShell
->SetLockCount(nLock
);
1026 sal_Int16 SAL_CALL
ScModelObj::resetActionLocks() throw(uno::RuntimeException
)
1032 nRet
= pDocShell
->GetLockCount();
1033 pDocShell
->SetLockCount(0);
1038 void SAL_CALL
ScModelObj::lockControllers() throw (::com::sun::star::uno::RuntimeException
)
1041 SfxBaseModel::lockControllers();
1043 pDocShell
->LockPaint();
1046 void SAL_CALL
ScModelObj::unlockControllers() throw (::com::sun::star::uno::RuntimeException
)
1049 if (hasControllersLocked())
1051 SfxBaseModel::unlockControllers();
1053 pDocShell
->UnlockPaint();
1059 void SAL_CALL
ScModelObj::calculate() throw(uno::RuntimeException
)
1063 pDocShell
->DoRecalc(TRUE
);
1066 DBG_ERROR("keine DocShell"); //! Exception oder so?
1070 void SAL_CALL
ScModelObj::calculateAll() throw(uno::RuntimeException
)
1074 pDocShell
->DoHardRecalc(TRUE
);
1077 DBG_ERROR("keine DocShell"); //! Exception oder so?
1081 sal_Bool SAL_CALL
ScModelObj::isAutomaticCalculationEnabled() throw(uno::RuntimeException
)
1085 return pDocShell
->GetDocument()->GetAutoCalc();
1087 DBG_ERROR("keine DocShell"); //! Exception oder so?
1091 void SAL_CALL
ScModelObj::enableAutomaticCalculation( sal_Bool bEnabled
)
1092 throw(uno::RuntimeException
)
1097 ScDocument
* pDoc
= pDocShell
->GetDocument();
1098 if ( pDoc
->GetAutoCalc() != bEnabled
)
1100 pDoc
->SetAutoCalc( bEnabled
);
1101 pDocShell
->SetDocumentModified();
1106 DBG_ERROR("keine DocShell"); //! Exception oder so?
1112 void SAL_CALL
ScModelObj::protect( const rtl::OUString
& aPassword
) throw(uno::RuntimeException
)
1117 String
aString(aPassword
);
1119 ScDocFunc
aFunc(*pDocShell
);
1120 aFunc
.Protect( TABLEID_DOC
, aString
, TRUE
);
1124 void SAL_CALL
ScModelObj::unprotect( const rtl::OUString
& aPassword
)
1125 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
1130 String
aString(aPassword
);
1132 ScDocFunc
aFunc(*pDocShell
);
1133 aFunc
.Unprotect( TABLEID_DOC
, aString
, TRUE
);
1135 //! Rueckgabewert auswerten, Exception oder so
1139 sal_Bool SAL_CALL
ScModelObj::isProtected() throw(uno::RuntimeException
)
1143 return pDocShell
->GetDocument()->IsDocProtected();
1145 DBG_ERROR("keine DocShell"); //! Exception oder so?
1149 // XDrawPagesSupplier
1151 uno::Reference
<drawing::XDrawPages
> SAL_CALL
ScModelObj::getDrawPages() throw(uno::RuntimeException
)
1155 return new ScDrawPagesObj(pDocShell
);
1157 DBG_ERROR("keine DocShell"); //! Exception oder so?
1164 rtl::OUString
ScModelObj::getPrinterName(void) const
1169 SfxPrinter
* pPrinter
= pDocShell
->GetPrinter();
1171 return pPrinter
->GetName();
1174 DBG_ERROR("getPrinterName: keine DocShell oder kein Printer");
1175 return rtl::OUString();
1178 void ScModelObj::setPrinterName(const rtl::OUString
& PrinterName
)
1181 // Drucker setzen - wie in SfxViewShell::ExecPrint_Impl
1185 SfxPrinter
* pPrinter
= pDocShell
->GetPrinter();
1188 String
aString(PrinterName
);
1189 SfxPrinter
* pNewPrinter
= new SfxPrinter( pPrinter
->GetOptions().Clone(), aString
);
1190 if (pNewPrinter
->IsKnown())
1191 pDocShell
->SetPrinter( pNewPrinter
, SFX_PRINTER_PRINTER
);
1198 XPropertySetRef
ScModelObj::createPrintOptions(void)
1201 return new ScPrintSettingsObj
; //! ScPrintSettingsObj implementieren!
1204 void ScModelObj::print(const XPropertySetRef
& xOptions
)
1209 //! xOptions auswerten (wie denn?)
1218 sheet::GoalResult SAL_CALL
ScModelObj::seekGoal(
1219 const table::CellAddress
& aFormulaPosition
,
1220 const table::CellAddress
& aVariablePosition
,
1221 const ::rtl::OUString
& aGoalValue
)
1222 throw(uno::RuntimeException
)
1225 sheet::GoalResult aResult
;
1226 aResult
.Divergence
= DBL_MAX
; // nichts gefunden
1229 WaitObject
aWait( pDocShell
->GetActiveDialogParent() );
1230 String
aGoalString(aGoalValue
);
1231 ScDocument
* pDoc
= pDocShell
->GetDocument();
1232 double fValue
= 0.0;
1233 BOOL bFound
= pDoc
->Solver(
1234 (SCCOL
)aFormulaPosition
.Column
, (SCROW
)aFormulaPosition
.Row
, aFormulaPosition
.Sheet
,
1235 (SCCOL
)aVariablePosition
.Column
, (SCROW
)aVariablePosition
.Row
, aVariablePosition
.Sheet
,
1236 aGoalString
, fValue
);
1237 aResult
.Result
= fValue
;
1239 aResult
.Divergence
= 0.0; //! das ist gelogen
1246 uno::Reference
<sheet::XConsolidationDescriptor
> SAL_CALL
ScModelObj::createConsolidationDescriptor(
1247 sal_Bool bEmpty
) throw(uno::RuntimeException
)
1250 ScConsolidationDescriptor
* pNew
= new ScConsolidationDescriptor
;
1251 if ( pDocShell
&& !bEmpty
)
1253 ScDocument
* pDoc
= pDocShell
->GetDocument();
1254 const ScConsolidateParam
* pParam
= pDoc
->GetConsolidateDlgData();
1256 pNew
->SetParam( *pParam
);
1261 void SAL_CALL
ScModelObj::consolidate(
1262 const uno::Reference
<sheet::XConsolidationDescriptor
>& xDescriptor
)
1263 throw(uno::RuntimeException
)
1266 // das koennte theoretisch ein fremdes Objekt sein, also nur das
1267 // oeffentliche XConsolidationDescriptor Interface benutzen, um
1268 // die Daten in ein ScConsolidationDescriptor Objekt zu kopieren:
1269 //! wenn es schon ein ScConsolidationDescriptor ist, direkt per getImplementation?
1271 ScConsolidationDescriptor aImpl
;
1272 aImpl
.setFunction( xDescriptor
->getFunction() );
1273 aImpl
.setSources( xDescriptor
->getSources() );
1274 aImpl
.setStartOutputPosition( xDescriptor
->getStartOutputPosition() );
1275 aImpl
.setUseColumnHeaders( xDescriptor
->getUseColumnHeaders() );
1276 aImpl
.setUseRowHeaders( xDescriptor
->getUseRowHeaders() );
1277 aImpl
.setInsertLinks( xDescriptor
->getInsertLinks() );
1281 const ScConsolidateParam
& rParam
= aImpl
.GetParam();
1282 pDocShell
->DoConsolidate( rParam
, TRUE
);
1283 pDocShell
->GetDocument()->SetConsolidateDlgData( &rParam
);
1287 // XDocumentAuditing
1289 void SAL_CALL
ScModelObj::refreshArrows() throw(uno::RuntimeException
)
1294 ScDocFunc
aFunc(*pDocShell
);
1295 aFunc
.DetectiveRefresh();
1299 // XViewDataSupplier
1300 uno::Reference
< container::XIndexAccess
> SAL_CALL
ScModelObj::getViewData( )
1301 throw (uno::RuntimeException
)
1303 uno::Reference
< container::XIndexAccess
> xRet( SfxBaseModel::getViewData() );
1308 if (pDocShell
&& pDocShell
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
1310 xRet
.set(uno::Reference
< container::XIndexAccess
>::query(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")))));
1312 uno::Reference
< container::XIndexContainer
> xCont( xRet
, uno::UNO_QUERY
);
1313 DBG_ASSERT( xCont
.is(), "ScModelObj::getViewData() failed for OLE object" );
1316 uno::Sequence
< beans::PropertyValue
> aSeq
;
1319 pDocShell
->GetDocument()->GetName( pDocShell
->GetDocument()->GetVisibleTab(), sName
);
1320 rtl::OUString
sOUName(sName
);
1321 aSeq
[0].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE
));
1322 aSeq
[0].Value
<<= sOUName
;
1323 xCont
->insertByIndex( 0, uno::makeAny( aSeq
) );
1331 // XPropertySet (Doc-Optionen)
1332 //! auch an der Applikation anbieten?
1334 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScModelObj::getPropertySetInfo()
1335 throw(uno::RuntimeException
)
1338 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1339 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
1343 void SAL_CALL
ScModelObj::setPropertyValue(
1344 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
1345 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1346 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1347 uno::RuntimeException
)
1350 String
aString(aPropertyName
);
1354 ScDocument
* pDoc
= pDocShell
->GetDocument();
1355 const ScDocOptions
& rOldOpt
= pDoc
->GetDocOptions();
1356 ScDocOptions aNewOpt
= rOldOpt
;
1358 BOOL bOpt
= ScDocOptionsHelper::setPropertyValue( aNewOpt
, *aPropSet
.getPropertyMap(), aPropertyName
, aValue
);
1363 else if ( aString
.EqualsAscii( SC_UNONAME_CLOCAL
) )
1365 lang::Locale aLocale
;
1366 if ( aValue
>>= aLocale
)
1368 LanguageType eLatin
, eCjk
, eCtl
;
1369 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1370 eLatin
= ScUnoConversion::GetLanguage(aLocale
);
1371 pDoc
->SetLanguage( eLatin
, eCjk
, eCtl
);
1374 else if ( aString
.EqualsAscii( SC_UNO_CJK_CLOCAL
) )
1376 lang::Locale aLocale
;
1377 if ( aValue
>>= aLocale
)
1379 LanguageType eLatin
, eCjk
, eCtl
;
1380 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1381 eCjk
= ScUnoConversion::GetLanguage(aLocale
);
1382 pDoc
->SetLanguage( eLatin
, eCjk
, eCtl
);
1385 else if ( aString
.EqualsAscii( SC_UNO_CTL_CLOCAL
) )
1387 lang::Locale aLocale
;
1388 if ( aValue
>>= aLocale
)
1390 LanguageType eLatin
, eCjk
, eCtl
;
1391 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1392 eCtl
= ScUnoConversion::GetLanguage(aLocale
);
1393 pDoc
->SetLanguage( eLatin
, eCjk
, eCtl
);
1396 else if ( aString
.EqualsAscii( SC_UNO_APPLYFMDES
) )
1398 // model is created if not there
1399 ScDrawLayer
* pModel
= pDocShell
->MakeDrawLayer();
1400 pModel
->SetOpenInDesignMode( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1402 SfxBindings
* pBindings
= pDocShell
->GetViewBindings();
1404 pBindings
->Invalidate( SID_FM_OPEN_READONLY
);
1406 else if ( aString
.EqualsAscii( SC_UNO_AUTOCONTFOC
) )
1408 // model is created if not there
1409 ScDrawLayer
* pModel
= pDocShell
->MakeDrawLayer();
1410 pModel
->SetAutoControlFocus( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1412 SfxBindings
* pBindings
= pDocShell
->GetViewBindings();
1414 pBindings
->Invalidate( SID_FM_AUTOCONTROLFOCUS
);
1416 else if ( aString
.EqualsAscii( SC_UNO_ISLOADED
) )
1418 pDocShell
->SetEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1420 else if ( aString
.EqualsAscii( SC_UNO_ISUNDOENABLED
) )
1422 BOOL bUndoEnabled
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1423 pDoc
->EnableUndo( bUndoEnabled
);
1424 USHORT nCount
= ( bUndoEnabled
?
1425 static_cast< USHORT
>( SvtUndoOptions().GetUndoCount() ) : 0 );
1426 pDocShell
->GetUndoManager()->SetMaxUndoActionCount( nCount
);
1428 else if ( aString
.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED
) )
1430 bool bOldAdjustHeightEnabled
= pDoc
->IsAdjustHeightEnabled();
1431 bool bAdjustHeightEnabled
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1432 if( bOldAdjustHeightEnabled
!= bAdjustHeightEnabled
)
1434 pDoc
->EnableAdjustHeight( bAdjustHeightEnabled
);
1435 if( bAdjustHeightEnabled
)
1436 pDocShell
->UpdateAllRowHeights();
1439 else if ( aString
.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED
) )
1441 pDoc
->EnableExecuteLink( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1443 else if ( aString
.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED
) )
1445 pDoc
->EnableChangeReadOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1447 else if ( aString
.EqualsAscii( "BuildId" ) )
1449 aValue
>>= maBuildId
;
1451 else if ( aString
.EqualsAscii( "SavedObject" ) ) // set from chart after saving
1453 rtl::OUString aObjName
;
1454 aValue
>>= aObjName
;
1455 if ( aObjName
.getLength() )
1456 pDoc
->RestoreChartListener( aObjName
);
1458 else if ( aString
.EqualsAscii( "WriteProtectionPassword" ) )
1460 /* This is a hack for #160550# to preserve the write-protection
1461 password in an XLS roundtrip. This property MUST NOT be used
1462 for any other purpose. This property will be deleted when the
1463 feature "Write Protection With Password" will be implemented. */
1464 aValue
>>= mnXlsWriteProtPass
;
1467 if ( aNewOpt
!= rOldOpt
)
1469 pDoc
->SetDocOptions( aNewOpt
);
1470 // Don't recalculate while loading XML, when the formula text is stored.
1471 // Recalculation after loading is handled separately.
1472 //! Recalc only for options that need it?
1473 if ( !pDoc
->IsImportingXML() )
1474 pDocShell
->DoHardRecalc( TRUE
);
1475 pDocShell
->SetDocumentModified();
1480 uno::Any SAL_CALL
ScModelObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
1481 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1482 uno::RuntimeException
)
1485 String
aString(aPropertyName
);
1490 ScDocument
* pDoc
= pDocShell
->GetDocument();
1491 const ScDocOptions
& rOpt
= pDoc
->GetDocOptions();
1492 aRet
= ScDocOptionsHelper::getPropertyValue( rOpt
, *aPropSet
.getPropertyMap(), aPropertyName
);
1493 if ( aRet
.hasValue() )
1497 else if ( aString
.EqualsAscii( SC_UNONAME_CLOCAL
) )
1499 LanguageType eLatin
, eCjk
, eCtl
;
1500 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1502 lang::Locale aLocale
;
1503 ScUnoConversion::FillLocale( aLocale
, eLatin
);
1506 else if ( aString
.EqualsAscii( SC_UNO_CJK_CLOCAL
) )
1508 LanguageType eLatin
, eCjk
, eCtl
;
1509 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1511 lang::Locale aLocale
;
1512 ScUnoConversion::FillLocale( aLocale
, eCjk
);
1515 else if ( aString
.EqualsAscii( SC_UNO_CTL_CLOCAL
) )
1517 LanguageType eLatin
, eCjk
, eCtl
;
1518 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1520 lang::Locale aLocale
;
1521 ScUnoConversion::FillLocale( aLocale
, eCtl
);
1524 else if ( aString
.EqualsAscii( SC_UNO_NAMEDRANGES
) )
1526 aRet
<<= uno::Reference
<sheet::XNamedRanges
>(new ScNamedRangesObj( pDocShell
));
1528 else if ( aString
.EqualsAscii( SC_UNO_DATABASERNG
) )
1530 aRet
<<= uno::Reference
<sheet::XDatabaseRanges
>(new ScDatabaseRangesObj( pDocShell
));
1532 else if ( aString
.EqualsAscii( SC_UNO_COLLABELRNG
) )
1534 aRet
<<= uno::Reference
<sheet::XLabelRanges
>(new ScLabelRangesObj( pDocShell
, TRUE
));
1536 else if ( aString
.EqualsAscii( SC_UNO_ROWLABELRNG
) )
1538 aRet
<<= uno::Reference
<sheet::XLabelRanges
>(new ScLabelRangesObj( pDocShell
, FALSE
));
1540 else if ( aString
.EqualsAscii( SC_UNO_AREALINKS
) )
1542 aRet
<<= uno::Reference
<sheet::XAreaLinks
>(new ScAreaLinksObj( pDocShell
));
1544 else if ( aString
.EqualsAscii( SC_UNO_DDELINKS
) )
1546 aRet
<<= uno::Reference
<container::XNameAccess
>(new ScDDELinksObj( pDocShell
));
1548 else if ( aString
.EqualsAscii( SC_UNO_EXTERNALDOCLINKS
) )
1550 aRet
<<= uno::Reference
<sheet::XExternalDocLinks
>(new ScExternalDocLinksObj(pDocShell
));
1552 else if ( aString
.EqualsAscii( SC_UNO_SHEETLINKS
) )
1554 aRet
<<= uno::Reference
<container::XNameAccess
>(new ScSheetLinksObj( pDocShell
));
1556 else if ( aString
.EqualsAscii( SC_UNO_APPLYFMDES
) )
1558 // default for no model is TRUE
1559 ScDrawLayer
* pModel
= pDoc
->GetDrawLayer();
1560 sal_Bool bOpenInDesign
= pModel
? pModel
->GetOpenInDesignMode() : sal_True
;
1561 ScUnoHelpFunctions::SetBoolInAny( aRet
, bOpenInDesign
);
1563 else if ( aString
.EqualsAscii( SC_UNO_AUTOCONTFOC
) )
1565 // default for no model is FALSE
1566 ScDrawLayer
* pModel
= pDoc
->GetDrawLayer();
1567 sal_Bool bAutoControlFocus
= pModel
? pModel
->GetAutoControlFocus() : sal_False
;
1568 ScUnoHelpFunctions::SetBoolInAny( aRet
, bAutoControlFocus
);
1570 else if ( aString
.EqualsAscii( SC_UNO_FORBIDDEN
) )
1572 aRet
<<= uno::Reference
<i18n::XForbiddenCharacters
>(new ScForbiddenCharsObj( pDocShell
));
1574 else if ( aString
.EqualsAscii( SC_UNO_HASDRAWPAGES
) )
1576 ScUnoHelpFunctions::SetBoolInAny( aRet
, (pDocShell
->GetDocument()->GetDrawLayer() != 0) );
1578 else if ( aString
.EqualsAscii( SC_UNO_BASICLIBRARIES
) )
1580 aRet
<<= pDocShell
->GetBasicContainer();
1582 else if ( aString
.EqualsAscii( SC_UNO_DIALOGLIBRARIES
) )
1584 aRet
<<= pDocShell
->GetDialogContainer();
1586 else if ( aString
.EqualsAscii( SC_UNO_VBADOCOBJ
) )
1588 beans::PropertyValue aProp
;
1589 aProp
.Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") );
1590 aProp
.Value
<<= pDocShell
->GetModel();
1593 else if ( aString
.EqualsAscii( SC_UNO_RUNTIMEUID
) )
1595 aRet
<<= getRuntimeUID();
1597 else if ( aString
.EqualsAscii( SC_UNO_HASVALIDSIGNATURES
) )
1599 aRet
<<= hasValidSignatures();
1601 else if ( aString
.EqualsAscii( SC_UNO_ISLOADED
) )
1603 ScUnoHelpFunctions::SetBoolInAny( aRet
, !pDocShell
->IsEmpty() );
1605 else if ( aString
.EqualsAscii( SC_UNO_ISUNDOENABLED
) )
1607 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsUndoEnabled() );
1609 else if ( aString
.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED
) )
1611 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsAdjustHeightEnabled() );
1613 else if ( aString
.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED
) )
1615 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsExecuteLinkEnabled() );
1617 else if ( aString
.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED
) )
1619 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsChangeReadOnlyEnabled() );
1621 else if ( aString
.EqualsAscii( SC_UNO_REFERENCEDEVICE
) )
1623 VCLXDevice
* pXDev
= new VCLXDevice();
1624 pXDev
->SetOutputDevice( pDoc
->GetRefDevice() );
1625 aRet
<<= uno::Reference
< awt::XDevice
>( pXDev
);
1627 else if (aString
.EqualsAscii(SC_UNO_ALWAYS_ALLOW_SAVE
))
1628 ScUnoHelpFunctions::SetBoolInAny(aRet
, pDocShell
->GetApplicationFlag(SFX_APPFLAG_ALWAYS_ALLOW_SAVE
));
1629 else if ( aString
.EqualsAscii( "BuildId" ) )
1633 else if ( aString
.EqualsAscii( "InternalDocument" ) )
1635 ScUnoHelpFunctions::SetBoolInAny( aRet
, (pDocShell
->GetCreateMode() == SFX_CREATE_MODE_INTERNAL
) );
1637 else if ( aString
.EqualsAscii( "WriteProtectionPassword" ) )
1639 /* This is a hack for #160550# to preserve the write-protection
1640 password in an XLS roundtrip. This property MUST NOT be used
1641 for any other purpose. This property will be deleted when the
1642 feature "Write Protection With Password" will be implemented. */
1643 aRet
<<= mnXlsWriteProtPass
;
1650 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScModelObj
)
1652 // XMultiServiceFactory
1654 uno::Reference
<uno::XInterface
> SAL_CALL
ScModelObj::createInstance(
1655 const rtl::OUString
& aServiceSpecifier
)
1656 throw(uno::Exception
, uno::RuntimeException
)
1659 uno::Reference
<uno::XInterface
> xRet
;
1660 String
aNameStr(aServiceSpecifier
);
1661 USHORT nType
= ScServiceProvider::GetProviderType(aNameStr
);
1662 if ( nType
!= SC_SERVICE_INVALID
)
1664 // drawing layer tables must be kept as long as the model is alive
1665 // return stored instance if already set
1668 case SC_SERVICE_GRADTAB
: xRet
.set(xDrawGradTab
); break;
1669 case SC_SERVICE_HATCHTAB
: xRet
.set(xDrawHatchTab
); break;
1670 case SC_SERVICE_BITMAPTAB
: xRet
.set(xDrawBitmapTab
); break;
1671 case SC_SERVICE_TRGRADTAB
: xRet
.set(xDrawTrGradTab
); break;
1672 case SC_SERVICE_MARKERTAB
: xRet
.set(xDrawMarkerTab
); break;
1673 case SC_SERVICE_DASHTAB
: xRet
.set(xDrawDashTab
); break;
1674 case SC_SERVICE_CHDATAPROV
: xRet
.set(xChartDataProv
); break;
1677 // #i64497# If a chart is in a temporary document during clipoard paste,
1678 // there should be no data provider, so that own data is used
1680 ! ( nType
== SC_SERVICE_CHDATAPROV
&&
1681 ( pDocShell
->GetCreateMode() == SFX_CREATE_MODE_INTERNAL
));
1682 // this should never happen, i.e. the temporary document should never be
1683 // loaded, becuase this unlinks the data
1684 OSL_ASSERT( bCreate
);
1686 if ( !xRet
.is() && bCreate
)
1688 xRet
.set(ScServiceProvider::MakeInstance( nType
, pDocShell
));
1690 // store created instance
1693 case SC_SERVICE_GRADTAB
: xDrawGradTab
.set(xRet
); break;
1694 case SC_SERVICE_HATCHTAB
: xDrawHatchTab
.set(xRet
); break;
1695 case SC_SERVICE_BITMAPTAB
: xDrawBitmapTab
.set(xRet
); break;
1696 case SC_SERVICE_TRGRADTAB
: xDrawTrGradTab
.set(xRet
); break;
1697 case SC_SERVICE_MARKERTAB
: xDrawMarkerTab
.set(xRet
); break;
1698 case SC_SERVICE_DASHTAB
: xDrawDashTab
.set(xRet
); break;
1699 case SC_SERVICE_CHDATAPROV
: xChartDataProv
.set(xRet
); break;
1705 // alles was ich nicht kenn, werf ich der SvxFmMSFactory an den Hals,
1706 // da wird dann 'ne Exception geworfen, wenn's nicht passt...
1710 xRet
.set(SvxFmMSFactory::createInstance(aServiceSpecifier
));
1711 // extra block to force deletion of the temporary before ScShapeObj ctor (setDelegator)
1713 catch ( lang::ServiceNotRegisteredException
& )
1717 // #96117# if the drawing factory created a shape, a ScShapeObj has to be used
1718 // to support own properties like ImageMap:
1720 uno::Reference
<drawing::XShape
> xShape( xRet
, uno::UNO_QUERY
);
1723 xRet
.clear(); // for aggregation, xShape must be the object's only ref
1724 new ScShapeObj( xShape
); // aggregates object and modifies xShape
1731 uno::Reference
<uno::XInterface
> SAL_CALL
ScModelObj::createInstanceWithArguments(
1732 const rtl::OUString
& ServiceSpecifier
,
1733 const uno::Sequence
<uno::Any
>& aArgs
)
1734 throw(uno::Exception
, uno::RuntimeException
)
1736 //! unterscheiden zwischen eigenen Services und denen vom Drawing-Layer?
1739 uno::Reference
<uno::XInterface
> xInt(createInstance(ServiceSpecifier
));
1741 if ( aArgs
.getLength() )
1743 // used only for cell value binding so far - it can be initialized after creating
1745 uno::Reference
<lang::XInitialization
> xInit( xInt
, uno::UNO_QUERY
);
1747 xInit
->initialize( aArgs
);
1753 uno::Sequence
<rtl::OUString
> SAL_CALL
ScModelObj::getAvailableServiceNames()
1754 throw(uno::RuntimeException
)
1758 //! warum sind die Parameter bei concatServiceNames nicht const ???
1759 //! return concatServiceNames( ScServiceProvider::GetAllServiceNames(),
1760 //! SvxFmMSFactory::getAvailableServiceNames() );
1762 uno::Sequence
<rtl::OUString
> aMyServices(ScServiceProvider::GetAllServiceNames());
1763 uno::Sequence
<rtl::OUString
> aDrawServices(SvxFmMSFactory::getAvailableServiceNames());
1765 return concatServiceNames( aMyServices
, aDrawServices
);
1771 ScModelObj::processCompatibleEvent( sal_Int16 nSlotId
) throw( ::com::sun::star::uno::RuntimeException
)
1773 USHORT nId
= (USHORT
)nSlotId
;
1774 uno::Reference
< document::XVbaEventsHelper
> xVbaEventsHelper( GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY
);
1775 if( xVbaEventsHelper
.is() )
1781 uno::Sequence
< uno::Any
> aArgs(1);
1782 aArgs
[0] <<= sal_False
;
1783 return xVbaEventsHelper
->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE
, aArgs
);
1787 uno::Sequence
< uno::Any
> aArgs(1);
1788 aArgs
[0] <<= sal_True
;
1789 return xVbaEventsHelper
->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE
, aArgs
);
1792 case SID_PRINTDOCDIRECT
:
1794 uno::Sequence
< uno::Any
> aArgs
;
1795 return xVbaEventsHelper
->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFOREPRINT
, aArgs
);
1803 rtl::OUString SAL_CALL
ScModelObj::getImplementationName() throw(uno::RuntimeException
)
1805 return rtl::OUString::createFromAscii( "ScModelObj" );
1808 sal_Bool SAL_CALL
ScModelObj::supportsService( const rtl::OUString
& rServiceName
)
1809 throw(uno::RuntimeException
)
1811 String
aServiceStr(rServiceName
);
1812 return aServiceStr
.EqualsAscii( SCMODELOBJ_SERVICE
) ||
1813 aServiceStr
.EqualsAscii( SCDOCSETTINGS_SERVICE
) ||
1814 aServiceStr
.EqualsAscii( SCDOC_SERVICE
);
1817 uno::Sequence
<rtl::OUString
> SAL_CALL
ScModelObj::getSupportedServiceNames()
1818 throw(uno::RuntimeException
)
1820 uno::Sequence
<rtl::OUString
> aRet(2);
1821 rtl::OUString
* pArray
= aRet
.getArray();
1822 pArray
[0] = rtl::OUString::createFromAscii( SCMODELOBJ_SERVICE
);
1823 pArray
[1] = rtl::OUString::createFromAscii( SCDOCSETTINGS_SERVICE
);
1829 sal_Int64 SAL_CALL
ScModelObj::getSomething(
1830 const uno::Sequence
<sal_Int8
>& rId
) throw(uno::RuntimeException
)
1832 if ( rId
.getLength() == 16 &&
1833 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1834 rId
.getConstArray(), 16 ) )
1836 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
1839 if ( rId
.getLength() == 16 &&
1840 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(),
1841 rId
.getConstArray(), 16 ) )
1843 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(pDocShell
));
1845 // aggregated number formats supplier has XUnoTunnel, too
1846 // interface from aggregated object must be obtained via queryAggregation
1848 sal_Int64 nRet
= SfxBaseModel::getSomething( rId
);
1852 if ( GetFormatter().is() )
1854 const uno::Type
& rTunnelType
= ::getCppuType((uno::Reference
<lang::XUnoTunnel
>*) 0);
1855 uno::Any
aNumTunnel(xNumberAgg
->queryAggregation(rTunnelType
));
1856 if(aNumTunnel
.getValueType() == rTunnelType
)
1858 uno::Reference
<lang::XUnoTunnel
> xTunnelAgg(
1859 *(uno::Reference
<lang::XUnoTunnel
>*)aNumTunnel
.getValue());
1860 return xTunnelAgg
->getSomething( rId
);
1868 const uno::Sequence
<sal_Int8
>& ScModelObj::getUnoTunnelId()
1870 static uno::Sequence
<sal_Int8
> * pSeq
= 0;
1873 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
1876 static uno::Sequence
< sal_Int8
> aSeq( 16 );
1877 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
1885 ScModelObj
* ScModelObj::getImplementation( const uno::Reference
<uno::XInterface
> xObj
)
1887 ScModelObj
* pRet
= NULL
;
1888 uno::Reference
<lang::XUnoTunnel
> xUT( xObj
, uno::UNO_QUERY
);
1890 pRet
= reinterpret_cast<ScModelObj
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething(getUnoTunnelId())));
1896 void ScModelObj::addChangesListener( const uno::Reference
< util::XChangesListener
>& aListener
)
1897 throw (uno::RuntimeException
)
1900 maChangesListeners
.addInterface( aListener
);
1903 void ScModelObj::removeChangesListener( const uno::Reference
< util::XChangesListener
>& aListener
)
1904 throw (uno::RuntimeException
)
1907 maChangesListeners
.removeInterface( aListener
);
1910 bool ScModelObj::HasChangesListeners() const
1912 return ( maChangesListeners
.getLength() > 0 );
1915 void ScModelObj::NotifyChanges( const ::rtl::OUString
& rOperation
, const ScRangeList
& rRanges
,
1916 const uno::Sequence
< beans::PropertyValue
>& rProperties
)
1918 if ( pDocShell
&& HasChangesListeners() )
1920 util::ChangesEvent aEvent
;
1921 aEvent
.Source
.set( static_cast< cppu::OWeakObject
* >( this ) );
1922 aEvent
.Base
<<= aEvent
.Source
;
1924 ULONG nRangeCount
= rRanges
.Count();
1925 aEvent
.Changes
.realloc( static_cast< sal_Int32
>( nRangeCount
) );
1926 for ( ULONG nIndex
= 0; nIndex
< nRangeCount
; ++nIndex
)
1928 uno::Reference
< table::XCellRange
> xRangeObj
;
1930 ScRange
aRange( *rRanges
.GetObject( nIndex
) );
1931 if ( aRange
.aStart
== aRange
.aEnd
)
1933 xRangeObj
.set( new ScCellObj( pDocShell
, aRange
.aStart
) );
1937 xRangeObj
.set( new ScCellRangeObj( pDocShell
, aRange
) );
1940 util::ElementChange
& rChange
= aEvent
.Changes
[ static_cast< sal_Int32
>( nIndex
) ];
1941 rChange
.Accessor
<<= rOperation
;
1942 rChange
.Element
<<= rProperties
;
1943 rChange
.ReplacedElement
<<= xRangeObj
;
1946 ::cppu::OInterfaceIteratorHelper
aIter( maChangesListeners
);
1947 while ( aIter
.hasMoreElements() )
1951 static_cast< util::XChangesListener
* >( aIter
.next() )->changesOccurred( aEvent
);
1953 catch( uno::Exception
& )
1960 //------------------------------------------------------------------------
1962 ScDrawPagesObj::ScDrawPagesObj(ScDocShell
* pDocSh
) :
1965 pDocShell
->GetDocument()->AddUnoObject(*this);
1968 ScDrawPagesObj::~ScDrawPagesObj()
1971 pDocShell
->GetDocument()->RemoveUnoObject(*this);
1974 void ScDrawPagesObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1976 // Referenz-Update interessiert hier nicht
1978 if ( rHint
.ISA( SfxSimpleHint
) &&
1979 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
1981 pDocShell
= NULL
; // ungueltig geworden
1985 uno::Reference
<drawing::XDrawPage
> ScDrawPagesObj::GetObjectByIndex_Impl(INT32 nIndex
) const
1989 ScDrawLayer
* pDrawLayer
= pDocShell
->MakeDrawLayer();
1990 DBG_ASSERT(pDrawLayer
,"kann Draw-Layer nicht anlegen");
1991 if ( pDrawLayer
&& nIndex
>= 0 && nIndex
< pDocShell
->GetDocument()->GetTableCount() )
1993 SdrPage
* pPage
= pDrawLayer
->GetPage((USHORT
)nIndex
);
1994 DBG_ASSERT(pPage
,"Draw-Page nicht gefunden");
1997 return uno::Reference
<drawing::XDrawPage
> (pPage
->getUnoPage(), uno::UNO_QUERY
);
2006 uno::Reference
<drawing::XDrawPage
> SAL_CALL
ScDrawPagesObj::insertNewByIndex( sal_Int32 nPos
)
2007 throw(uno::RuntimeException
)
2010 uno::Reference
<drawing::XDrawPage
> xRet
;
2014 pDocShell
->GetDocument()->CreateValidTabName(aNewName
);
2015 ScDocFunc
aFunc(*pDocShell
);
2016 if ( aFunc
.InsertTable( (SCTAB
)nPos
, aNewName
, TRUE
, TRUE
) )
2017 xRet
.set(GetObjectByIndex_Impl( nPos
));
2022 void SAL_CALL
ScDrawPagesObj::remove( const uno::Reference
<drawing::XDrawPage
>& xPage
)
2023 throw(uno::RuntimeException
)
2026 SvxDrawPage
* pImp
= SvxDrawPage::getImplementation( xPage
);
2027 if ( pDocShell
&& pImp
)
2029 SdrPage
* pPage
= pImp
->GetSdrPage();
2032 SCTAB nPageNum
= static_cast<SCTAB
>(pPage
->GetPageNum());
2033 ScDocFunc
aFunc(*pDocShell
);
2034 aFunc
.DeleteTable( nPageNum
, TRUE
, TRUE
);
2041 sal_Int32 SAL_CALL
ScDrawPagesObj::getCount() throw(uno::RuntimeException
)
2045 return pDocShell
->GetDocument()->GetTableCount();
2049 uno::Any SAL_CALL
ScDrawPagesObj::getByIndex( sal_Int32 nIndex
)
2050 throw(lang::IndexOutOfBoundsException
,
2051 lang::WrappedTargetException
, uno::RuntimeException
)
2054 uno::Reference
<drawing::XDrawPage
> xPage(GetObjectByIndex_Impl(nIndex
));
2056 return uno::makeAny(xPage
);
2058 throw lang::IndexOutOfBoundsException();
2059 // return uno::Any();
2062 uno::Type SAL_CALL
ScDrawPagesObj::getElementType() throw(uno::RuntimeException
)
2065 return getCppuType((uno::Reference
<drawing::XDrawPage
>*)0);
2068 sal_Bool SAL_CALL
ScDrawPagesObj::hasElements() throw(uno::RuntimeException
)
2071 return ( getCount() != 0 );
2074 //------------------------------------------------------------------------
2076 ScTableSheetsObj::ScTableSheetsObj(ScDocShell
* pDocSh
) :
2079 pDocShell
->GetDocument()->AddUnoObject(*this);
2082 ScTableSheetsObj::~ScTableSheetsObj()
2085 pDocShell
->GetDocument()->RemoveUnoObject(*this);
2088 void ScTableSheetsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
2090 // Referenz-Update interessiert hier nicht
2092 if ( rHint
.ISA( SfxSimpleHint
) &&
2093 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
2095 pDocShell
= NULL
; // ungueltig geworden
2101 ScTableSheetObj
* ScTableSheetsObj::GetObjectByIndex_Impl(sal_Int32 nIndex
) const
2103 if ( pDocShell
&& nIndex
>= 0 && nIndex
< pDocShell
->GetDocument()->GetTableCount() )
2104 return new ScTableSheetObj( pDocShell
, static_cast<SCTAB
>(nIndex
) );
2109 ScTableSheetObj
* ScTableSheetsObj::GetObjectByName_Impl(const rtl::OUString
& aName
) const
2114 String
aString(aName
);
2115 if ( pDocShell
->GetDocument()->GetTable( aString
, nIndex
) )
2116 return new ScTableSheetObj( pDocShell
, nIndex
);
2121 void SAL_CALL
ScTableSheetsObj::insertNewByName( const rtl::OUString
& aName
, sal_Int16 nPosition
)
2122 throw(uno::RuntimeException
)
2128 String
aNamStr(aName
);
2129 ScDocFunc
aFunc(*pDocShell
);
2130 bDone
= aFunc
.InsertTable( nPosition
, aNamStr
, TRUE
, TRUE
);
2133 throw uno::RuntimeException(); // no other exceptions specified
2136 void SAL_CALL
ScTableSheetsObj::moveByName( const rtl::OUString
& aName
, sal_Int16 nDestination
)
2137 throw(uno::RuntimeException
)
2143 String
aNamStr(aName
);
2145 if ( pDocShell
->GetDocument()->GetTable( aNamStr
, nSource
) )
2146 bDone
= pDocShell
->MoveTable( nSource
, nDestination
, FALSE
, TRUE
);
2149 throw uno::RuntimeException(); // no other exceptions specified
2152 void SAL_CALL
ScTableSheetsObj::copyByName( const rtl::OUString
& aName
,
2153 const rtl::OUString
& aCopy
, sal_Int16 nDestination
)
2154 throw(uno::RuntimeException
)
2160 String
aNamStr(aName
);
2161 String
aNewStr(aCopy
);
2163 if ( pDocShell
->GetDocument()->GetTable( aNamStr
, nSource
) )
2165 bDone
= pDocShell
->MoveTable( nSource
, nDestination
, TRUE
, TRUE
);
2168 // #i92477# any index past the last sheet means "append" in MoveTable
2169 SCTAB nResultTab
= static_cast<SCTAB
>(nDestination
);
2170 SCTAB nTabCount
= pDocShell
->GetDocument()->GetTableCount(); // count after copying
2171 if (nResultTab
>= nTabCount
)
2172 nResultTab
= nTabCount
- 1;
2174 ScDocFunc
aFunc(*pDocShell
);
2175 bDone
= aFunc
.RenameTable( nResultTab
, aNewStr
, TRUE
, TRUE
);
2180 throw uno::RuntimeException(); // no other exceptions specified
2183 void SAL_CALL
ScTableSheetsObj::insertByName( const rtl::OUString
& aName
, const uno::Any
& aElement
)
2184 throw(lang::IllegalArgumentException
, container::ElementExistException
,
2185 lang::WrappedTargetException
, uno::RuntimeException
)
2189 BOOL bIllArg
= FALSE
;
2191 //! Type of aElement can be some specific interface instead of XInterface
2195 uno::Reference
<uno::XInterface
> xInterface(aElement
, uno::UNO_QUERY
);
2196 if ( xInterface
.is() )
2198 ScTableSheetObj
* pSheetObj
= ScTableSheetObj::getImplementation( xInterface
);
2199 if ( pSheetObj
&& !pSheetObj
->GetDocShell() ) // noch nicht eingefuegt?
2201 ScDocument
* pDoc
= pDocShell
->GetDocument();
2202 String
aNamStr(aName
);
2204 if ( pDoc
->GetTable( aNamStr
, nDummy
) )
2206 // name already exists
2207 throw container::ElementExistException();
2211 SCTAB nPosition
= pDoc
->GetTableCount();
2212 ScDocFunc
aFunc(*pDocShell
);
2213 bDone
= aFunc
.InsertTable( nPosition
, aNamStr
, TRUE
, TRUE
);
2215 pSheetObj
->InitInsertSheet( pDocShell
, nPosition
);
2216 // Dokument und neuen Range am Objekt setzen
2229 throw lang::IllegalArgumentException();
2231 throw uno::RuntimeException(); // ElementExistException is handled above
2235 void SAL_CALL
ScTableSheetsObj::replaceByName( const rtl::OUString
& aName
, const uno::Any
& aElement
)
2236 throw(lang::IllegalArgumentException
, container::NoSuchElementException
,
2237 lang::WrappedTargetException
, uno::RuntimeException
)
2241 BOOL bIllArg
= FALSE
;
2243 //! Type of aElement can be some specific interface instead of XInterface
2247 uno::Reference
<uno::XInterface
> xInterface(aElement
, uno::UNO_QUERY
);
2248 if ( xInterface
.is() )
2250 ScTableSheetObj
* pSheetObj
= ScTableSheetObj::getImplementation( xInterface
);
2251 if ( pSheetObj
&& !pSheetObj
->GetDocShell() ) // noch nicht eingefuegt?
2253 String
aNamStr(aName
);
2255 if ( pDocShell
->GetDocument()->GetTable( aNamStr
, nPosition
) )
2257 ScDocFunc
aFunc(*pDocShell
);
2258 if ( aFunc
.DeleteTable( nPosition
, TRUE
, TRUE
) )
2260 // InsertTable kann jetzt eigentlich nicht schiefgehen...
2261 bDone
= aFunc
.InsertTable( nPosition
, aNamStr
, TRUE
, TRUE
);
2263 pSheetObj
->InitInsertSheet( pDocShell
, nPosition
);
2269 throw container::NoSuchElementException();
2282 throw lang::IllegalArgumentException();
2284 throw uno::RuntimeException(); // NoSuchElementException is handled above
2288 void SAL_CALL
ScTableSheetsObj::removeByName( const rtl::OUString
& aName
)
2289 throw(container::NoSuchElementException
,
2290 lang::WrappedTargetException
, uno::RuntimeException
)
2297 String
aString(aName
);
2298 if ( pDocShell
->GetDocument()->GetTable( aString
, nIndex
) )
2300 ScDocFunc
aFunc(*pDocShell
);
2301 bDone
= aFunc
.DeleteTable( nIndex
, TRUE
, TRUE
);
2306 throw container::NoSuchElementException();
2311 throw uno::RuntimeException(); // NoSuchElementException is handled above
2314 // XCellRangesAccess
2316 uno::Reference
< table::XCell
> SAL_CALL
ScTableSheetsObj::getCellByPosition( sal_Int32 nColumn
, sal_Int32 nRow
, sal_Int32 nSheet
)
2317 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
2320 uno::Reference
<table::XCellRange
> xSheet(static_cast<ScCellRangeObj
*>(GetObjectByIndex_Impl((USHORT
)nSheet
)));
2322 throw lang::IndexOutOfBoundsException();
2324 return xSheet
->getCellByPosition(nColumn
, nRow
);
2327 uno::Reference
< table::XCellRange
> SAL_CALL
ScTableSheetsObj::getCellRangeByPosition( sal_Int32 nLeft
, sal_Int32 nTop
, sal_Int32 nRight
, sal_Int32 nBottom
, sal_Int32 nSheet
)
2328 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
2331 uno::Reference
<table::XCellRange
> xSheet(static_cast<ScCellRangeObj
*>(GetObjectByIndex_Impl((USHORT
)nSheet
)));
2333 throw lang::IndexOutOfBoundsException();
2335 return xSheet
->getCellRangeByPosition(nLeft
, nTop
, nRight
, nBottom
);
2338 uno::Sequence
< uno::Reference
< table::XCellRange
> > SAL_CALL
ScTableSheetsObj::getCellRangesByName( const rtl::OUString
& aRange
)
2339 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
2342 uno::Sequence
< uno::Reference
< table::XCellRange
> > xRet
;
2344 ScRangeList aRangeList
;
2345 ScDocument
* pDoc
= pDocShell
->GetDocument();
2346 if (ScRangeStringConverter::GetRangeListFromString( aRangeList
, aRange
, pDoc
, ::formula::FormulaGrammar::CONV_OOO
, ';' ))
2348 sal_Int32 nCount
= aRangeList
.Count();
2351 xRet
.realloc(nCount
);
2352 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; nIndex
++ )
2354 const ScRange
* pRange
= aRangeList
.GetObject( nIndex
);
2356 xRet
[nIndex
] = new ScCellRangeObj(pDocShell
, *pRange
);
2360 throw lang::IllegalArgumentException();
2363 throw lang::IllegalArgumentException();
2367 // XEnumerationAccess
2369 uno::Reference
<container::XEnumeration
> SAL_CALL
ScTableSheetsObj::createEnumeration()
2370 throw(uno::RuntimeException
)
2373 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetsEnumeration")));
2378 sal_Int32 SAL_CALL
ScTableSheetsObj::getCount() throw(uno::RuntimeException
)
2382 return pDocShell
->GetDocument()->GetTableCount();
2386 uno::Any SAL_CALL
ScTableSheetsObj::getByIndex( sal_Int32 nIndex
)
2387 throw(lang::IndexOutOfBoundsException
,
2388 lang::WrappedTargetException
, uno::RuntimeException
)
2391 uno::Reference
<sheet::XSpreadsheet
> xSheet(GetObjectByIndex_Impl(nIndex
));
2393 return uno::makeAny(xSheet
);
2395 throw lang::IndexOutOfBoundsException();
2396 // return uno::Any();
2399 uno::Type SAL_CALL
ScTableSheetsObj::getElementType() throw(uno::RuntimeException
)
2402 return getCppuType((uno::Reference
<sheet::XSpreadsheet
>*)0);
2405 sal_Bool SAL_CALL
ScTableSheetsObj::hasElements() throw(uno::RuntimeException
)
2408 return ( getCount() != 0 );
2413 uno::Any SAL_CALL
ScTableSheetsObj::getByName( const rtl::OUString
& aName
)
2414 throw(container::NoSuchElementException
,
2415 lang::WrappedTargetException
, uno::RuntimeException
)
2418 uno::Reference
<sheet::XSpreadsheet
> xSheet(GetObjectByName_Impl(aName
));
2420 return uno::makeAny(xSheet
);
2422 throw container::NoSuchElementException();
2423 // return uno::Any();
2426 uno::Sequence
<rtl::OUString
> SAL_CALL
ScTableSheetsObj::getElementNames()
2427 throw(uno::RuntimeException
)
2432 ScDocument
* pDoc
= pDocShell
->GetDocument();
2433 SCTAB nCount
= pDoc
->GetTableCount();
2435 uno::Sequence
<rtl::OUString
> aSeq(nCount
);
2436 rtl::OUString
* pAry
= aSeq
.getArray();
2437 for (SCTAB i
=0; i
<nCount
; i
++)
2439 pDoc
->GetName( i
, aName
);
2444 return uno::Sequence
<rtl::OUString
>();
2447 sal_Bool SAL_CALL
ScTableSheetsObj::hasByName( const rtl::OUString
& aName
)
2448 throw(uno::RuntimeException
)
2454 if ( pDocShell
->GetDocument()->GetTable( String(aName
), nIndex
) )
2460 //------------------------------------------------------------------------
2462 ScTableColumnsObj::ScTableColumnsObj(ScDocShell
* pDocSh
, SCTAB nT
, SCCOL nSC
, SCCOL nEC
) :
2463 pDocShell( pDocSh
),
2468 pDocShell
->GetDocument()->AddUnoObject(*this);
2471 ScTableColumnsObj::~ScTableColumnsObj()
2474 pDocShell
->GetDocument()->RemoveUnoObject(*this);
2477 void ScTableColumnsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
2479 if ( rHint
.ISA( ScUpdateRefHint
) )
2481 // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
2483 //! Referenz-Update fuer Tab und Start/Ende
2485 else if ( rHint
.ISA( SfxSimpleHint
) &&
2486 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
2488 pDocShell
= NULL
; // ungueltig geworden
2494 ScTableColumnObj
* ScTableColumnsObj::GetObjectByIndex_Impl(sal_Int32 nIndex
) const
2496 SCCOL nCol
= static_cast<SCCOL
>(nIndex
) + nStartCol
;
2497 if ( pDocShell
&& nCol
<= nEndCol
)
2498 return new ScTableColumnObj( pDocShell
, nCol
, nTab
);
2500 return NULL
; // falscher Index
2503 ScTableColumnObj
* ScTableColumnsObj::GetObjectByName_Impl(const rtl::OUString
& aName
) const
2506 String
aString(aName
);
2507 if ( ::AlphaToCol( nCol
, aString
) )
2508 if ( pDocShell
&& nCol
>= nStartCol
&& nCol
<= nEndCol
)
2509 return new ScTableColumnObj( pDocShell
, nCol
, nTab
);
2514 void SAL_CALL
ScTableColumnsObj::insertByIndex( sal_Int32 nPosition
, sal_Int32 nCount
)
2515 throw(uno::RuntimeException
)
2519 if ( pDocShell
&& nCount
> 0 && nPosition
>= 0 && nStartCol
+nPosition
<= nEndCol
&&
2520 nStartCol
+nPosition
+nCount
-1 <= MAXCOL
)
2522 ScDocFunc
aFunc(*pDocShell
);
2523 ScRange
aRange( (SCCOL
)(nStartCol
+nPosition
), 0, nTab
,
2524 (SCCOL
)(nStartCol
+nPosition
+nCount
-1), MAXROW
, nTab
);
2525 bDone
= aFunc
.InsertCells( aRange
, NULL
, INS_INSCOLS
, TRUE
, TRUE
);
2528 throw uno::RuntimeException(); // no other exceptions specified
2531 void SAL_CALL
ScTableColumnsObj::removeByIndex( sal_Int32 nIndex
, sal_Int32 nCount
)
2532 throw(uno::RuntimeException
)
2536 // Der zu loeschende Bereich muss innerhalb des Objekts liegen
2537 if ( pDocShell
&& nCount
> 0 && nIndex
>= 0 && nStartCol
+nIndex
+nCount
-1 <= nEndCol
)
2539 ScDocFunc
aFunc(*pDocShell
);
2540 ScRange
aRange( (SCCOL
)(nStartCol
+nIndex
), 0, nTab
,
2541 (SCCOL
)(nStartCol
+nIndex
+nCount
-1), MAXROW
, nTab
);
2542 bDone
= aFunc
.DeleteCells( aRange
, NULL
, DEL_DELCOLS
, TRUE
, TRUE
);
2545 throw uno::RuntimeException(); // no other exceptions specified
2548 // XEnumerationAccess
2550 uno::Reference
<container::XEnumeration
> SAL_CALL
ScTableColumnsObj::createEnumeration()
2551 throw(uno::RuntimeException
)
2554 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableColumnsEnumeration")));
2559 sal_Int32 SAL_CALL
ScTableColumnsObj::getCount() throw(uno::RuntimeException
)
2562 return nEndCol
- nStartCol
+ 1;
2565 uno::Any SAL_CALL
ScTableColumnsObj::getByIndex( sal_Int32 nIndex
)
2566 throw(lang::IndexOutOfBoundsException
,
2567 lang::WrappedTargetException
, uno::RuntimeException
)
2570 uno::Reference
<table::XCellRange
> xColumn(GetObjectByIndex_Impl(nIndex
));
2572 return uno::makeAny(xColumn
);
2574 throw lang::IndexOutOfBoundsException();
2575 // return uno::Any();
2578 uno::Type SAL_CALL
ScTableColumnsObj::getElementType() throw(uno::RuntimeException
)
2581 return getCppuType((uno::Reference
<table::XCellRange
>*)0);
2584 sal_Bool SAL_CALL
ScTableColumnsObj::hasElements() throw(uno::RuntimeException
)
2587 return ( getCount() != 0 );
2590 uno::Any SAL_CALL
ScTableColumnsObj::getByName( const rtl::OUString
& aName
)
2591 throw(container::NoSuchElementException
,
2592 lang::WrappedTargetException
, uno::RuntimeException
)
2595 uno::Reference
<table::XCellRange
> xColumn(GetObjectByName_Impl(aName
));
2597 return uno::makeAny(xColumn
);
2599 throw container::NoSuchElementException();
2600 // return uno::Any();
2603 uno::Sequence
<rtl::OUString
> SAL_CALL
ScTableColumnsObj::getElementNames()
2604 throw(uno::RuntimeException
)
2607 SCCOL nCount
= nEndCol
- nStartCol
+ 1;
2608 uno::Sequence
<rtl::OUString
> aSeq(nCount
);
2609 rtl::OUString
* pAry
= aSeq
.getArray();
2610 for (SCCOL i
=0; i
<nCount
; i
++)
2611 pAry
[i
] = ::ScColToAlpha( nStartCol
+ i
);
2616 sal_Bool SAL_CALL
ScTableColumnsObj::hasByName( const rtl::OUString
& aName
)
2617 throw(uno::RuntimeException
)
2621 String
aString(aName
);
2622 if ( ::AlphaToCol( nCol
, aString
) )
2623 if ( pDocShell
&& nCol
>= nStartCol
&& nCol
<= nEndCol
)
2626 return FALSE
; // nicht gefunden
2631 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScTableColumnsObj::getPropertySetInfo()
2632 throw(uno::RuntimeException
)
2635 static uno::Reference
<beans::XPropertySetInfo
> aRef(
2636 new SfxItemPropertySetInfo( lcl_GetColumnsPropertyMap() ));
2640 void SAL_CALL
ScTableColumnsObj::setPropertyValue(
2641 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
2642 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
2643 lang::IllegalArgumentException
, lang::WrappedTargetException
,
2644 uno::RuntimeException
)
2648 throw uno::RuntimeException();
2650 ScDocFunc
aFunc(*pDocShell
);
2651 SCCOLROW nColArr
[2];
2652 nColArr
[0] = nStartCol
;
2653 nColArr
[1] = nEndCol
;
2654 String
aNameString(aPropertyName
);
2656 if ( aNameString
.EqualsAscii( SC_UNONAME_CELLWID
) )
2658 sal_Int32 nNewWidth
= 0;
2659 if ( aValue
>>= nNewWidth
)
2660 aFunc
.SetWidthOrHeight( TRUE
, 1, nColArr
, nTab
, SC_SIZE_ORIGINAL
,
2661 (USHORT
)HMMToTwips(nNewWidth
), TRUE
, TRUE
);
2663 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2665 BOOL bVis
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2666 ScSizeMode eMode
= bVis
? SC_SIZE_SHOW
: SC_SIZE_DIRECT
;
2667 aFunc
.SetWidthOrHeight( TRUE
, 1, nColArr
, nTab
, eMode
, 0, TRUE
, TRUE
);
2668 // SC_SIZE_DIRECT with size 0: hide
2670 else if ( aNameString
.EqualsAscii( SC_UNONAME_OWIDTH
) )
2672 BOOL bOpt
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2674 aFunc
.SetWidthOrHeight( TRUE
, 1, nColArr
, nTab
,
2675 SC_SIZE_OPTIMAL
, STD_EXTRA_WIDTH
, TRUE
, TRUE
);
2676 // FALSE for columns currently has no effect
2678 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) || aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2680 //! single function to set/remove all breaks?
2681 BOOL bSet
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2682 for (SCCOL nCol
=nStartCol
; nCol
<=nEndCol
; nCol
++)
2684 aFunc
.InsertPageBreak( TRUE
, ScAddress(nCol
,0,nTab
), TRUE
, TRUE
, TRUE
);
2686 aFunc
.RemovePageBreak( TRUE
, ScAddress(nCol
,0,nTab
), TRUE
, TRUE
, TRUE
);
2690 uno::Any SAL_CALL
ScTableColumnsObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
2691 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
2692 uno::RuntimeException
)
2696 throw uno::RuntimeException();
2698 ScDocument
* pDoc
= pDocShell
->GetDocument();
2699 String
aNameString(aPropertyName
);
2702 //! loop over all columns for current state?
2704 if ( aNameString
.EqualsAscii( SC_UNONAME_CELLWID
) )
2706 // for hidden column, return original height
2707 USHORT nWidth
= pDoc
->GetOriginalWidth( nStartCol
, nTab
);
2708 aAny
<<= (sal_Int32
)TwipsToHMM(nWidth
);
2710 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2713 bool bVis
= !pDoc
->ColHidden(nStartCol
, nTab
, nLastCol
);
2714 ScUnoHelpFunctions::SetBoolInAny( aAny
, bVis
);
2716 else if ( aNameString
.EqualsAscii( SC_UNONAME_OWIDTH
) )
2718 BOOL bOpt
= !(pDoc
->GetColFlags( nStartCol
, nTab
) & CR_MANUALSIZE
);
2719 ScUnoHelpFunctions::SetBoolInAny( aAny
, bOpt
);
2721 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) )
2723 ScBreakType nBreak
= pDoc
->HasColBreak(nStartCol
, nTab
);
2724 ScUnoHelpFunctions::SetBoolInAny( aAny
, nBreak
);
2726 else if ( aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2728 ScBreakType nBreak
= pDoc
->HasColBreak(nStartCol
, nTab
);
2729 ScUnoHelpFunctions::SetBoolInAny( aAny
, (nBreak
& BREAK_MANUAL
) );
2735 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableColumnsObj
)
2737 //------------------------------------------------------------------------
2739 ScTableRowsObj::ScTableRowsObj(ScDocShell
* pDocSh
, SCTAB nT
, SCROW nSR
, SCROW nER
) :
2740 pDocShell( pDocSh
),
2745 pDocShell
->GetDocument()->AddUnoObject(*this);
2748 ScTableRowsObj::~ScTableRowsObj()
2751 pDocShell
->GetDocument()->RemoveUnoObject(*this);
2754 void ScTableRowsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
2756 if ( rHint
.ISA( ScUpdateRefHint
) )
2758 // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
2760 //! Referenz-Update fuer Tab und Start/Ende
2762 else if ( rHint
.ISA( SfxSimpleHint
) &&
2763 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
2765 pDocShell
= NULL
; // ungueltig geworden
2771 ScTableRowObj
* ScTableRowsObj::GetObjectByIndex_Impl(sal_Int32 nIndex
) const
2773 SCROW nRow
= static_cast<SCROW
>(nIndex
) + nStartRow
;
2774 if ( pDocShell
&& nRow
<= nEndRow
)
2775 return new ScTableRowObj( pDocShell
, nRow
, nTab
);
2777 return NULL
; // falscher Index
2780 void SAL_CALL
ScTableRowsObj::insertByIndex( sal_Int32 nPosition
, sal_Int32 nCount
)
2781 throw(uno::RuntimeException
)
2785 if ( pDocShell
&& nCount
> 0 && nPosition
>= 0 && nStartRow
+nPosition
<= nEndRow
&&
2786 nStartRow
+nPosition
+nCount
-1 <= MAXROW
)
2788 ScDocFunc
aFunc(*pDocShell
);
2789 ScRange
aRange( 0, (SCROW
)(nStartRow
+nPosition
), nTab
,
2790 MAXCOL
, (SCROW
)(nStartRow
+nPosition
+nCount
-1), nTab
);
2791 bDone
= aFunc
.InsertCells( aRange
, NULL
, INS_INSROWS
, TRUE
, TRUE
);
2794 throw uno::RuntimeException(); // no other exceptions specified
2797 void SAL_CALL
ScTableRowsObj::removeByIndex( sal_Int32 nIndex
, sal_Int32 nCount
)
2798 throw(uno::RuntimeException
)
2802 // Der zu loeschende Bereich muss innerhalb des Objekts liegen
2803 if ( pDocShell
&& nCount
> 0 && nIndex
>= 0 && nStartRow
+nIndex
+nCount
-1 <= nEndRow
)
2805 ScDocFunc
aFunc(*pDocShell
);
2806 ScRange
aRange( 0, (SCROW
)(nStartRow
+nIndex
), nTab
,
2807 MAXCOL
, (SCROW
)(nStartRow
+nIndex
+nCount
-1), nTab
);
2808 bDone
= aFunc
.DeleteCells( aRange
, NULL
, DEL_DELROWS
, TRUE
, TRUE
);
2811 throw uno::RuntimeException(); // no other exceptions specified
2814 // XEnumerationAccess
2816 uno::Reference
<container::XEnumeration
> SAL_CALL
ScTableRowsObj::createEnumeration()
2817 throw(uno::RuntimeException
)
2820 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableRowsEnumeration")));
2825 sal_Int32 SAL_CALL
ScTableRowsObj::getCount() throw(uno::RuntimeException
)
2828 return nEndRow
- nStartRow
+ 1;
2831 uno::Any SAL_CALL
ScTableRowsObj::getByIndex( sal_Int32 nIndex
)
2832 throw(lang::IndexOutOfBoundsException
,
2833 lang::WrappedTargetException
, uno::RuntimeException
)
2836 uno::Reference
<table::XCellRange
> xRow(GetObjectByIndex_Impl(nIndex
));
2838 return uno::makeAny(xRow
);
2840 throw lang::IndexOutOfBoundsException();
2841 // return uno::Any();
2844 uno::Type SAL_CALL
ScTableRowsObj::getElementType() throw(uno::RuntimeException
)
2847 return getCppuType((uno::Reference
<table::XCellRange
>*)0);
2850 sal_Bool SAL_CALL
ScTableRowsObj::hasElements() throw(uno::RuntimeException
)
2853 return ( getCount() != 0 );
2858 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScTableRowsObj::getPropertySetInfo()
2859 throw(uno::RuntimeException
)
2862 static uno::Reference
<beans::XPropertySetInfo
> aRef(
2863 new SfxItemPropertySetInfo( lcl_GetRowsPropertyMap() ));
2867 void SAL_CALL
ScTableRowsObj::setPropertyValue(
2868 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
2869 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
2870 lang::IllegalArgumentException
, lang::WrappedTargetException
,
2871 uno::RuntimeException
)
2875 throw uno::RuntimeException();
2877 ScDocFunc
aFunc(*pDocShell
);
2878 ScDocument
* pDoc
= pDocShell
->GetDocument();
2879 SCCOLROW nRowArr
[2];
2880 nRowArr
[0] = nStartRow
;
2881 nRowArr
[1] = nEndRow
;
2882 String
aNameString(aPropertyName
);
2884 if ( aNameString
.EqualsAscii( SC_UNONAME_OHEIGHT
) )
2886 sal_Int32 nNewHeight
= 0;
2887 if ( pDoc
->IsImportingXML() && ( aValue
>>= nNewHeight
) )
2889 // used to set the stored row height for rows with optimal height when loading
2890 pDoc
->SetRowHeightRange( nStartRow
, nEndRow
, nTab
, (USHORT
)HMMToTwips(nNewHeight
) );
2894 BOOL bOpt
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2896 aFunc
.SetWidthOrHeight( FALSE
, 1, nRowArr
, nTab
, SC_SIZE_OPTIMAL
, 0, TRUE
, TRUE
);
2899 //! manually set old heights again?
2903 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLHGT
) )
2905 sal_Int32 nNewHeight
= 0;
2906 if ( aValue
>>= nNewHeight
)
2907 aFunc
.SetWidthOrHeight( FALSE
, 1, nRowArr
, nTab
, SC_SIZE_ORIGINAL
,
2908 (USHORT
)HMMToTwips(nNewHeight
), TRUE
, TRUE
);
2910 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2912 BOOL bVis
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2913 ScSizeMode eMode
= bVis
? SC_SIZE_SHOW
: SC_SIZE_DIRECT
;
2914 aFunc
.SetWidthOrHeight( FALSE
, 1, nRowArr
, nTab
, eMode
, 0, TRUE
, TRUE
);
2915 // SC_SIZE_DIRECT with size 0: hide
2917 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLFILT
) )
2920 if (ScUnoHelpFunctions::GetBoolFromAny( aValue
))
2921 pDoc
->SetRowFiltered(nStartRow
, nEndRow
, nTab
, true);
2923 pDoc
->SetRowFiltered(nStartRow
, nEndRow
, nTab
, false);
2925 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) || aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2927 //! single function to set/remove all breaks?
2928 BOOL bSet
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2929 for (SCROW nRow
=nStartRow
; nRow
<=nEndRow
; nRow
++)
2931 aFunc
.InsertPageBreak( FALSE
, ScAddress(0,nRow
,nTab
), TRUE
, TRUE
, TRUE
);
2933 aFunc
.RemovePageBreak( FALSE
, ScAddress(0,nRow
,nTab
), TRUE
, TRUE
, TRUE
);
2935 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLBACK
) || aNameString
.EqualsAscii( SC_UNONAME_CELLTRAN
) )
2937 // #i57867# Background color is specified for row styles in the file format,
2938 // so it has to be supported along with the row properties (import only).
2940 // Use ScCellRangeObj to set the property for all cells in the rows
2941 // (this means, the "row attribute" must be set before individual cell attributes).
2943 ScRange
aRange( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
);
2944 uno::Reference
<beans::XPropertySet
> xRangeObj
= new ScCellRangeObj( pDocShell
, aRange
);
2945 xRangeObj
->setPropertyValue( aPropertyName
, aValue
);
2949 uno::Any SAL_CALL
ScTableRowsObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
2950 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
2951 uno::RuntimeException
)
2955 throw uno::RuntimeException();
2957 ScDocument
* pDoc
= pDocShell
->GetDocument();
2958 String
aNameString(aPropertyName
);
2961 //! loop over all rows for current state?
2963 if ( aNameString
.EqualsAscii( SC_UNONAME_CELLHGT
) )
2965 // for hidden row, return original height
2966 USHORT nHeight
= pDoc
->GetOriginalHeight( nStartRow
, nTab
);
2967 aAny
<<= (sal_Int32
)TwipsToHMM(nHeight
);
2969 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2972 bool bVis
= !pDoc
->RowHidden(nStartRow
, nTab
, nLastRow
);
2973 ScUnoHelpFunctions::SetBoolInAny( aAny
, bVis
);
2975 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLFILT
) )
2977 bool bVis
= pDoc
->RowFiltered(nStartRow
, nTab
);
2978 ScUnoHelpFunctions::SetBoolInAny( aAny
, bVis
);
2980 else if ( aNameString
.EqualsAscii( SC_UNONAME_OHEIGHT
) )
2982 BOOL bOpt
= !(pDoc
->GetRowFlags( nStartRow
, nTab
) & CR_MANUALSIZE
);
2983 ScUnoHelpFunctions::SetBoolInAny( aAny
, bOpt
);
2985 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) )
2987 ScBreakType nBreak
= pDoc
->HasRowBreak(nStartRow
, nTab
);
2988 ScUnoHelpFunctions::SetBoolInAny( aAny
, nBreak
);
2990 else if ( aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2992 ScBreakType nBreak
= pDoc
->HasRowBreak(nStartRow
, nTab
);
2993 ScUnoHelpFunctions::SetBoolInAny( aAny
, (nBreak
& BREAK_MANUAL
) );
2995 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLBACK
) || aNameString
.EqualsAscii( SC_UNONAME_CELLTRAN
) )
2997 // Use ScCellRangeObj to get the property from the cell range
2998 // (for completeness only, this is not used by the XML filter).
3000 ScRange
aRange( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
);
3001 uno::Reference
<beans::XPropertySet
> xRangeObj
= new ScCellRangeObj( pDocShell
, aRange
);
3002 aAny
= xRangeObj
->getPropertyValue( aPropertyName
);
3008 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableRowsObj
)
3010 //------------------------------------------------------------------------
3012 //UNUSED2008-05 ScSpreadsheetSettingsObj::ScSpreadsheetSettingsObj(ScDocShell* pDocSh) :
3013 //UNUSED2008-05 pDocShell( pDocSh )
3015 //UNUSED2008-05 pDocShell->GetDocument()->AddUnoObject(*this);
3018 ScSpreadsheetSettingsObj::~ScSpreadsheetSettingsObj()
3021 pDocShell
->GetDocument()->RemoveUnoObject(*this);
3024 void ScSpreadsheetSettingsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
3026 // Referenz-Update interessiert hier nicht
3028 if ( rHint
.ISA( SfxSimpleHint
) &&
3029 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
3031 pDocShell
= NULL
; // ungueltig geworden
3037 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScSpreadsheetSettingsObj::getPropertySetInfo()
3038 throw(uno::RuntimeException
)
3044 void SAL_CALL
ScSpreadsheetSettingsObj::setPropertyValue(
3045 const rtl::OUString
& /* aPropertyName */, const uno::Any
& /* aValue */ )
3046 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
3047 lang::IllegalArgumentException
, lang::WrappedTargetException
,
3048 uno::RuntimeException
)
3053 uno::Any SAL_CALL
ScSpreadsheetSettingsObj::getPropertyValue( const rtl::OUString
& /* aPropertyName */ )
3054 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
3055 uno::RuntimeException
)
3061 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettingsObj
)
3063 //------------------------------------------------------------------------
3065 ScAnnotationsObj::ScAnnotationsObj(ScDocShell
* pDocSh
, SCTAB nT
) :
3066 pDocShell( pDocSh
),
3069 pDocShell
->GetDocument()->AddUnoObject(*this);
3072 ScAnnotationsObj::~ScAnnotationsObj()
3075 pDocShell
->GetDocument()->RemoveUnoObject(*this);
3078 void ScAnnotationsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
3080 //! nTab bei Referenz-Update anpassen!!!
3082 if ( rHint
.ISA( SfxSimpleHint
) &&
3083 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
3085 pDocShell
= NULL
; // ungueltig geworden
3089 bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex
, ScAddress
& rPos
) const
3093 sal_Int32 nFound
= 0;
3094 ScDocument
* pDoc
= pDocShell
->GetDocument();
3095 ScCellIterator
aCellIter( pDoc
, 0,0, nTab
, MAXCOL
,MAXROW
, nTab
);
3096 for( ScBaseCell
* pCell
= aCellIter
.GetFirst(); pCell
; pCell
= aCellIter
.GetNext() )
3098 if (pCell
->HasNote())
3100 if (nFound
== nIndex
)
3102 rPos
= ScAddress( aCellIter
.GetCol(), aCellIter
.GetRow(), aCellIter
.GetTab() );
3112 ScAnnotationObj
* ScAnnotationsObj::GetObjectByIndex_Impl( sal_Int32 nIndex
) const
3117 if ( GetAddressByIndex_Impl( nIndex
, aPos
) )
3118 return new ScAnnotationObj( pDocShell
, aPos
);
3123 // XSheetAnnotations
3125 void SAL_CALL
ScAnnotationsObj::insertNew(
3126 const table::CellAddress
& aPosition
, const ::rtl::OUString
& rText
)
3127 throw(uno::RuntimeException
)
3132 DBG_ASSERT( aPosition
.Sheet
== nTab
, "addAnnotation mit falschem Sheet" );
3133 ScAddress
aPos( (SCCOL
)aPosition
.Column
, (SCROW
)aPosition
.Row
, nTab
);
3135 ScDocFunc
aFunc( *pDocShell
);
3136 aFunc
.ReplaceNote( aPos
, rText
, 0, 0, TRUE
);
3140 void SAL_CALL
ScAnnotationsObj::removeByIndex( sal_Int32 nIndex
) throw(uno::RuntimeException
)
3146 if ( GetAddressByIndex_Impl( nIndex
, aPos
) )
3148 ScMarkData aMarkData
;
3149 aMarkData
.SelectTable( aPos
.Tab(), TRUE
);
3150 aMarkData
.SetMultiMarkArea( ScRange(aPos
) );
3152 ScDocFunc
aFunc(*pDocShell
);
3153 aFunc
.DeleteContents( aMarkData
, IDF_NOTE
, TRUE
, TRUE
);
3158 // XEnumerationAccess
3160 uno::Reference
<container::XEnumeration
> SAL_CALL
ScAnnotationsObj::createEnumeration()
3161 throw(uno::RuntimeException
)
3163 //! iterate directly (more efficiently)?
3166 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.CellAnnotationsEnumeration")));
3171 sal_Int32 SAL_CALL
ScAnnotationsObj::getCount() throw(uno::RuntimeException
)
3177 ScCellIterator
aCellIter( pDocShell
->GetDocument(), 0,0, nTab
, MAXCOL
,MAXROW
, nTab
);
3178 for( ScBaseCell
* pCell
= aCellIter
.GetFirst(); pCell
; pCell
= aCellIter
.GetNext() )
3179 if (pCell
->HasNote())
3185 uno::Any SAL_CALL
ScAnnotationsObj::getByIndex( sal_Int32 nIndex
)
3186 throw(lang::IndexOutOfBoundsException
,
3187 lang::WrappedTargetException
, uno::RuntimeException
)
3190 uno::Reference
<sheet::XSheetAnnotation
> xAnnotation(GetObjectByIndex_Impl(nIndex
));
3191 if (xAnnotation
.is())
3192 return uno::makeAny(xAnnotation
);
3194 throw lang::IndexOutOfBoundsException();
3195 // return uno::Any();
3198 uno::Type SAL_CALL
ScAnnotationsObj::getElementType() throw(uno::RuntimeException
)
3201 return getCppuType((uno::Reference
<sheet::XSheetAnnotation
>*)0);
3204 sal_Bool SAL_CALL
ScAnnotationsObj::hasElements() throw(uno::RuntimeException
)
3207 return ( getCount() != 0 );
3210 //------------------------------------------------------------------------
3212 ScScenariosObj::ScScenariosObj(ScDocShell
* pDocSh
, SCTAB nT
) :
3213 pDocShell( pDocSh
),
3216 pDocShell
->GetDocument()->AddUnoObject(*this);
3219 ScScenariosObj::~ScScenariosObj()
3222 pDocShell
->GetDocument()->RemoveUnoObject(*this);
3225 void ScScenariosObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
3227 if ( rHint
.ISA( ScUpdateRefHint
) )
3229 // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
3231 //! Referenz-Update fuer Tab und Start/Ende
3233 else if ( rHint
.ISA( SfxSimpleHint
) &&
3234 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
3236 pDocShell
= NULL
; // ungueltig geworden
3242 BOOL
ScScenariosObj::GetScenarioIndex_Impl( const rtl::OUString
& rName
, SCTAB
& rIndex
)
3244 //! Case-insensitiv ????
3248 String
aString(rName
);
3251 ScDocument
* pDoc
= pDocShell
->GetDocument();
3252 SCTAB nCount
= (SCTAB
)getCount();
3253 for (SCTAB i
=0; i
<nCount
; i
++)
3254 if (pDoc
->GetName( nTab
+i
+1, aTabName
))
3255 if ( aTabName
== aString
)
3265 ScTableSheetObj
* ScScenariosObj::GetObjectByIndex_Impl(sal_Int32 nIndex
)
3267 USHORT nCount
= (USHORT
)getCount();
3268 if ( pDocShell
&& nIndex
>= 0 && nIndex
< nCount
)
3269 return new ScTableSheetObj( pDocShell
, nTab
+static_cast<SCTAB
>(nIndex
)+1 );
3271 return NULL
; // kein Dokument oder falscher Index
3274 ScTableSheetObj
* ScScenariosObj::GetObjectByName_Impl(const rtl::OUString
& aName
)
3277 if ( pDocShell
&& GetScenarioIndex_Impl( aName
, nIndex
) )
3278 return new ScTableSheetObj( pDocShell
, nTab
+nIndex
+1 );
3280 return NULL
; // nicht gefunden
3283 void SAL_CALL
ScScenariosObj::addNewByName( const rtl::OUString
& aName
,
3284 const uno::Sequence
<table::CellRangeAddress
>& aRanges
,
3285 const rtl::OUString
& aComment
)
3286 throw(uno::RuntimeException
)
3291 ScMarkData aMarkData
;
3292 aMarkData
.SelectTable( nTab
, TRUE
);
3294 USHORT nRangeCount
= (USHORT
)aRanges
.getLength();
3297 const table::CellRangeAddress
* pAry
= aRanges
.getConstArray();
3298 for (USHORT i
=0; i
<nRangeCount
; i
++)
3300 DBG_ASSERT( pAry
[i
].Sheet
== nTab
, "addScenario mit falscher Tab" );
3301 ScRange
aRange( (SCCOL
)pAry
[i
].StartColumn
, (SCROW
)pAry
[i
].StartRow
, nTab
,
3302 (SCCOL
)pAry
[i
].EndColumn
, (SCROW
)pAry
[i
].EndRow
, nTab
);
3304 aMarkData
.SetMultiMarkArea( aRange
);
3308 String
aNameStr(aName
);
3309 String
aCommStr(aComment
);
3311 Color
aColor( COL_LIGHTGRAY
); // Default
3312 USHORT nFlags
= SC_SCENARIO_SHOWFRAME
| SC_SCENARIO_PRINTFRAME
| SC_SCENARIO_TWOWAY
| SC_SCENARIO_PROTECT
;
3314 pDocShell
->MakeScenario( nTab
, aNameStr
, aCommStr
, aColor
, nFlags
, aMarkData
);
3318 void SAL_CALL
ScScenariosObj::removeByName( const rtl::OUString
& aName
)
3319 throw(uno::RuntimeException
)
3323 if ( pDocShell
&& GetScenarioIndex_Impl( aName
, nIndex
) )
3325 ScDocFunc
aFunc(*pDocShell
);
3326 aFunc
.DeleteTable( nTab
+nIndex
+1, TRUE
, TRUE
);
3330 // XEnumerationAccess
3332 uno::Reference
<container::XEnumeration
> SAL_CALL
ScScenariosObj::createEnumeration()
3333 throw(uno::RuntimeException
)
3336 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.ScenariosEnumeration")));
3341 sal_Int32 SAL_CALL
ScScenariosObj::getCount() throw(uno::RuntimeException
)
3347 ScDocument
* pDoc
= pDocShell
->GetDocument();
3348 if (!pDoc
->IsScenario(nTab
))
3350 SCTAB nTabCount
= pDoc
->GetTableCount();
3351 SCTAB nNext
= nTab
+ 1;
3352 while (nNext
< nTabCount
&& pDoc
->IsScenario(nNext
))
3362 uno::Any SAL_CALL
ScScenariosObj::getByIndex( sal_Int32 nIndex
)
3363 throw(lang::IndexOutOfBoundsException
,
3364 lang::WrappedTargetException
, uno::RuntimeException
)
3367 uno::Reference
<sheet::XScenario
> xScen(GetObjectByIndex_Impl(nIndex
));
3369 return uno::makeAny(xScen
);
3371 throw lang::IndexOutOfBoundsException();
3372 // return uno::Any();
3375 uno::Type SAL_CALL
ScScenariosObj::getElementType() throw(uno::RuntimeException
)
3378 return getCppuType((uno::Reference
<sheet::XScenario
>*)0);
3381 sal_Bool SAL_CALL
ScScenariosObj::hasElements() throw(uno::RuntimeException
)
3384 return ( getCount() != 0 );
3387 uno::Any SAL_CALL
ScScenariosObj::getByName( const rtl::OUString
& aName
)
3388 throw(container::NoSuchElementException
,
3389 lang::WrappedTargetException
, uno::RuntimeException
)
3392 uno::Reference
<sheet::XScenario
> xScen(GetObjectByName_Impl(aName
));
3394 return uno::makeAny(xScen
);
3396 throw container::NoSuchElementException();
3397 // return uno::Any();
3400 uno::Sequence
<rtl::OUString
> SAL_CALL
ScScenariosObj::getElementNames()
3401 throw(uno::RuntimeException
)
3404 SCTAB nCount
= (SCTAB
)getCount();
3405 uno::Sequence
<rtl::OUString
> aSeq(nCount
);
3407 if ( pDocShell
) // sonst ist auch Count = 0
3410 ScDocument
* pDoc
= pDocShell
->GetDocument();
3411 rtl::OUString
* pAry
= aSeq
.getArray();
3412 for (SCTAB i
=0; i
<nCount
; i
++)
3413 if (pDoc
->GetName( nTab
+i
+1, aTabName
))
3420 sal_Bool SAL_CALL
ScScenariosObj::hasByName( const rtl::OUString
& aName
)
3421 throw(uno::RuntimeException
)
3425 return GetScenarioIndex_Impl( aName
, nIndex
);