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
)
231 // pDocShell may be NULL if this is the base of a ScDocOptionsObj
234 pDocShell
->GetDocument()->AddUnoObject(*this); // SfxModel is derived from SfxListener
238 ScModelObj::~ScModelObj()
241 pDocShell
->GetDocument()->RemoveUnoObject(*this);
244 xNumberAgg
->setDelegator(uno::Reference
<uno::XInterface
>());
246 delete pPrintFuncCache
;
249 uno::Reference
< uno::XAggregation
> ScModelObj::GetFormatter()
251 if ( !xNumberAgg
.is() )
253 // setDelegator veraendert den RefCount, darum eine Referenz selber halten
254 // (direkt am m_refCount, um sich beim release nicht selbst zu loeschen)
255 comphelper::increment( m_refCount
);
256 // waehrend des queryInterface braucht man ein Ref auf das
257 // SvNumberFormatsSupplierObj, sonst wird es geloescht.
258 uno::Reference
<util::XNumberFormatsSupplier
> xFormatter(new SvNumberFormatsSupplierObj(pDocShell
->GetDocument()->GetFormatTable() ));
260 xNumberAgg
.set(uno::Reference
<uno::XAggregation
>( xFormatter
, uno::UNO_QUERY
));
261 // extra block to force deletion of the temporary before setDelegator
264 // beim setDelegator darf die zusaetzliche Ref nicht mehr existieren
268 xNumberAgg
->setDelegator( (cppu::OWeakObject
*)this );
269 comphelper::decrement( m_refCount
);
270 } // if ( !xNumberAgg.is() )
274 ScDocument
* ScModelObj::GetDocument() const
277 return pDocShell
->GetDocument();
281 SfxObjectShell
* ScModelObj::GetEmbeddedObject() const
286 void ScModelObj::UpdateAllRowHeights(const ScMarkData
* pTabMark
)
289 pDocShell
->UpdateAllRowHeights(pTabMark
);
292 void ScModelObj::BeforeXMLLoading()
295 pDocShell
->BeforeXMLLoading();
298 void ScModelObj::AfterXMLLoading(sal_Bool bRet
)
301 pDocShell
->AfterXMLLoading(bRet
);
304 ScSheetSaveData
* ScModelObj::GetSheetSaveData()
307 return pDocShell
->GetSheetSaveData();
311 uno::Any SAL_CALL
ScModelObj::queryInterface( const uno::Type
& rType
)
312 throw(uno::RuntimeException
)
314 SC_QUERYINTERFACE( sheet::XSpreadsheetDocument
)
315 SC_QUERYINTERFACE( document::XActionLockable
)
316 SC_QUERYINTERFACE( sheet::XCalculatable
)
317 SC_QUERYINTERFACE( util::XProtectable
)
318 SC_QUERYINTERFACE( drawing::XDrawPagesSupplier
)
319 SC_QUERYINTERFACE( sheet::XGoalSeek
)
320 SC_QUERYINTERFACE( sheet::XConsolidatable
)
321 SC_QUERYINTERFACE( sheet::XDocumentAuditing
)
322 SC_QUERYINTERFACE( style::XStyleFamiliesSupplier
)
323 SC_QUERYINTERFACE( view::XRenderable
)
324 SC_QUERYINTERFACE( document::XLinkTargetSupplier
)
325 SC_QUERYINTERFACE( beans::XPropertySet
)
326 SC_QUERYINTERFACE( document::XDocumentEventCompatibleHelper
)
327 SC_QUERYINTERFACE( lang::XMultiServiceFactory
)
328 SC_QUERYINTERFACE( lang::XServiceInfo
)
329 SC_QUERYINTERFACE( util::XChangesNotifier
)
331 uno::Any
aRet(SfxBaseModel::queryInterface( rType
));
332 if ( !aRet
.hasValue()
333 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::document::XDocumentEventBroadcaster
>*)0)
334 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::frame::XController
>*)0)
335 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::frame::XFrame
>*)0)
336 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::script::XInvocation
>*)0)
337 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::reflection::XIdlClassProvider
>*)0)
338 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::beans::XFastPropertySet
>*)0)
339 && rType
!= ::getCppuType((uno::Reference
< com::sun::star::awt::XWindow
>*)0))
342 if ( xNumberAgg
.is() )
343 aRet
= xNumberAgg
->queryAggregation( rType
);
349 void SAL_CALL
ScModelObj::acquire() throw()
351 SfxBaseModel::acquire();
354 void SAL_CALL
ScModelObj::release() throw()
356 SfxBaseModel::release();
359 uno::Sequence
<uno::Type
> SAL_CALL
ScModelObj::getTypes() throw(uno::RuntimeException
)
361 static uno::Sequence
<uno::Type
> aTypes
;
362 if ( aTypes
.getLength() == 0 )
364 uno::Sequence
<uno::Type
> aParentTypes(SfxBaseModel::getTypes());
365 long nParentLen
= aParentTypes
.getLength();
366 const uno::Type
* pParentPtr
= aParentTypes
.getConstArray();
368 uno::Sequence
<uno::Type
> aAggTypes
;
369 if ( GetFormatter().is() )
371 const uno::Type
& rProvType
= ::getCppuType((uno::Reference
<lang::XTypeProvider
>*) 0);
372 uno::Any
aNumProv(xNumberAgg
->queryAggregation(rProvType
));
373 if(aNumProv
.getValueType() == rProvType
)
375 uno::Reference
<lang::XTypeProvider
> xNumProv(
376 *(uno::Reference
<lang::XTypeProvider
>*)aNumProv
.getValue());
377 aAggTypes
= xNumProv
->getTypes();
380 long nAggLen
= aAggTypes
.getLength();
381 const uno::Type
* pAggPtr
= aAggTypes
.getConstArray();
383 const long nThisLen
= 15;
384 aTypes
.realloc( nParentLen
+ nAggLen
+ nThisLen
);
385 uno::Type
* pPtr
= aTypes
.getArray();
386 pPtr
[nParentLen
+ 0] = getCppuType((const uno::Reference
<sheet::XSpreadsheetDocument
>*)0);
387 pPtr
[nParentLen
+ 1] = getCppuType((const uno::Reference
<document::XActionLockable
>*)0);
388 pPtr
[nParentLen
+ 2] = getCppuType((const uno::Reference
<sheet::XCalculatable
>*)0);
389 pPtr
[nParentLen
+ 3] = getCppuType((const uno::Reference
<util::XProtectable
>*)0);
390 pPtr
[nParentLen
+ 4] = getCppuType((const uno::Reference
<drawing::XDrawPagesSupplier
>*)0);
391 pPtr
[nParentLen
+ 5] = getCppuType((const uno::Reference
<sheet::XGoalSeek
>*)0);
392 pPtr
[nParentLen
+ 6] = getCppuType((const uno::Reference
<sheet::XConsolidatable
>*)0);
393 pPtr
[nParentLen
+ 7] = getCppuType((const uno::Reference
<sheet::XDocumentAuditing
>*)0);
394 pPtr
[nParentLen
+ 8] = getCppuType((const uno::Reference
<style::XStyleFamiliesSupplier
>*)0);
395 pPtr
[nParentLen
+ 9] = getCppuType((const uno::Reference
<view::XRenderable
>*)0);
396 pPtr
[nParentLen
+10] = getCppuType((const uno::Reference
<document::XLinkTargetSupplier
>*)0);
397 pPtr
[nParentLen
+11] = getCppuType((const uno::Reference
<beans::XPropertySet
>*)0);
398 pPtr
[nParentLen
+12] = getCppuType((const uno::Reference
<lang::XMultiServiceFactory
>*)0);
399 pPtr
[nParentLen
+13] = getCppuType((const uno::Reference
<lang::XServiceInfo
>*)0);
400 pPtr
[nParentLen
+14] = getCppuType((const uno::Reference
<util::XChangesNotifier
>*)0);
403 for (i
=0; i
<nParentLen
; i
++)
404 pPtr
[i
] = pParentPtr
[i
]; // parent types first
406 for (i
=0; i
<nAggLen
; i
++)
407 pPtr
[nParentLen
+nThisLen
+i
] = pAggPtr
[i
]; // aggregated types last
412 uno::Sequence
<sal_Int8
> SAL_CALL
ScModelObj::getImplementationId()
413 throw(uno::RuntimeException
)
415 static uno::Sequence
< sal_Int8
> aId
;
416 if( aId
.getLength() == 0 )
419 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
424 void ScModelObj::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
426 // Not interested in reference update hints here
428 if ( rHint
.ISA( SfxSimpleHint
) )
430 ULONG nId
= ((const SfxSimpleHint
&)rHint
).GetId();
431 if ( nId
== SFX_HINT_DYING
)
433 pDocShell
= NULL
; // has become invalid
436 SvNumberFormatsSupplierObj
* pNumFmt
=
437 SvNumberFormatsSupplierObj::getImplementation(
438 uno::Reference
<util::XNumberFormatsSupplier
>(xNumberAgg
, uno::UNO_QUERY
) );
440 pNumFmt
->SetNumberFormatter( NULL
);
443 DELETEZ( pPrintFuncCache
); // must be deleted because it has a pointer to the DocShell
445 else if ( nId
== SFX_HINT_DATACHANGED
)
447 // cached data for rendering become invalid when contents change
448 // (if a broadcast is added to SetDrawModified, is has to be tested here, too)
450 DELETEZ( pPrintFuncCache
);
453 else if ( rHint
.ISA( ScPointerChangedHint
) )
455 USHORT nFlags
= ((const ScPointerChangedHint
&)rHint
).GetFlags();
456 if (nFlags
& SC_POINTERCHANGED_NUMFMT
)
458 // NumberFormatter-Pointer am Uno-Objekt neu setzen
460 if (GetFormatter().is())
462 SvNumberFormatsSupplierObj
* pNumFmt
=
463 SvNumberFormatsSupplierObj::getImplementation(
464 uno::Reference
<util::XNumberFormatsSupplier
>(xNumberAgg
, uno::UNO_QUERY
) );
465 if ( pNumFmt
&& pDocShell
)
466 pNumFmt
->SetNumberFormatter( pDocShell
->GetDocument()->GetFormatTable() );
471 // always call parent - SfxBaseModel might need to handle the same hints again
472 SfxBaseModel::Notify( rBC
, rHint
); // SfxBaseModel is derived from SfxListener
475 // XSpreadsheetDocument
477 uno::Reference
<sheet::XSpreadsheets
> SAL_CALL
ScModelObj::getSheets() throw(uno::RuntimeException
)
481 return new ScTableSheetsObj(pDocShell
);
485 // XStyleFamiliesSupplier
487 uno::Reference
<container::XNameAccess
> SAL_CALL
ScModelObj::getStyleFamilies()
488 throw(uno::RuntimeException
)
492 return new ScStyleFamiliesObj(pDocShell
);
498 OutputDevice
* lcl_GetRenderDevice( const uno::Sequence
<beans::PropertyValue
>& rOptions
)
500 OutputDevice
* pRet
= NULL
;
501 const beans::PropertyValue
* pPropArray
= rOptions
.getConstArray();
502 long nPropCount
= rOptions
.getLength();
503 for (long i
= 0; i
< nPropCount
; i
++)
505 const beans::PropertyValue
& rProp
= pPropArray
[i
];
506 String
aPropName(rProp
.Name
);
508 if (aPropName
.EqualsAscii( SC_UNONAME_RENDERDEV
))
510 uno::Reference
<awt::XDevice
> xRenderDevice(rProp
.Value
, uno::UNO_QUERY
);
511 if ( xRenderDevice
.is() )
513 VCLXDevice
* pDevice
= VCLXDevice::GetImplementation( xRenderDevice
);
516 pRet
= pDevice
->GetOutputDevice();
517 pRet
->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
525 bool lcl_ParseTarget( const String
& rTarget
, ScRange
& rTargetRange
, Rectangle
& rTargetRect
,
526 bool& rIsSheet
, ScDocument
* pDoc
, SCTAB nSourceTab
)
528 // test in same order as in SID_CURRENTCELL execute
531 ScRangeUtil aRangeUtil
;
533 sal_Int32 nNumeric
= 0;
535 bool bRangeValid
= false;
536 bool bRectValid
= false;
538 if ( rTargetRange
.Parse( rTarget
, pDoc
) & SCA_VALID
)
540 bRangeValid
= true; // range reference
542 else if ( aAddress
.Parse( rTarget
, pDoc
) & SCA_VALID
)
544 rTargetRange
= aAddress
;
545 bRangeValid
= true; // cell reference
547 else if ( aRangeUtil
.MakeRangeFromName( rTarget
, pDoc
, nSourceTab
, rTargetRange
, RUTL_NAMES
) ||
548 aRangeUtil
.MakeRangeFromName( rTarget
, pDoc
, nSourceTab
, rTargetRange
, RUTL_DBASE
) )
550 bRangeValid
= true; // named range or database range
552 else if ( ByteString( rTarget
, RTL_TEXTENCODING_ASCII_US
).IsNumericAscii() &&
553 ( nNumeric
= rTarget
.ToInt32() ) > 0 && nNumeric
<= MAXROW
+1 )
555 // row number is always mapped to cell A(row) on the same sheet
556 rTargetRange
= ScAddress( 0, (SCROW
)(nNumeric
-1), nSourceTab
); // target row number is 1-based
557 bRangeValid
= true; // row number
559 else if ( pDoc
->GetTable( rTarget
, nNameTab
) )
561 rTargetRange
= ScAddress(0,0,nNameTab
);
562 bRangeValid
= true; // sheet name
563 rIsSheet
= true; // needs special handling (first page of the sheet)
567 // look for named drawing object
569 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
572 SCTAB nTabCount
= pDoc
->GetTableCount();
573 for (SCTAB i
=0; i
<nTabCount
&& !bRangeValid
; i
++)
575 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(i
));
576 DBG_ASSERT(pPage
,"Page ?");
579 SdrObjListIter
aIter( *pPage
, IM_DEEPWITHGROUPS
);
580 SdrObject
* pObject
= aIter
.Next();
581 while (pObject
&& !bRangeValid
)
583 if ( ScDrawLayer::GetVisibleName( pObject
) == rTarget
)
585 rTargetRect
= pObject
->GetLogicRect(); // 1/100th mm
586 rTargetRange
= pDoc
->GetRange( i
, rTargetRect
); // underlying cells
587 bRangeValid
= bRectValid
= true; // rectangle is valid
589 pObject
= aIter
.Next();
595 if ( bRangeValid
&& !bRectValid
)
597 // get rectangle for cell range
598 rTargetRect
= pDoc
->GetMMRect( rTargetRange
.aStart
.Col(), rTargetRange
.aStart
.Row(),
599 rTargetRange
.aEnd
.Col(), rTargetRange
.aEnd
.Row(),
600 rTargetRange
.aStart
.Tab() );
606 BOOL
ScModelObj::FillRenderMarkData( const uno::Any
& aSelection
, ScMarkData
& rMark
,
607 ScPrintSelectionStatus
& rStatus
) const
609 DBG_ASSERT( !rMark
.IsMarked() && !rMark
.IsMultiMarked(), "FillRenderMarkData: MarkData must be empty" );
610 DBG_ASSERT( pDocShell
, "FillRenderMarkData: DocShell must be set" );
614 uno::Reference
<uno::XInterface
> xInterface(aSelection
, uno::UNO_QUERY
);
615 if ( xInterface
.is() )
617 ScCellRangesBase
* pSelObj
= ScCellRangesBase::getImplementation( xInterface
);
618 uno::Reference
< drawing::XShapes
> xShapes( xInterface
, uno::UNO_QUERY
);
620 if ( pSelObj
&& pSelObj
->GetDocShell() == pDocShell
)
622 BOOL bSheet
= ( ScTableSheetObj::getImplementation( xInterface
) != NULL
);
623 BOOL bCursor
= pSelObj
->IsCursorOnly();
624 const ScRangeList
& rRanges
= pSelObj
->GetRangeList();
626 rMark
.MarkFromRangeList( rRanges
, FALSE
);
627 rMark
.MarkToSimple();
629 if ( rMark
.IsMarked() && !rMark
.IsMultiMarked() )
631 // a sheet object is treated like an empty selection: print the used area of the sheet
633 if ( bCursor
|| bSheet
) // nothing selected -> use whole tables
635 rMark
.ResetMark(); // doesn't change table selection
636 rStatus
.SetMode( SC_PRINTSEL_CURSOR
);
639 rStatus
.SetMode( SC_PRINTSEL_RANGE
);
641 rStatus
.SetRanges( rRanges
);
644 // multi selection isn't supported
646 else if( xShapes
.is() )
648 //print a selected ole object
649 uno::Reference
< container::XIndexAccess
> xIndexAccess( xShapes
, uno::UNO_QUERY
);
650 if( xIndexAccess
.is() )
652 // multi selection isn't supported yet
653 uno::Reference
< drawing::XShape
> xShape( xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
654 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
657 SdrObject
*pSdrObj
= pShape
->GetSdrObject();
660 ScDocument
* pDoc
= pDocShell
->GetDocument();
661 if( pDoc
&& pSdrObj
)
663 Rectangle aObjRect
= pSdrObj
->GetCurrentBoundRect();
664 SCTAB nCurrentTab
= ScDocShell::GetCurTab();
665 ScRange aRange
= pDoc
->GetRange( nCurrentTab
, aObjRect
);
666 rMark
.SetMarkArea( aRange
);
668 if( rMark
.IsMarked() && !rMark
.IsMultiMarked() )
670 rStatus
.SetMode( SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
);
678 else if ( ScModelObj::getImplementation( xInterface
) == this )
680 // render the whole document
681 // -> no selection, all sheets
683 SCTAB nTabCount
= pDocShell
->GetDocument()->GetTableCount();
684 for (SCTAB nTab
= 0; nTab
< nTabCount
; nTab
++)
685 rMark
.SelectTable( nTab
, TRUE
);
686 rStatus
.SetMode( SC_PRINTSEL_DOCUMENT
);
689 // other selection types aren't supported
696 sal_Int32 SAL_CALL
ScModelObj::getRendererCount( const uno::Any
& aSelection
,
697 const uno::Sequence
<beans::PropertyValue
>& /* xOptions */ )
698 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
702 throw uno::RuntimeException();
705 ScPrintSelectionStatus aStatus
;
706 if ( !FillRenderMarkData( aSelection
, aMark
, aStatus
) )
709 // The same ScPrintFuncCache object in pPrintFuncCache is used as long as
710 // the same selection is used (aStatus) and the document isn't changed
711 // (pPrintFuncCache is cleared in Notify handler)
713 if ( !pPrintFuncCache
|| !pPrintFuncCache
->IsSameSelection( aStatus
) )
715 delete pPrintFuncCache
;
716 pPrintFuncCache
= new ScPrintFuncCache( pDocShell
, aMark
, aStatus
);
718 return pPrintFuncCache
->GetPageCount();
721 uno::Sequence
<beans::PropertyValue
> SAL_CALL
ScModelObj::getRenderer( sal_Int32 nRenderer
,
722 const uno::Any
& aSelection
, const uno::Sequence
<beans::PropertyValue
>& /* xOptions */ )
723 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
727 throw uno::RuntimeException();
730 ScPrintSelectionStatus aStatus
;
731 if ( !FillRenderMarkData( aSelection
, aMark
, aStatus
) )
732 throw lang::IllegalArgumentException();
734 if ( !pPrintFuncCache
|| !pPrintFuncCache
->IsSameSelection( aStatus
) )
736 delete pPrintFuncCache
;
737 pPrintFuncCache
= new ScPrintFuncCache( pDocShell
, aMark
, aStatus
);
739 long nTotalPages
= pPrintFuncCache
->GetPageCount();
740 if ( nRenderer
>= nTotalPages
)
741 throw lang::IllegalArgumentException();
743 // printer is used as device (just for page layout), draw view is not needed
745 SCTAB nTab
= pPrintFuncCache
->GetTabForPage( nRenderer
);
748 const ScRange
* pSelRange
= NULL
;
749 if ( aMark
.IsMarked() )
751 aMark
.GetMarkArea( aRange
);
754 ScPrintFunc
aFunc( pDocShell
, pDocShell
->GetPrinter(), nTab
,
755 pPrintFuncCache
->GetFirstAttr(nTab
), nTotalPages
, pSelRange
);
756 aFunc
.SetRenderFlag( TRUE
);
758 Range
aPageRange( nRenderer
+1, nRenderer
+1 );
759 MultiSelection
aPage( aPageRange
);
760 aPage
.SetTotalRange( Range(0,RANGE_MAX
) );
761 aPage
.Select( aPageRange
);
763 long nDisplayStart
= pPrintFuncCache
->GetDisplayStart( nTab
);
764 long nTabStart
= pPrintFuncCache
->GetTabStart( nTab
);
766 (void)aFunc
.DoPrint( aPage
, nTabStart
, nDisplayStart
, FALSE
, NULL
, NULL
);
769 BOOL bWasCellRange
= aFunc
.GetLastSourceRange( aCellRange
);
770 Size aTwips
= aFunc
.GetPageSize();
771 awt::Size
aPageSize( TwipsToHMM( aTwips
.Width() ), TwipsToHMM( aTwips
.Height() ) );
773 long nPropCount
= bWasCellRange
? 2 : 1;
774 uno::Sequence
<beans::PropertyValue
> aSequence(nPropCount
);
775 beans::PropertyValue
* pArray
= aSequence
.getArray();
776 pArray
[0].Name
= rtl::OUString::createFromAscii( SC_UNONAME_PAGESIZE
);
777 pArray
[0].Value
<<= aPageSize
;
780 table::CellRangeAddress
aRangeAddress( nTab
,
781 aCellRange
.aStart
.Col(), aCellRange
.aStart
.Row(),
782 aCellRange
.aEnd
.Col(), aCellRange
.aEnd
.Row() );
783 pArray
[1].Name
= rtl::OUString::createFromAscii( SC_UNONAME_SOURCERANGE
);
784 pArray
[1].Value
<<= aRangeAddress
;
789 void SAL_CALL
ScModelObj::render( sal_Int32 nRenderer
, const uno::Any
& aSelection
,
790 const uno::Sequence
<beans::PropertyValue
>& rOptions
)
791 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
795 throw uno::RuntimeException();
798 ScPrintSelectionStatus aStatus
;
799 if ( !FillRenderMarkData( aSelection
, aMark
, aStatus
) )
800 throw lang::IllegalArgumentException();
802 if ( !pPrintFuncCache
|| !pPrintFuncCache
->IsSameSelection( aStatus
) )
804 delete pPrintFuncCache
;
805 pPrintFuncCache
= new ScPrintFuncCache( pDocShell
, aMark
, aStatus
);
807 long nTotalPages
= pPrintFuncCache
->GetPageCount();
808 if ( nRenderer
>= nTotalPages
)
809 throw lang::IllegalArgumentException();
811 OutputDevice
* pDev
= lcl_GetRenderDevice( rOptions
);
813 throw lang::IllegalArgumentException();
815 SCTAB nTab
= pPrintFuncCache
->GetTabForPage( nRenderer
);
816 ScDocument
* pDoc
= pDocShell
->GetDocument();
818 FmFormView
* pDrawView
= NULL
;
819 Rectangle
aFull( 0, 0, LONG_MAX
, LONG_MAX
);
822 ScDrawLayer
* pModel
= pDoc
->GetDrawLayer();
826 pDrawView
= new FmFormView( pModel
, pDev
);
827 pDrawView
->ShowSdrPage(pDrawView
->GetModel()->GetPage(nTab
));
828 pDrawView
->SetPrintPreview( TRUE
);
832 const ScRange
* pSelRange
= NULL
;
833 if ( aMark
.IsMarked() )
835 aMark
.GetMarkArea( aRange
);
839 // to increase performance, ScPrintState might be used here for subsequent
840 // pages of the same sheet
842 ScPrintFunc
aFunc( pDev
, pDocShell
, nTab
, pPrintFuncCache
->GetFirstAttr(nTab
), nTotalPages
, pSelRange
);
843 aFunc
.SetDrawView( pDrawView
);
844 aFunc
.SetRenderFlag( TRUE
);
845 if( aStatus
.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
)
846 aFunc
.SetExclusivelyDrawOleAndDrawObjects();
848 Range
aPageRange( nRenderer
+1, nRenderer
+1 );
849 MultiSelection
aPage( aPageRange
);
850 aPage
.SetTotalRange( Range(0,RANGE_MAX
) );
851 aPage
.Select( aPageRange
);
853 long nDisplayStart
= pPrintFuncCache
->GetDisplayStart( nTab
);
854 long nTabStart
= pPrintFuncCache
->GetTabStart( nTab
);
856 if ( nRenderer
== nTabStart
)
858 // first page of a sheet: add outline item for the sheet name
860 vcl::PDFExtOutDevData
* pPDFData
= PTR_CAST( vcl::PDFExtOutDevData
, pDev
->GetExtOutDevData() );
861 if ( pPDFData
&& pPDFData
->GetIsExportBookmarks() )
863 // the sheet starts at the top of the page
864 Rectangle
aArea( pDev
->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
865 sal_Int32 nDestID
= pPDFData
->CreateDest( aArea
);
867 pDoc
->GetName( nTab
, aTabName
);
868 sal_Int32 nParent
= -1; // top-level
869 pPDFData
->CreateOutlineItem( nParent
, aTabName
, nDestID
);
872 // add the named destination stuff
873 if( pPDFData
->GetIsExportNamedDestinations() )
875 Rectangle
aArea( pDev
->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
877 pDoc
->GetName( nTab
, aTabName
);
878 //need the PDF page number here
879 pPDFData
->CreateNamedDest( aTabName
, aArea
);
884 (void)aFunc
.DoPrint( aPage
, nTabStart
, nDisplayStart
, TRUE
, NULL
, NULL
);
886 // resolve the hyperlinks for PDF export
888 vcl::PDFExtOutDevData
* pPDFData
= PTR_CAST( vcl::PDFExtOutDevData
, pDev
->GetExtOutDevData() );
891 // iterate over the hyperlinks that were output for this page
893 std::vector
< vcl::PDFExtOutDevBookmarkEntry
>& rBookmarks
= pPDFData
->GetBookmarks();
894 std::vector
< vcl::PDFExtOutDevBookmarkEntry
>::iterator aIter
= rBookmarks
.begin();
895 std::vector
< vcl::PDFExtOutDevBookmarkEntry
>::iterator aIEnd
= rBookmarks
.end();
896 while ( aIter
!= aIEnd
)
898 rtl::OUString aBookmark
= aIter
->aBookmark
;
899 if ( aBookmark
.toChar() == (sal_Unicode
) '#' )
901 // try to resolve internal link
903 String
aTarget( aBookmark
.copy( 1 ) );
905 ScRange aTargetRange
;
906 Rectangle aTargetRect
; // 1/100th mm
907 bool bIsSheet
= false;
908 bool bValid
= lcl_ParseTarget( aTarget
, aTargetRange
, aTargetRect
, bIsSheet
, pDoc
, nTab
);
912 sal_Int32 nPage
= -1;
916 // Get first page for sheet (if nothing from that sheet is printed,
917 // this page can show a different sheet)
918 nPage
= pPrintFuncCache
->GetTabStart( aTargetRange
.aStart
.Tab() );
919 aArea
= pDev
->PixelToLogic( Rectangle( 0,0,0,0 ) );
923 pPrintFuncCache
->InitLocations( aMark
, pDev
); // does nothing if already initialized
925 ScPrintPageLocation aLocation
;
926 if ( pPrintFuncCache
->FindLocation( aTargetRange
.aStart
, aLocation
) )
928 nPage
= aLocation
.nPage
;
930 // get the rectangle of the page's cell range in 1/100th mm
931 ScRange aLocRange
= aLocation
.aCellRange
;
932 Rectangle aLocationMM
= pDoc
->GetMMRect(
933 aLocRange
.aStart
.Col(), aLocRange
.aStart
.Row(),
934 aLocRange
.aEnd
.Col(), aLocRange
.aEnd
.Row(),
935 aLocRange
.aStart
.Tab() );
936 Rectangle aLocationPixel
= aLocation
.aRectangle
;
938 // Scale and move the target rectangle from aLocationMM to aLocationPixel,
939 // to get the target rectangle in pixels.
941 Fraction
aScaleX( aLocationPixel
.GetWidth(), aLocationMM
.GetWidth() );
942 Fraction
aScaleY( aLocationPixel
.GetHeight(), aLocationMM
.GetHeight() );
944 long nX1
= aLocationPixel
.Left() + (long)
945 ( Fraction( aTargetRect
.Left() - aLocationMM
.Left(), 1 ) * aScaleX
);
946 long nX2
= aLocationPixel
.Left() + (long)
947 ( Fraction( aTargetRect
.Right() - aLocationMM
.Left(), 1 ) * aScaleX
);
948 long nY1
= aLocationPixel
.Top() + (long)
949 ( Fraction( aTargetRect
.Top() - aLocationMM
.Top(), 1 ) * aScaleY
);
950 long nY2
= aLocationPixel
.Top() + (long)
951 ( Fraction( aTargetRect
.Bottom() - aLocationMM
.Top(), 1 ) * aScaleY
);
953 if ( nX1
> aLocationPixel
.Right() ) nX1
= aLocationPixel
.Right();
954 if ( nX2
> aLocationPixel
.Right() ) nX2
= aLocationPixel
.Right();
955 if ( nY1
> aLocationPixel
.Bottom() ) nY1
= aLocationPixel
.Bottom();
956 if ( nY2
> aLocationPixel
.Bottom() ) nY2
= aLocationPixel
.Bottom();
958 // The link target area is interpreted using the device's MapMode at
959 // the time of the CreateDest call, so PixelToLogic can be used here,
960 // regardless of the MapMode that is actually selected.
962 aArea
= pDev
->PixelToLogic( Rectangle( nX1
, nY1
, nX2
, nY2
) );
967 pPDFData
->SetLinkDest( aIter
->nLinkId
, pPDFData
->CreateDest( aArea
, nPage
) );
972 // external link, use as-is
973 pPDFData
->SetLinkURL( aIter
->nLinkId
, aBookmark
);
983 // XLinkTargetSupplier
985 uno::Reference
<container::XNameAccess
> SAL_CALL
ScModelObj::getLinks() throw(uno::RuntimeException
)
989 return new ScLinkTargetTypesObj(pDocShell
);
995 sal_Bool SAL_CALL
ScModelObj::isActionLocked() throw(uno::RuntimeException
)
998 BOOL bLocked
= FALSE
;
1000 bLocked
= ( pDocShell
->GetLockCount() != 0 );
1004 void SAL_CALL
ScModelObj::addActionLock() throw(uno::RuntimeException
)
1008 pDocShell
->LockDocument();
1011 void SAL_CALL
ScModelObj::removeActionLock() throw(uno::RuntimeException
)
1015 pDocShell
->UnlockDocument();
1018 void SAL_CALL
ScModelObj::setActionLocks( sal_Int16 nLock
) throw(uno::RuntimeException
)
1022 pDocShell
->SetLockCount(nLock
);
1025 sal_Int16 SAL_CALL
ScModelObj::resetActionLocks() throw(uno::RuntimeException
)
1031 nRet
= pDocShell
->GetLockCount();
1032 pDocShell
->SetLockCount(0);
1037 void SAL_CALL
ScModelObj::lockControllers() throw (::com::sun::star::uno::RuntimeException
)
1040 SfxBaseModel::lockControllers();
1042 pDocShell
->LockPaint();
1045 void SAL_CALL
ScModelObj::unlockControllers() throw (::com::sun::star::uno::RuntimeException
)
1048 if (hasControllersLocked())
1050 SfxBaseModel::unlockControllers();
1052 pDocShell
->UnlockPaint();
1058 void SAL_CALL
ScModelObj::calculate() throw(uno::RuntimeException
)
1062 pDocShell
->DoRecalc(TRUE
);
1065 DBG_ERROR("keine DocShell"); //! Exception oder so?
1069 void SAL_CALL
ScModelObj::calculateAll() throw(uno::RuntimeException
)
1073 pDocShell
->DoHardRecalc(TRUE
);
1076 DBG_ERROR("keine DocShell"); //! Exception oder so?
1080 sal_Bool SAL_CALL
ScModelObj::isAutomaticCalculationEnabled() throw(uno::RuntimeException
)
1084 return pDocShell
->GetDocument()->GetAutoCalc();
1086 DBG_ERROR("keine DocShell"); //! Exception oder so?
1090 void SAL_CALL
ScModelObj::enableAutomaticCalculation( sal_Bool bEnabled
)
1091 throw(uno::RuntimeException
)
1096 ScDocument
* pDoc
= pDocShell
->GetDocument();
1097 if ( pDoc
->GetAutoCalc() != bEnabled
)
1099 pDoc
->SetAutoCalc( bEnabled
);
1100 pDocShell
->SetDocumentModified();
1105 DBG_ERROR("keine DocShell"); //! Exception oder so?
1111 void SAL_CALL
ScModelObj::protect( const rtl::OUString
& aPassword
) throw(uno::RuntimeException
)
1116 String
aString(aPassword
);
1118 ScDocFunc
aFunc(*pDocShell
);
1119 aFunc
.Protect( TABLEID_DOC
, aString
, TRUE
);
1123 void SAL_CALL
ScModelObj::unprotect( const rtl::OUString
& aPassword
)
1124 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
1129 String
aString(aPassword
);
1131 ScDocFunc
aFunc(*pDocShell
);
1132 aFunc
.Unprotect( TABLEID_DOC
, aString
, TRUE
);
1134 //! Rueckgabewert auswerten, Exception oder so
1138 sal_Bool SAL_CALL
ScModelObj::isProtected() throw(uno::RuntimeException
)
1142 return pDocShell
->GetDocument()->IsDocProtected();
1144 DBG_ERROR("keine DocShell"); //! Exception oder so?
1148 // XDrawPagesSupplier
1150 uno::Reference
<drawing::XDrawPages
> SAL_CALL
ScModelObj::getDrawPages() throw(uno::RuntimeException
)
1154 return new ScDrawPagesObj(pDocShell
);
1156 DBG_ERROR("keine DocShell"); //! Exception oder so?
1163 rtl::OUString
ScModelObj::getPrinterName(void) const
1168 SfxPrinter
* pPrinter
= pDocShell
->GetPrinter();
1170 return pPrinter
->GetName();
1173 DBG_ERROR("getPrinterName: keine DocShell oder kein Printer");
1174 return rtl::OUString();
1177 void ScModelObj::setPrinterName(const rtl::OUString
& PrinterName
)
1180 // Drucker setzen - wie in SfxViewShell::ExecPrint_Impl
1184 SfxPrinter
* pPrinter
= pDocShell
->GetPrinter();
1187 String
aString(PrinterName
);
1188 SfxPrinter
* pNewPrinter
= new SfxPrinter( pPrinter
->GetOptions().Clone(), aString
);
1189 if (pNewPrinter
->IsKnown())
1190 pDocShell
->SetPrinter( pNewPrinter
, SFX_PRINTER_PRINTER
);
1197 XPropertySetRef
ScModelObj::createPrintOptions(void)
1200 return new ScPrintSettingsObj
; //! ScPrintSettingsObj implementieren!
1203 void ScModelObj::print(const XPropertySetRef
& xOptions
)
1208 //! xOptions auswerten (wie denn?)
1217 sheet::GoalResult SAL_CALL
ScModelObj::seekGoal(
1218 const table::CellAddress
& aFormulaPosition
,
1219 const table::CellAddress
& aVariablePosition
,
1220 const ::rtl::OUString
& aGoalValue
)
1221 throw(uno::RuntimeException
)
1224 sheet::GoalResult aResult
;
1225 aResult
.Divergence
= DBL_MAX
; // nichts gefunden
1228 WaitObject
aWait( pDocShell
->GetActiveDialogParent() );
1229 String
aGoalString(aGoalValue
);
1230 ScDocument
* pDoc
= pDocShell
->GetDocument();
1231 double fValue
= 0.0;
1232 BOOL bFound
= pDoc
->Solver(
1233 (SCCOL
)aFormulaPosition
.Column
, (SCROW
)aFormulaPosition
.Row
, aFormulaPosition
.Sheet
,
1234 (SCCOL
)aVariablePosition
.Column
, (SCROW
)aVariablePosition
.Row
, aVariablePosition
.Sheet
,
1235 aGoalString
, fValue
);
1236 aResult
.Result
= fValue
;
1238 aResult
.Divergence
= 0.0; //! das ist gelogen
1245 uno::Reference
<sheet::XConsolidationDescriptor
> SAL_CALL
ScModelObj::createConsolidationDescriptor(
1246 sal_Bool bEmpty
) throw(uno::RuntimeException
)
1249 ScConsolidationDescriptor
* pNew
= new ScConsolidationDescriptor
;
1250 if ( pDocShell
&& !bEmpty
)
1252 ScDocument
* pDoc
= pDocShell
->GetDocument();
1253 const ScConsolidateParam
* pParam
= pDoc
->GetConsolidateDlgData();
1255 pNew
->SetParam( *pParam
);
1260 void SAL_CALL
ScModelObj::consolidate(
1261 const uno::Reference
<sheet::XConsolidationDescriptor
>& xDescriptor
)
1262 throw(uno::RuntimeException
)
1265 // das koennte theoretisch ein fremdes Objekt sein, also nur das
1266 // oeffentliche XConsolidationDescriptor Interface benutzen, um
1267 // die Daten in ein ScConsolidationDescriptor Objekt zu kopieren:
1268 //! wenn es schon ein ScConsolidationDescriptor ist, direkt per getImplementation?
1270 ScConsolidationDescriptor aImpl
;
1271 aImpl
.setFunction( xDescriptor
->getFunction() );
1272 aImpl
.setSources( xDescriptor
->getSources() );
1273 aImpl
.setStartOutputPosition( xDescriptor
->getStartOutputPosition() );
1274 aImpl
.setUseColumnHeaders( xDescriptor
->getUseColumnHeaders() );
1275 aImpl
.setUseRowHeaders( xDescriptor
->getUseRowHeaders() );
1276 aImpl
.setInsertLinks( xDescriptor
->getInsertLinks() );
1280 const ScConsolidateParam
& rParam
= aImpl
.GetParam();
1281 pDocShell
->DoConsolidate( rParam
, TRUE
);
1282 pDocShell
->GetDocument()->SetConsolidateDlgData( &rParam
);
1286 // XDocumentAuditing
1288 void SAL_CALL
ScModelObj::refreshArrows() throw(uno::RuntimeException
)
1293 ScDocFunc
aFunc(*pDocShell
);
1294 aFunc
.DetectiveRefresh();
1298 // XViewDataSupplier
1299 uno::Reference
< container::XIndexAccess
> SAL_CALL
ScModelObj::getViewData( )
1300 throw (uno::RuntimeException
)
1302 uno::Reference
< container::XIndexAccess
> xRet( SfxBaseModel::getViewData() );
1307 if (pDocShell
&& pDocShell
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
1309 xRet
.set(uno::Reference
< container::XIndexAccess
>::query(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")))));
1311 uno::Reference
< container::XIndexContainer
> xCont( xRet
, uno::UNO_QUERY
);
1312 DBG_ASSERT( xCont
.is(), "ScModelObj::getViewData() failed for OLE object" );
1315 uno::Sequence
< beans::PropertyValue
> aSeq
;
1318 pDocShell
->GetDocument()->GetName( pDocShell
->GetDocument()->GetVisibleTab(), sName
);
1319 rtl::OUString
sOUName(sName
);
1320 aSeq
[0].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE
));
1321 aSeq
[0].Value
<<= sOUName
;
1322 xCont
->insertByIndex( 0, uno::makeAny( aSeq
) );
1330 // XPropertySet (Doc-Optionen)
1331 //! auch an der Applikation anbieten?
1333 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScModelObj::getPropertySetInfo()
1334 throw(uno::RuntimeException
)
1337 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1338 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
1342 void SAL_CALL
ScModelObj::setPropertyValue(
1343 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
1344 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1345 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1346 uno::RuntimeException
)
1349 String
aString(aPropertyName
);
1353 ScDocument
* pDoc
= pDocShell
->GetDocument();
1354 const ScDocOptions
& rOldOpt
= pDoc
->GetDocOptions();
1355 ScDocOptions aNewOpt
= rOldOpt
;
1357 BOOL bOpt
= ScDocOptionsHelper::setPropertyValue( aNewOpt
, *aPropSet
.getPropertyMap(), aPropertyName
, aValue
);
1362 else if ( aString
.EqualsAscii( SC_UNONAME_CLOCAL
) )
1364 lang::Locale aLocale
;
1365 if ( aValue
>>= aLocale
)
1367 LanguageType eLatin
, eCjk
, eCtl
;
1368 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1369 eLatin
= ScUnoConversion::GetLanguage(aLocale
);
1370 pDoc
->SetLanguage( eLatin
, eCjk
, eCtl
);
1373 else if ( aString
.EqualsAscii( SC_UNO_CJK_CLOCAL
) )
1375 lang::Locale aLocale
;
1376 if ( aValue
>>= aLocale
)
1378 LanguageType eLatin
, eCjk
, eCtl
;
1379 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1380 eCjk
= ScUnoConversion::GetLanguage(aLocale
);
1381 pDoc
->SetLanguage( eLatin
, eCjk
, eCtl
);
1384 else if ( aString
.EqualsAscii( SC_UNO_CTL_CLOCAL
) )
1386 lang::Locale aLocale
;
1387 if ( aValue
>>= aLocale
)
1389 LanguageType eLatin
, eCjk
, eCtl
;
1390 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1391 eCtl
= ScUnoConversion::GetLanguage(aLocale
);
1392 pDoc
->SetLanguage( eLatin
, eCjk
, eCtl
);
1395 else if ( aString
.EqualsAscii( SC_UNO_APPLYFMDES
) )
1397 // model is created if not there
1398 ScDrawLayer
* pModel
= pDocShell
->MakeDrawLayer();
1399 pModel
->SetOpenInDesignMode( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1401 SfxBindings
* pBindings
= pDocShell
->GetViewBindings();
1403 pBindings
->Invalidate( SID_FM_OPEN_READONLY
);
1405 else if ( aString
.EqualsAscii( SC_UNO_AUTOCONTFOC
) )
1407 // model is created if not there
1408 ScDrawLayer
* pModel
= pDocShell
->MakeDrawLayer();
1409 pModel
->SetAutoControlFocus( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1411 SfxBindings
* pBindings
= pDocShell
->GetViewBindings();
1413 pBindings
->Invalidate( SID_FM_AUTOCONTROLFOCUS
);
1415 else if ( aString
.EqualsAscii( SC_UNO_ISLOADED
) )
1417 pDocShell
->SetEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1419 else if ( aString
.EqualsAscii( SC_UNO_ISUNDOENABLED
) )
1421 BOOL bUndoEnabled
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1422 pDoc
->EnableUndo( bUndoEnabled
);
1423 USHORT nCount
= ( bUndoEnabled
?
1424 static_cast< USHORT
>( SvtUndoOptions().GetUndoCount() ) : 0 );
1425 pDocShell
->GetUndoManager()->SetMaxUndoActionCount( nCount
);
1427 else if ( aString
.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED
) )
1429 bool bOldAdjustHeightEnabled
= pDoc
->IsAdjustHeightEnabled();
1430 bool bAdjustHeightEnabled
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
1431 if( bOldAdjustHeightEnabled
!= bAdjustHeightEnabled
)
1433 pDoc
->EnableAdjustHeight( bAdjustHeightEnabled
);
1434 if( bAdjustHeightEnabled
)
1435 pDocShell
->UpdateAllRowHeights();
1438 else if ( aString
.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED
) )
1440 pDoc
->EnableExecuteLink( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1442 else if ( aString
.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED
) )
1444 pDoc
->EnableChangeReadOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1446 else if ( aString
.EqualsAscii( "BuildId" ) )
1448 aValue
>>= maBuildId
;
1450 else if ( aString
.EqualsAscii( "SavedObject" ) ) // set from chart after saving
1452 rtl::OUString aObjName
;
1453 aValue
>>= aObjName
;
1454 if ( aObjName
.getLength() )
1455 pDoc
->RestoreChartListener( aObjName
);
1458 if ( aNewOpt
!= rOldOpt
)
1460 pDoc
->SetDocOptions( aNewOpt
);
1461 // Don't recalculate while loading XML, when the formula text is stored.
1462 // Recalculation after loading is handled separately.
1463 //! Recalc only for options that need it?
1464 if ( !pDoc
->IsImportingXML() )
1465 pDocShell
->DoHardRecalc( TRUE
);
1466 pDocShell
->SetDocumentModified();
1471 uno::Any SAL_CALL
ScModelObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
1472 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1473 uno::RuntimeException
)
1476 String
aString(aPropertyName
);
1481 ScDocument
* pDoc
= pDocShell
->GetDocument();
1482 const ScDocOptions
& rOpt
= pDoc
->GetDocOptions();
1483 aRet
= ScDocOptionsHelper::getPropertyValue( rOpt
, *aPropSet
.getPropertyMap(), aPropertyName
);
1484 if ( aRet
.hasValue() )
1488 else if ( aString
.EqualsAscii( SC_UNONAME_CLOCAL
) )
1490 LanguageType eLatin
, eCjk
, eCtl
;
1491 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1493 lang::Locale aLocale
;
1494 ScUnoConversion::FillLocale( aLocale
, eLatin
);
1497 else if ( aString
.EqualsAscii( SC_UNO_CJK_CLOCAL
) )
1499 LanguageType eLatin
, eCjk
, eCtl
;
1500 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1502 lang::Locale aLocale
;
1503 ScUnoConversion::FillLocale( aLocale
, eCjk
);
1506 else if ( aString
.EqualsAscii( SC_UNO_CTL_CLOCAL
) )
1508 LanguageType eLatin
, eCjk
, eCtl
;
1509 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
1511 lang::Locale aLocale
;
1512 ScUnoConversion::FillLocale( aLocale
, eCtl
);
1515 else if ( aString
.EqualsAscii( SC_UNO_NAMEDRANGES
) )
1517 aRet
<<= uno::Reference
<sheet::XNamedRanges
>(new ScNamedRangesObj( pDocShell
));
1519 else if ( aString
.EqualsAscii( SC_UNO_DATABASERNG
) )
1521 aRet
<<= uno::Reference
<sheet::XDatabaseRanges
>(new ScDatabaseRangesObj( pDocShell
));
1523 else if ( aString
.EqualsAscii( SC_UNO_COLLABELRNG
) )
1525 aRet
<<= uno::Reference
<sheet::XLabelRanges
>(new ScLabelRangesObj( pDocShell
, TRUE
));
1527 else if ( aString
.EqualsAscii( SC_UNO_ROWLABELRNG
) )
1529 aRet
<<= uno::Reference
<sheet::XLabelRanges
>(new ScLabelRangesObj( pDocShell
, FALSE
));
1531 else if ( aString
.EqualsAscii( SC_UNO_AREALINKS
) )
1533 aRet
<<= uno::Reference
<sheet::XAreaLinks
>(new ScAreaLinksObj( pDocShell
));
1535 else if ( aString
.EqualsAscii( SC_UNO_DDELINKS
) )
1537 aRet
<<= uno::Reference
<container::XNameAccess
>(new ScDDELinksObj( pDocShell
));
1539 else if ( aString
.EqualsAscii( SC_UNO_EXTERNALDOCLINKS
) )
1541 aRet
<<= uno::Reference
<sheet::XExternalDocLinks
>(new ScExternalDocLinksObj(pDocShell
));
1543 else if ( aString
.EqualsAscii( SC_UNO_SHEETLINKS
) )
1545 aRet
<<= uno::Reference
<container::XNameAccess
>(new ScSheetLinksObj( pDocShell
));
1547 else if ( aString
.EqualsAscii( SC_UNO_APPLYFMDES
) )
1549 // default for no model is TRUE
1550 ScDrawLayer
* pModel
= pDoc
->GetDrawLayer();
1551 sal_Bool bOpenInDesign
= pModel
? pModel
->GetOpenInDesignMode() : sal_True
;
1552 ScUnoHelpFunctions::SetBoolInAny( aRet
, bOpenInDesign
);
1554 else if ( aString
.EqualsAscii( SC_UNO_AUTOCONTFOC
) )
1556 // default for no model is FALSE
1557 ScDrawLayer
* pModel
= pDoc
->GetDrawLayer();
1558 sal_Bool bAutoControlFocus
= pModel
? pModel
->GetAutoControlFocus() : sal_False
;
1559 ScUnoHelpFunctions::SetBoolInAny( aRet
, bAutoControlFocus
);
1561 else if ( aString
.EqualsAscii( SC_UNO_FORBIDDEN
) )
1563 aRet
<<= uno::Reference
<i18n::XForbiddenCharacters
>(new ScForbiddenCharsObj( pDocShell
));
1565 else if ( aString
.EqualsAscii( SC_UNO_HASDRAWPAGES
) )
1567 ScUnoHelpFunctions::SetBoolInAny( aRet
, (pDocShell
->GetDocument()->GetDrawLayer() != 0) );
1569 else if ( aString
.EqualsAscii( SC_UNO_BASICLIBRARIES
) )
1571 aRet
<<= pDocShell
->GetBasicContainer();
1573 else if ( aString
.EqualsAscii( SC_UNO_DIALOGLIBRARIES
) )
1575 aRet
<<= pDocShell
->GetDialogContainer();
1577 else if ( aString
.EqualsAscii( SC_UNO_VBADOCOBJ
) )
1579 beans::PropertyValue aProp
;
1580 aProp
.Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") );
1581 aProp
.Value
<<= pDocShell
->GetModel();
1584 else if ( aString
.EqualsAscii( SC_UNO_RUNTIMEUID
) )
1586 aRet
<<= getRuntimeUID();
1588 else if ( aString
.EqualsAscii( SC_UNO_HASVALIDSIGNATURES
) )
1590 aRet
<<= hasValidSignatures();
1592 else if ( aString
.EqualsAscii( SC_UNO_ISLOADED
) )
1594 ScUnoHelpFunctions::SetBoolInAny( aRet
, !pDocShell
->IsEmpty() );
1596 else if ( aString
.EqualsAscii( SC_UNO_ISUNDOENABLED
) )
1598 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsUndoEnabled() );
1600 else if ( aString
.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED
) )
1602 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsAdjustHeightEnabled() );
1604 else if ( aString
.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED
) )
1606 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsExecuteLinkEnabled() );
1608 else if ( aString
.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED
) )
1610 ScUnoHelpFunctions::SetBoolInAny( aRet
, pDoc
->IsChangeReadOnlyEnabled() );
1612 else if ( aString
.EqualsAscii( SC_UNO_REFERENCEDEVICE
) )
1614 VCLXDevice
* pXDev
= new VCLXDevice();
1615 pXDev
->SetOutputDevice( pDoc
->GetRefDevice() );
1616 aRet
<<= uno::Reference
< awt::XDevice
>( pXDev
);
1618 else if (aString
.EqualsAscii(SC_UNO_ALWAYS_ALLOW_SAVE
))
1619 ScUnoHelpFunctions::SetBoolInAny(aRet
, pDocShell
->GetApplicationFlag(SFX_APPFLAG_ALWAYS_ALLOW_SAVE
));
1620 else if ( aString
.EqualsAscii( "BuildId" ) )
1624 else if ( aString
.EqualsAscii( "InternalDocument" ) )
1626 ScUnoHelpFunctions::SetBoolInAny( aRet
, (pDocShell
->GetCreateMode() == SFX_CREATE_MODE_INTERNAL
) );
1633 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScModelObj
)
1635 // XMultiServiceFactory
1637 uno::Reference
<uno::XInterface
> SAL_CALL
ScModelObj::createInstance(
1638 const rtl::OUString
& aServiceSpecifier
)
1639 throw(uno::Exception
, uno::RuntimeException
)
1642 uno::Reference
<uno::XInterface
> xRet
;
1643 String
aNameStr(aServiceSpecifier
);
1644 USHORT nType
= ScServiceProvider::GetProviderType(aNameStr
);
1645 if ( nType
!= SC_SERVICE_INVALID
)
1647 // drawing layer tables must be kept as long as the model is alive
1648 // return stored instance if already set
1651 case SC_SERVICE_GRADTAB
: xRet
.set(xDrawGradTab
); break;
1652 case SC_SERVICE_HATCHTAB
: xRet
.set(xDrawHatchTab
); break;
1653 case SC_SERVICE_BITMAPTAB
: xRet
.set(xDrawBitmapTab
); break;
1654 case SC_SERVICE_TRGRADTAB
: xRet
.set(xDrawTrGradTab
); break;
1655 case SC_SERVICE_MARKERTAB
: xRet
.set(xDrawMarkerTab
); break;
1656 case SC_SERVICE_DASHTAB
: xRet
.set(xDrawDashTab
); break;
1657 case SC_SERVICE_CHDATAPROV
: xRet
.set(xChartDataProv
); break;
1660 // #i64497# If a chart is in a temporary document during clipoard paste,
1661 // there should be no data provider, so that own data is used
1663 ! ( nType
== SC_SERVICE_CHDATAPROV
&&
1664 ( pDocShell
->GetCreateMode() == SFX_CREATE_MODE_INTERNAL
));
1665 // this should never happen, i.e. the temporary document should never be
1666 // loaded, becuase this unlinks the data
1667 OSL_ASSERT( bCreate
);
1669 if ( !xRet
.is() && bCreate
)
1671 xRet
.set(ScServiceProvider::MakeInstance( nType
, pDocShell
));
1673 // store created instance
1676 case SC_SERVICE_GRADTAB
: xDrawGradTab
.set(xRet
); break;
1677 case SC_SERVICE_HATCHTAB
: xDrawHatchTab
.set(xRet
); break;
1678 case SC_SERVICE_BITMAPTAB
: xDrawBitmapTab
.set(xRet
); break;
1679 case SC_SERVICE_TRGRADTAB
: xDrawTrGradTab
.set(xRet
); break;
1680 case SC_SERVICE_MARKERTAB
: xDrawMarkerTab
.set(xRet
); break;
1681 case SC_SERVICE_DASHTAB
: xDrawDashTab
.set(xRet
); break;
1682 case SC_SERVICE_CHDATAPROV
: xChartDataProv
.set(xRet
); break;
1688 // alles was ich nicht kenn, werf ich der SvxFmMSFactory an den Hals,
1689 // da wird dann 'ne Exception geworfen, wenn's nicht passt...
1693 xRet
.set(SvxFmMSFactory::createInstance(aServiceSpecifier
));
1694 // extra block to force deletion of the temporary before ScShapeObj ctor (setDelegator)
1696 catch ( lang::ServiceNotRegisteredException
& )
1700 // #96117# if the drawing factory created a shape, a ScShapeObj has to be used
1701 // to support own properties like ImageMap:
1703 uno::Reference
<drawing::XShape
> xShape( xRet
, uno::UNO_QUERY
);
1706 xRet
.clear(); // for aggregation, xShape must be the object's only ref
1707 new ScShapeObj( xShape
); // aggregates object and modifies xShape
1714 uno::Reference
<uno::XInterface
> SAL_CALL
ScModelObj::createInstanceWithArguments(
1715 const rtl::OUString
& ServiceSpecifier
,
1716 const uno::Sequence
<uno::Any
>& aArgs
)
1717 throw(uno::Exception
, uno::RuntimeException
)
1719 //! unterscheiden zwischen eigenen Services und denen vom Drawing-Layer?
1722 uno::Reference
<uno::XInterface
> xInt(createInstance(ServiceSpecifier
));
1724 if ( aArgs
.getLength() )
1726 // used only for cell value binding so far - it can be initialized after creating
1728 uno::Reference
<lang::XInitialization
> xInit( xInt
, uno::UNO_QUERY
);
1730 xInit
->initialize( aArgs
);
1736 uno::Sequence
<rtl::OUString
> SAL_CALL
ScModelObj::getAvailableServiceNames()
1737 throw(uno::RuntimeException
)
1741 //! warum sind die Parameter bei concatServiceNames nicht const ???
1742 //! return concatServiceNames( ScServiceProvider::GetAllServiceNames(),
1743 //! SvxFmMSFactory::getAvailableServiceNames() );
1745 uno::Sequence
<rtl::OUString
> aMyServices(ScServiceProvider::GetAllServiceNames());
1746 uno::Sequence
<rtl::OUString
> aDrawServices(SvxFmMSFactory::getAvailableServiceNames());
1748 return concatServiceNames( aMyServices
, aDrawServices
);
1754 ScModelObj::processCompatibleEvent( sal_Int16 nSlotId
) throw( ::com::sun::star::uno::RuntimeException
)
1756 USHORT nId
= (USHORT
)nSlotId
;
1757 uno::Reference
< document::XVbaEventsHelper
> xVbaEventsHelper( GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY
);
1758 if( xVbaEventsHelper
.is() )
1764 uno::Sequence
< uno::Any
> aArgs(1);
1765 aArgs
[0] <<= sal_False
;
1766 return xVbaEventsHelper
->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE
, aArgs
);
1770 uno::Sequence
< uno::Any
> aArgs(1);
1771 aArgs
[0] <<= sal_True
;
1772 return xVbaEventsHelper
->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFORESAVE
, aArgs
);
1775 case SID_PRINTDOCDIRECT
:
1777 uno::Sequence
< uno::Any
> aArgs
;
1778 return xVbaEventsHelper
->ProcessCompatibleVbaEvent( VBAEVENT_WORKBOOK_BEFOREPRINT
, aArgs
);
1786 rtl::OUString SAL_CALL
ScModelObj::getImplementationName() throw(uno::RuntimeException
)
1788 return rtl::OUString::createFromAscii( "ScModelObj" );
1791 sal_Bool SAL_CALL
ScModelObj::supportsService( const rtl::OUString
& rServiceName
)
1792 throw(uno::RuntimeException
)
1794 String
aServiceStr(rServiceName
);
1795 return aServiceStr
.EqualsAscii( SCMODELOBJ_SERVICE
) ||
1796 aServiceStr
.EqualsAscii( SCDOCSETTINGS_SERVICE
) ||
1797 aServiceStr
.EqualsAscii( SCDOC_SERVICE
);
1800 uno::Sequence
<rtl::OUString
> SAL_CALL
ScModelObj::getSupportedServiceNames()
1801 throw(uno::RuntimeException
)
1803 uno::Sequence
<rtl::OUString
> aRet(2);
1804 rtl::OUString
* pArray
= aRet
.getArray();
1805 pArray
[0] = rtl::OUString::createFromAscii( SCMODELOBJ_SERVICE
);
1806 pArray
[1] = rtl::OUString::createFromAscii( SCDOCSETTINGS_SERVICE
);
1812 sal_Int64 SAL_CALL
ScModelObj::getSomething(
1813 const uno::Sequence
<sal_Int8
>& rId
) throw(uno::RuntimeException
)
1815 if ( rId
.getLength() == 16 &&
1816 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1817 rId
.getConstArray(), 16 ) )
1819 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
1822 if ( rId
.getLength() == 16 &&
1823 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(),
1824 rId
.getConstArray(), 16 ) )
1826 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(pDocShell
));
1828 // aggregated number formats supplier has XUnoTunnel, too
1829 // interface from aggregated object must be obtained via queryAggregation
1831 sal_Int64 nRet
= SfxBaseModel::getSomething( rId
);
1835 if ( GetFormatter().is() )
1837 const uno::Type
& rTunnelType
= ::getCppuType((uno::Reference
<lang::XUnoTunnel
>*) 0);
1838 uno::Any
aNumTunnel(xNumberAgg
->queryAggregation(rTunnelType
));
1839 if(aNumTunnel
.getValueType() == rTunnelType
)
1841 uno::Reference
<lang::XUnoTunnel
> xTunnelAgg(
1842 *(uno::Reference
<lang::XUnoTunnel
>*)aNumTunnel
.getValue());
1843 return xTunnelAgg
->getSomething( rId
);
1851 const uno::Sequence
<sal_Int8
>& ScModelObj::getUnoTunnelId()
1853 static uno::Sequence
<sal_Int8
> * pSeq
= 0;
1856 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
1859 static uno::Sequence
< sal_Int8
> aSeq( 16 );
1860 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
1868 ScModelObj
* ScModelObj::getImplementation( const uno::Reference
<uno::XInterface
> xObj
)
1870 ScModelObj
* pRet
= NULL
;
1871 uno::Reference
<lang::XUnoTunnel
> xUT( xObj
, uno::UNO_QUERY
);
1873 pRet
= reinterpret_cast<ScModelObj
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething(getUnoTunnelId())));
1879 void ScModelObj::addChangesListener( const uno::Reference
< util::XChangesListener
>& aListener
)
1880 throw (uno::RuntimeException
)
1883 maChangesListeners
.addInterface( aListener
);
1886 void ScModelObj::removeChangesListener( const uno::Reference
< util::XChangesListener
>& aListener
)
1887 throw (uno::RuntimeException
)
1890 maChangesListeners
.removeInterface( aListener
);
1893 bool ScModelObj::HasChangesListeners() const
1895 return ( maChangesListeners
.getLength() > 0 );
1898 void ScModelObj::NotifyChanges( const ::rtl::OUString
& rOperation
, const ScRangeList
& rRanges
,
1899 const uno::Sequence
< beans::PropertyValue
>& rProperties
)
1901 if ( pDocShell
&& HasChangesListeners() )
1903 util::ChangesEvent aEvent
;
1904 aEvent
.Source
.set( static_cast< cppu::OWeakObject
* >( this ) );
1905 aEvent
.Base
<<= aEvent
.Source
;
1907 ULONG nRangeCount
= rRanges
.Count();
1908 aEvent
.Changes
.realloc( static_cast< sal_Int32
>( nRangeCount
) );
1909 for ( ULONG nIndex
= 0; nIndex
< nRangeCount
; ++nIndex
)
1911 uno::Reference
< table::XCellRange
> xRangeObj
;
1913 ScRange
aRange( *rRanges
.GetObject( nIndex
) );
1914 if ( aRange
.aStart
== aRange
.aEnd
)
1916 xRangeObj
.set( new ScCellObj( pDocShell
, aRange
.aStart
) );
1920 xRangeObj
.set( new ScCellRangeObj( pDocShell
, aRange
) );
1923 util::ElementChange
& rChange
= aEvent
.Changes
[ static_cast< sal_Int32
>( nIndex
) ];
1924 rChange
.Accessor
<<= rOperation
;
1925 rChange
.Element
<<= rProperties
;
1926 rChange
.ReplacedElement
<<= xRangeObj
;
1929 ::cppu::OInterfaceIteratorHelper
aIter( maChangesListeners
);
1930 while ( aIter
.hasMoreElements() )
1934 static_cast< util::XChangesListener
* >( aIter
.next() )->changesOccurred( aEvent
);
1936 catch( uno::Exception
& )
1943 //------------------------------------------------------------------------
1945 ScDrawPagesObj::ScDrawPagesObj(ScDocShell
* pDocSh
) :
1948 pDocShell
->GetDocument()->AddUnoObject(*this);
1951 ScDrawPagesObj::~ScDrawPagesObj()
1954 pDocShell
->GetDocument()->RemoveUnoObject(*this);
1957 void ScDrawPagesObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1959 // Referenz-Update interessiert hier nicht
1961 if ( rHint
.ISA( SfxSimpleHint
) &&
1962 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
1964 pDocShell
= NULL
; // ungueltig geworden
1968 uno::Reference
<drawing::XDrawPage
> ScDrawPagesObj::GetObjectByIndex_Impl(INT32 nIndex
) const
1972 ScDrawLayer
* pDrawLayer
= pDocShell
->MakeDrawLayer();
1973 DBG_ASSERT(pDrawLayer
,"kann Draw-Layer nicht anlegen");
1974 if ( pDrawLayer
&& nIndex
>= 0 && nIndex
< pDocShell
->GetDocument()->GetTableCount() )
1976 SdrPage
* pPage
= pDrawLayer
->GetPage((USHORT
)nIndex
);
1977 DBG_ASSERT(pPage
,"Draw-Page nicht gefunden");
1980 return uno::Reference
<drawing::XDrawPage
> (pPage
->getUnoPage(), uno::UNO_QUERY
);
1989 uno::Reference
<drawing::XDrawPage
> SAL_CALL
ScDrawPagesObj::insertNewByIndex( sal_Int32 nPos
)
1990 throw(uno::RuntimeException
)
1993 uno::Reference
<drawing::XDrawPage
> xRet
;
1997 pDocShell
->GetDocument()->CreateValidTabName(aNewName
);
1998 ScDocFunc
aFunc(*pDocShell
);
1999 if ( aFunc
.InsertTable( (SCTAB
)nPos
, aNewName
, TRUE
, TRUE
) )
2000 xRet
.set(GetObjectByIndex_Impl( nPos
));
2005 void SAL_CALL
ScDrawPagesObj::remove( const uno::Reference
<drawing::XDrawPage
>& xPage
)
2006 throw(uno::RuntimeException
)
2009 SvxDrawPage
* pImp
= SvxDrawPage::getImplementation( xPage
);
2010 if ( pDocShell
&& pImp
)
2012 SdrPage
* pPage
= pImp
->GetSdrPage();
2015 SCTAB nPageNum
= static_cast<SCTAB
>(pPage
->GetPageNum());
2016 ScDocFunc
aFunc(*pDocShell
);
2017 aFunc
.DeleteTable( nPageNum
, TRUE
, TRUE
);
2024 sal_Int32 SAL_CALL
ScDrawPagesObj::getCount() throw(uno::RuntimeException
)
2028 return pDocShell
->GetDocument()->GetTableCount();
2032 uno::Any SAL_CALL
ScDrawPagesObj::getByIndex( sal_Int32 nIndex
)
2033 throw(lang::IndexOutOfBoundsException
,
2034 lang::WrappedTargetException
, uno::RuntimeException
)
2037 uno::Reference
<drawing::XDrawPage
> xPage(GetObjectByIndex_Impl(nIndex
));
2039 return uno::makeAny(xPage
);
2041 throw lang::IndexOutOfBoundsException();
2042 // return uno::Any();
2045 uno::Type SAL_CALL
ScDrawPagesObj::getElementType() throw(uno::RuntimeException
)
2048 return getCppuType((uno::Reference
<drawing::XDrawPage
>*)0);
2051 sal_Bool SAL_CALL
ScDrawPagesObj::hasElements() throw(uno::RuntimeException
)
2054 return ( getCount() != 0 );
2057 //------------------------------------------------------------------------
2059 ScTableSheetsObj::ScTableSheetsObj(ScDocShell
* pDocSh
) :
2062 pDocShell
->GetDocument()->AddUnoObject(*this);
2065 ScTableSheetsObj::~ScTableSheetsObj()
2068 pDocShell
->GetDocument()->RemoveUnoObject(*this);
2071 void ScTableSheetsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
2073 // Referenz-Update interessiert hier nicht
2075 if ( rHint
.ISA( SfxSimpleHint
) &&
2076 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
2078 pDocShell
= NULL
; // ungueltig geworden
2084 ScTableSheetObj
* ScTableSheetsObj::GetObjectByIndex_Impl(sal_Int32 nIndex
) const
2086 if ( pDocShell
&& nIndex
>= 0 && nIndex
< pDocShell
->GetDocument()->GetTableCount() )
2087 return new ScTableSheetObj( pDocShell
, static_cast<SCTAB
>(nIndex
) );
2092 ScTableSheetObj
* ScTableSheetsObj::GetObjectByName_Impl(const rtl::OUString
& aName
) const
2097 String
aString(aName
);
2098 if ( pDocShell
->GetDocument()->GetTable( aString
, nIndex
) )
2099 return new ScTableSheetObj( pDocShell
, nIndex
);
2104 void SAL_CALL
ScTableSheetsObj::insertNewByName( const rtl::OUString
& aName
, sal_Int16 nPosition
)
2105 throw(uno::RuntimeException
)
2111 String
aNamStr(aName
);
2112 ScDocFunc
aFunc(*pDocShell
);
2113 bDone
= aFunc
.InsertTable( nPosition
, aNamStr
, TRUE
, TRUE
);
2116 throw uno::RuntimeException(); // no other exceptions specified
2119 void SAL_CALL
ScTableSheetsObj::moveByName( const rtl::OUString
& aName
, sal_Int16 nDestination
)
2120 throw(uno::RuntimeException
)
2126 String
aNamStr(aName
);
2128 if ( pDocShell
->GetDocument()->GetTable( aNamStr
, nSource
) )
2129 bDone
= pDocShell
->MoveTable( nSource
, nDestination
, FALSE
, TRUE
);
2132 throw uno::RuntimeException(); // no other exceptions specified
2135 void SAL_CALL
ScTableSheetsObj::copyByName( const rtl::OUString
& aName
,
2136 const rtl::OUString
& aCopy
, sal_Int16 nDestination
)
2137 throw(uno::RuntimeException
)
2143 String
aNamStr(aName
);
2144 String
aNewStr(aCopy
);
2146 if ( pDocShell
->GetDocument()->GetTable( aNamStr
, nSource
) )
2148 bDone
= pDocShell
->MoveTable( nSource
, nDestination
, TRUE
, TRUE
);
2151 // #i92477# any index past the last sheet means "append" in MoveTable
2152 SCTAB nResultTab
= static_cast<SCTAB
>(nDestination
);
2153 SCTAB nTabCount
= pDocShell
->GetDocument()->GetTableCount(); // count after copying
2154 if (nResultTab
>= nTabCount
)
2155 nResultTab
= nTabCount
- 1;
2157 ScDocFunc
aFunc(*pDocShell
);
2158 bDone
= aFunc
.RenameTable( nResultTab
, aNewStr
, TRUE
, TRUE
);
2163 throw uno::RuntimeException(); // no other exceptions specified
2166 void SAL_CALL
ScTableSheetsObj::insertByName( const rtl::OUString
& aName
, const uno::Any
& aElement
)
2167 throw(lang::IllegalArgumentException
, container::ElementExistException
,
2168 lang::WrappedTargetException
, uno::RuntimeException
)
2172 BOOL bIllArg
= FALSE
;
2174 //! Type of aElement can be some specific interface instead of XInterface
2178 uno::Reference
<uno::XInterface
> xInterface(aElement
, uno::UNO_QUERY
);
2179 if ( xInterface
.is() )
2181 ScTableSheetObj
* pSheetObj
= ScTableSheetObj::getImplementation( xInterface
);
2182 if ( pSheetObj
&& !pSheetObj
->GetDocShell() ) // noch nicht eingefuegt?
2184 ScDocument
* pDoc
= pDocShell
->GetDocument();
2185 String
aNamStr(aName
);
2187 if ( pDoc
->GetTable( aNamStr
, nDummy
) )
2189 // name already exists
2190 throw container::ElementExistException();
2194 SCTAB nPosition
= pDoc
->GetTableCount();
2195 ScDocFunc
aFunc(*pDocShell
);
2196 bDone
= aFunc
.InsertTable( nPosition
, aNamStr
, TRUE
, TRUE
);
2198 pSheetObj
->InitInsertSheet( pDocShell
, nPosition
);
2199 // Dokument und neuen Range am Objekt setzen
2212 throw lang::IllegalArgumentException();
2214 throw uno::RuntimeException(); // ElementExistException is handled above
2218 void SAL_CALL
ScTableSheetsObj::replaceByName( const rtl::OUString
& aName
, const uno::Any
& aElement
)
2219 throw(lang::IllegalArgumentException
, container::NoSuchElementException
,
2220 lang::WrappedTargetException
, uno::RuntimeException
)
2224 BOOL bIllArg
= FALSE
;
2226 //! Type of aElement can be some specific interface instead of XInterface
2230 uno::Reference
<uno::XInterface
> xInterface(aElement
, uno::UNO_QUERY
);
2231 if ( xInterface
.is() )
2233 ScTableSheetObj
* pSheetObj
= ScTableSheetObj::getImplementation( xInterface
);
2234 if ( pSheetObj
&& !pSheetObj
->GetDocShell() ) // noch nicht eingefuegt?
2236 String
aNamStr(aName
);
2238 if ( pDocShell
->GetDocument()->GetTable( aNamStr
, nPosition
) )
2240 ScDocFunc
aFunc(*pDocShell
);
2241 if ( aFunc
.DeleteTable( nPosition
, TRUE
, TRUE
) )
2243 // InsertTable kann jetzt eigentlich nicht schiefgehen...
2244 bDone
= aFunc
.InsertTable( nPosition
, aNamStr
, TRUE
, TRUE
);
2246 pSheetObj
->InitInsertSheet( pDocShell
, nPosition
);
2252 throw container::NoSuchElementException();
2265 throw lang::IllegalArgumentException();
2267 throw uno::RuntimeException(); // NoSuchElementException is handled above
2271 void SAL_CALL
ScTableSheetsObj::removeByName( const rtl::OUString
& aName
)
2272 throw(container::NoSuchElementException
,
2273 lang::WrappedTargetException
, uno::RuntimeException
)
2280 String
aString(aName
);
2281 if ( pDocShell
->GetDocument()->GetTable( aString
, nIndex
) )
2283 ScDocFunc
aFunc(*pDocShell
);
2284 bDone
= aFunc
.DeleteTable( nIndex
, TRUE
, TRUE
);
2289 throw container::NoSuchElementException();
2294 throw uno::RuntimeException(); // NoSuchElementException is handled above
2297 // XCellRangesAccess
2299 uno::Reference
< table::XCell
> SAL_CALL
ScTableSheetsObj::getCellByPosition( sal_Int32 nColumn
, sal_Int32 nRow
, sal_Int32 nSheet
)
2300 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
2303 uno::Reference
<table::XCellRange
> xSheet(static_cast<ScCellRangeObj
*>(GetObjectByIndex_Impl((USHORT
)nSheet
)));
2305 throw lang::IndexOutOfBoundsException();
2307 return xSheet
->getCellByPosition(nColumn
, nRow
);
2310 uno::Reference
< table::XCellRange
> SAL_CALL
ScTableSheetsObj::getCellRangeByPosition( sal_Int32 nLeft
, sal_Int32 nTop
, sal_Int32 nRight
, sal_Int32 nBottom
, sal_Int32 nSheet
)
2311 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
2314 uno::Reference
<table::XCellRange
> xSheet(static_cast<ScCellRangeObj
*>(GetObjectByIndex_Impl((USHORT
)nSheet
)));
2316 throw lang::IndexOutOfBoundsException();
2318 return xSheet
->getCellRangeByPosition(nLeft
, nTop
, nRight
, nBottom
);
2321 uno::Sequence
< uno::Reference
< table::XCellRange
> > SAL_CALL
ScTableSheetsObj::getCellRangesByName( const rtl::OUString
& aRange
)
2322 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
2325 uno::Sequence
< uno::Reference
< table::XCellRange
> > xRet
;
2327 ScRangeList aRangeList
;
2328 ScDocument
* pDoc
= pDocShell
->GetDocument();
2329 if (ScRangeStringConverter::GetRangeListFromString( aRangeList
, aRange
, pDoc
, ::formula::FormulaGrammar::CONV_OOO
, ';' ))
2331 sal_Int32 nCount
= aRangeList
.Count();
2334 xRet
.realloc(nCount
);
2335 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; nIndex
++ )
2337 const ScRange
* pRange
= aRangeList
.GetObject( nIndex
);
2339 xRet
[nIndex
] = new ScCellRangeObj(pDocShell
, *pRange
);
2343 throw lang::IllegalArgumentException();
2346 throw lang::IllegalArgumentException();
2350 // XEnumerationAccess
2352 uno::Reference
<container::XEnumeration
> SAL_CALL
ScTableSheetsObj::createEnumeration()
2353 throw(uno::RuntimeException
)
2356 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetsEnumeration")));
2361 sal_Int32 SAL_CALL
ScTableSheetsObj::getCount() throw(uno::RuntimeException
)
2365 return pDocShell
->GetDocument()->GetTableCount();
2369 uno::Any SAL_CALL
ScTableSheetsObj::getByIndex( sal_Int32 nIndex
)
2370 throw(lang::IndexOutOfBoundsException
,
2371 lang::WrappedTargetException
, uno::RuntimeException
)
2374 uno::Reference
<sheet::XSpreadsheet
> xSheet(GetObjectByIndex_Impl(nIndex
));
2376 return uno::makeAny(xSheet
);
2378 throw lang::IndexOutOfBoundsException();
2379 // return uno::Any();
2382 uno::Type SAL_CALL
ScTableSheetsObj::getElementType() throw(uno::RuntimeException
)
2385 return getCppuType((uno::Reference
<sheet::XSpreadsheet
>*)0);
2388 sal_Bool SAL_CALL
ScTableSheetsObj::hasElements() throw(uno::RuntimeException
)
2391 return ( getCount() != 0 );
2396 uno::Any SAL_CALL
ScTableSheetsObj::getByName( const rtl::OUString
& aName
)
2397 throw(container::NoSuchElementException
,
2398 lang::WrappedTargetException
, uno::RuntimeException
)
2401 uno::Reference
<sheet::XSpreadsheet
> xSheet(GetObjectByName_Impl(aName
));
2403 return uno::makeAny(xSheet
);
2405 throw container::NoSuchElementException();
2406 // return uno::Any();
2409 uno::Sequence
<rtl::OUString
> SAL_CALL
ScTableSheetsObj::getElementNames()
2410 throw(uno::RuntimeException
)
2415 ScDocument
* pDoc
= pDocShell
->GetDocument();
2416 SCTAB nCount
= pDoc
->GetTableCount();
2418 uno::Sequence
<rtl::OUString
> aSeq(nCount
);
2419 rtl::OUString
* pAry
= aSeq
.getArray();
2420 for (SCTAB i
=0; i
<nCount
; i
++)
2422 pDoc
->GetName( i
, aName
);
2427 return uno::Sequence
<rtl::OUString
>();
2430 sal_Bool SAL_CALL
ScTableSheetsObj::hasByName( const rtl::OUString
& aName
)
2431 throw(uno::RuntimeException
)
2437 if ( pDocShell
->GetDocument()->GetTable( String(aName
), nIndex
) )
2443 //------------------------------------------------------------------------
2445 ScTableColumnsObj::ScTableColumnsObj(ScDocShell
* pDocSh
, SCTAB nT
, SCCOL nSC
, SCCOL nEC
) :
2446 pDocShell( pDocSh
),
2451 pDocShell
->GetDocument()->AddUnoObject(*this);
2454 ScTableColumnsObj::~ScTableColumnsObj()
2457 pDocShell
->GetDocument()->RemoveUnoObject(*this);
2460 void ScTableColumnsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
2462 if ( rHint
.ISA( ScUpdateRefHint
) )
2464 // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
2466 //! Referenz-Update fuer Tab und Start/Ende
2468 else if ( rHint
.ISA( SfxSimpleHint
) &&
2469 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
2471 pDocShell
= NULL
; // ungueltig geworden
2477 ScTableColumnObj
* ScTableColumnsObj::GetObjectByIndex_Impl(sal_Int32 nIndex
) const
2479 SCCOL nCol
= static_cast<SCCOL
>(nIndex
) + nStartCol
;
2480 if ( pDocShell
&& nCol
<= nEndCol
)
2481 return new ScTableColumnObj( pDocShell
, nCol
, nTab
);
2483 return NULL
; // falscher Index
2486 ScTableColumnObj
* ScTableColumnsObj::GetObjectByName_Impl(const rtl::OUString
& aName
) const
2489 String
aString(aName
);
2490 if ( ::AlphaToCol( nCol
, aString
) )
2491 if ( pDocShell
&& nCol
>= nStartCol
&& nCol
<= nEndCol
)
2492 return new ScTableColumnObj( pDocShell
, nCol
, nTab
);
2497 void SAL_CALL
ScTableColumnsObj::insertByIndex( sal_Int32 nPosition
, sal_Int32 nCount
)
2498 throw(uno::RuntimeException
)
2502 if ( pDocShell
&& nCount
> 0 && nPosition
>= 0 && nStartCol
+nPosition
<= nEndCol
&&
2503 nStartCol
+nPosition
+nCount
-1 <= MAXCOL
)
2505 ScDocFunc
aFunc(*pDocShell
);
2506 ScRange
aRange( (SCCOL
)(nStartCol
+nPosition
), 0, nTab
,
2507 (SCCOL
)(nStartCol
+nPosition
+nCount
-1), MAXROW
, nTab
);
2508 bDone
= aFunc
.InsertCells( aRange
, NULL
, INS_INSCOLS
, TRUE
, TRUE
);
2511 throw uno::RuntimeException(); // no other exceptions specified
2514 void SAL_CALL
ScTableColumnsObj::removeByIndex( sal_Int32 nIndex
, sal_Int32 nCount
)
2515 throw(uno::RuntimeException
)
2519 // Der zu loeschende Bereich muss innerhalb des Objekts liegen
2520 if ( pDocShell
&& nCount
> 0 && nIndex
>= 0 && nStartCol
+nIndex
+nCount
-1 <= nEndCol
)
2522 ScDocFunc
aFunc(*pDocShell
);
2523 ScRange
aRange( (SCCOL
)(nStartCol
+nIndex
), 0, nTab
,
2524 (SCCOL
)(nStartCol
+nIndex
+nCount
-1), MAXROW
, nTab
);
2525 bDone
= aFunc
.DeleteCells( aRange
, NULL
, DEL_DELCOLS
, TRUE
, TRUE
);
2528 throw uno::RuntimeException(); // no other exceptions specified
2531 // XEnumerationAccess
2533 uno::Reference
<container::XEnumeration
> SAL_CALL
ScTableColumnsObj::createEnumeration()
2534 throw(uno::RuntimeException
)
2537 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableColumnsEnumeration")));
2542 sal_Int32 SAL_CALL
ScTableColumnsObj::getCount() throw(uno::RuntimeException
)
2545 return nEndCol
- nStartCol
+ 1;
2548 uno::Any SAL_CALL
ScTableColumnsObj::getByIndex( sal_Int32 nIndex
)
2549 throw(lang::IndexOutOfBoundsException
,
2550 lang::WrappedTargetException
, uno::RuntimeException
)
2553 uno::Reference
<table::XCellRange
> xColumn(GetObjectByIndex_Impl(nIndex
));
2555 return uno::makeAny(xColumn
);
2557 throw lang::IndexOutOfBoundsException();
2558 // return uno::Any();
2561 uno::Type SAL_CALL
ScTableColumnsObj::getElementType() throw(uno::RuntimeException
)
2564 return getCppuType((uno::Reference
<table::XCellRange
>*)0);
2567 sal_Bool SAL_CALL
ScTableColumnsObj::hasElements() throw(uno::RuntimeException
)
2570 return ( getCount() != 0 );
2573 uno::Any SAL_CALL
ScTableColumnsObj::getByName( const rtl::OUString
& aName
)
2574 throw(container::NoSuchElementException
,
2575 lang::WrappedTargetException
, uno::RuntimeException
)
2578 uno::Reference
<table::XCellRange
> xColumn(GetObjectByName_Impl(aName
));
2580 return uno::makeAny(xColumn
);
2582 throw container::NoSuchElementException();
2583 // return uno::Any();
2586 uno::Sequence
<rtl::OUString
> SAL_CALL
ScTableColumnsObj::getElementNames()
2587 throw(uno::RuntimeException
)
2590 SCCOL nCount
= nEndCol
- nStartCol
+ 1;
2591 uno::Sequence
<rtl::OUString
> aSeq(nCount
);
2592 rtl::OUString
* pAry
= aSeq
.getArray();
2593 for (SCCOL i
=0; i
<nCount
; i
++)
2594 pAry
[i
] = ::ScColToAlpha( nStartCol
+ i
);
2599 sal_Bool SAL_CALL
ScTableColumnsObj::hasByName( const rtl::OUString
& aName
)
2600 throw(uno::RuntimeException
)
2604 String
aString(aName
);
2605 if ( ::AlphaToCol( nCol
, aString
) )
2606 if ( pDocShell
&& nCol
>= nStartCol
&& nCol
<= nEndCol
)
2609 return FALSE
; // nicht gefunden
2614 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScTableColumnsObj::getPropertySetInfo()
2615 throw(uno::RuntimeException
)
2618 static uno::Reference
<beans::XPropertySetInfo
> aRef(
2619 new SfxItemPropertySetInfo( lcl_GetColumnsPropertyMap() ));
2623 void SAL_CALL
ScTableColumnsObj::setPropertyValue(
2624 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
2625 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
2626 lang::IllegalArgumentException
, lang::WrappedTargetException
,
2627 uno::RuntimeException
)
2631 throw uno::RuntimeException();
2633 ScDocFunc
aFunc(*pDocShell
);
2634 SCCOLROW nColArr
[2];
2635 nColArr
[0] = nStartCol
;
2636 nColArr
[1] = nEndCol
;
2637 String
aNameString(aPropertyName
);
2639 if ( aNameString
.EqualsAscii( SC_UNONAME_CELLWID
) )
2641 sal_Int32 nNewWidth
= 0;
2642 if ( aValue
>>= nNewWidth
)
2643 aFunc
.SetWidthOrHeight( TRUE
, 1, nColArr
, nTab
, SC_SIZE_ORIGINAL
,
2644 (USHORT
)HMMToTwips(nNewWidth
), TRUE
, TRUE
);
2646 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2648 BOOL bVis
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2649 ScSizeMode eMode
= bVis
? SC_SIZE_SHOW
: SC_SIZE_DIRECT
;
2650 aFunc
.SetWidthOrHeight( TRUE
, 1, nColArr
, nTab
, eMode
, 0, TRUE
, TRUE
);
2651 // SC_SIZE_DIRECT with size 0: hide
2653 else if ( aNameString
.EqualsAscii( SC_UNONAME_OWIDTH
) )
2655 BOOL bOpt
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2657 aFunc
.SetWidthOrHeight( TRUE
, 1, nColArr
, nTab
,
2658 SC_SIZE_OPTIMAL
, STD_EXTRA_WIDTH
, TRUE
, TRUE
);
2659 // FALSE for columns currently has no effect
2661 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) || aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2663 //! single function to set/remove all breaks?
2664 BOOL bSet
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2665 for (SCCOL nCol
=nStartCol
; nCol
<=nEndCol
; nCol
++)
2667 aFunc
.InsertPageBreak( TRUE
, ScAddress(nCol
,0,nTab
), TRUE
, TRUE
, TRUE
);
2669 aFunc
.RemovePageBreak( TRUE
, ScAddress(nCol
,0,nTab
), TRUE
, TRUE
, TRUE
);
2673 uno::Any SAL_CALL
ScTableColumnsObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
2674 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
2675 uno::RuntimeException
)
2679 throw uno::RuntimeException();
2681 ScDocument
* pDoc
= pDocShell
->GetDocument();
2682 String
aNameString(aPropertyName
);
2685 //! loop over all columns for current state?
2687 if ( aNameString
.EqualsAscii( SC_UNONAME_CELLWID
) )
2689 // for hidden column, return original height
2690 USHORT nWidth
= pDoc
->GetOriginalWidth( nStartCol
, nTab
);
2691 aAny
<<= (sal_Int32
)TwipsToHMM(nWidth
);
2693 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2696 bool bVis
= !pDoc
->ColHidden(nStartCol
, nTab
, nLastCol
);
2697 ScUnoHelpFunctions::SetBoolInAny( aAny
, bVis
);
2699 else if ( aNameString
.EqualsAscii( SC_UNONAME_OWIDTH
) )
2701 BOOL bOpt
= !(pDoc
->GetColFlags( nStartCol
, nTab
) & CR_MANUALSIZE
);
2702 ScUnoHelpFunctions::SetBoolInAny( aAny
, bOpt
);
2704 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) )
2706 ScBreakType nBreak
= pDoc
->HasColBreak(nStartCol
, nTab
);
2707 ScUnoHelpFunctions::SetBoolInAny( aAny
, nBreak
);
2709 else if ( aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2711 ScBreakType nBreak
= pDoc
->HasColBreak(nStartCol
, nTab
);
2712 ScUnoHelpFunctions::SetBoolInAny( aAny
, (nBreak
& BREAK_MANUAL
) );
2718 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableColumnsObj
)
2720 //------------------------------------------------------------------------
2722 ScTableRowsObj::ScTableRowsObj(ScDocShell
* pDocSh
, SCTAB nT
, SCROW nSR
, SCROW nER
) :
2723 pDocShell( pDocSh
),
2728 pDocShell
->GetDocument()->AddUnoObject(*this);
2731 ScTableRowsObj::~ScTableRowsObj()
2734 pDocShell
->GetDocument()->RemoveUnoObject(*this);
2737 void ScTableRowsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
2739 if ( rHint
.ISA( ScUpdateRefHint
) )
2741 // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
2743 //! Referenz-Update fuer Tab und Start/Ende
2745 else if ( rHint
.ISA( SfxSimpleHint
) &&
2746 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
2748 pDocShell
= NULL
; // ungueltig geworden
2754 ScTableRowObj
* ScTableRowsObj::GetObjectByIndex_Impl(sal_Int32 nIndex
) const
2756 SCROW nRow
= static_cast<SCROW
>(nIndex
) + nStartRow
;
2757 if ( pDocShell
&& nRow
<= nEndRow
)
2758 return new ScTableRowObj( pDocShell
, nRow
, nTab
);
2760 return NULL
; // falscher Index
2763 void SAL_CALL
ScTableRowsObj::insertByIndex( sal_Int32 nPosition
, sal_Int32 nCount
)
2764 throw(uno::RuntimeException
)
2768 if ( pDocShell
&& nCount
> 0 && nPosition
>= 0 && nStartRow
+nPosition
<= nEndRow
&&
2769 nStartRow
+nPosition
+nCount
-1 <= MAXROW
)
2771 ScDocFunc
aFunc(*pDocShell
);
2772 ScRange
aRange( 0, (SCROW
)(nStartRow
+nPosition
), nTab
,
2773 MAXCOL
, (SCROW
)(nStartRow
+nPosition
+nCount
-1), nTab
);
2774 bDone
= aFunc
.InsertCells( aRange
, NULL
, INS_INSROWS
, TRUE
, TRUE
);
2777 throw uno::RuntimeException(); // no other exceptions specified
2780 void SAL_CALL
ScTableRowsObj::removeByIndex( sal_Int32 nIndex
, sal_Int32 nCount
)
2781 throw(uno::RuntimeException
)
2785 // Der zu loeschende Bereich muss innerhalb des Objekts liegen
2786 if ( pDocShell
&& nCount
> 0 && nIndex
>= 0 && nStartRow
+nIndex
+nCount
-1 <= nEndRow
)
2788 ScDocFunc
aFunc(*pDocShell
);
2789 ScRange
aRange( 0, (SCROW
)(nStartRow
+nIndex
), nTab
,
2790 MAXCOL
, (SCROW
)(nStartRow
+nIndex
+nCount
-1), nTab
);
2791 bDone
= aFunc
.DeleteCells( aRange
, NULL
, DEL_DELROWS
, TRUE
, TRUE
);
2794 throw uno::RuntimeException(); // no other exceptions specified
2797 // XEnumerationAccess
2799 uno::Reference
<container::XEnumeration
> SAL_CALL
ScTableRowsObj::createEnumeration()
2800 throw(uno::RuntimeException
)
2803 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableRowsEnumeration")));
2808 sal_Int32 SAL_CALL
ScTableRowsObj::getCount() throw(uno::RuntimeException
)
2811 return nEndRow
- nStartRow
+ 1;
2814 uno::Any SAL_CALL
ScTableRowsObj::getByIndex( sal_Int32 nIndex
)
2815 throw(lang::IndexOutOfBoundsException
,
2816 lang::WrappedTargetException
, uno::RuntimeException
)
2819 uno::Reference
<table::XCellRange
> xRow(GetObjectByIndex_Impl(nIndex
));
2821 return uno::makeAny(xRow
);
2823 throw lang::IndexOutOfBoundsException();
2824 // return uno::Any();
2827 uno::Type SAL_CALL
ScTableRowsObj::getElementType() throw(uno::RuntimeException
)
2830 return getCppuType((uno::Reference
<table::XCellRange
>*)0);
2833 sal_Bool SAL_CALL
ScTableRowsObj::hasElements() throw(uno::RuntimeException
)
2836 return ( getCount() != 0 );
2841 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScTableRowsObj::getPropertySetInfo()
2842 throw(uno::RuntimeException
)
2845 static uno::Reference
<beans::XPropertySetInfo
> aRef(
2846 new SfxItemPropertySetInfo( lcl_GetRowsPropertyMap() ));
2850 void SAL_CALL
ScTableRowsObj::setPropertyValue(
2851 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
2852 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
2853 lang::IllegalArgumentException
, lang::WrappedTargetException
,
2854 uno::RuntimeException
)
2858 throw uno::RuntimeException();
2860 ScDocFunc
aFunc(*pDocShell
);
2861 ScDocument
* pDoc
= pDocShell
->GetDocument();
2862 SCCOLROW nRowArr
[2];
2863 nRowArr
[0] = nStartRow
;
2864 nRowArr
[1] = nEndRow
;
2865 String
aNameString(aPropertyName
);
2867 if ( aNameString
.EqualsAscii( SC_UNONAME_OHEIGHT
) )
2869 sal_Int32 nNewHeight
= 0;
2870 if ( pDoc
->IsImportingXML() && ( aValue
>>= nNewHeight
) )
2872 // used to set the stored row height for rows with optimal height when loading
2873 pDoc
->SetRowHeightRange( nStartRow
, nEndRow
, nTab
, (USHORT
)HMMToTwips(nNewHeight
) );
2877 BOOL bOpt
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2879 aFunc
.SetWidthOrHeight( FALSE
, 1, nRowArr
, nTab
, SC_SIZE_OPTIMAL
, 0, TRUE
, TRUE
);
2882 //! manually set old heights again?
2886 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLHGT
) )
2888 sal_Int32 nNewHeight
= 0;
2889 if ( aValue
>>= nNewHeight
)
2890 aFunc
.SetWidthOrHeight( FALSE
, 1, nRowArr
, nTab
, SC_SIZE_ORIGINAL
,
2891 (USHORT
)HMMToTwips(nNewHeight
), TRUE
, TRUE
);
2893 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2895 BOOL bVis
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2896 ScSizeMode eMode
= bVis
? SC_SIZE_SHOW
: SC_SIZE_DIRECT
;
2897 aFunc
.SetWidthOrHeight( FALSE
, 1, nRowArr
, nTab
, eMode
, 0, TRUE
, TRUE
);
2898 // SC_SIZE_DIRECT with size 0: hide
2900 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLFILT
) )
2903 if (ScUnoHelpFunctions::GetBoolFromAny( aValue
))
2904 pDoc
->SetRowFiltered(nStartRow
, nEndRow
, nTab
, true);
2906 pDoc
->SetRowFiltered(nStartRow
, nEndRow
, nTab
, false);
2908 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) || aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2910 //! single function to set/remove all breaks?
2911 BOOL bSet
= ScUnoHelpFunctions::GetBoolFromAny( aValue
);
2912 for (SCROW nRow
=nStartRow
; nRow
<=nEndRow
; nRow
++)
2914 aFunc
.InsertPageBreak( FALSE
, ScAddress(0,nRow
,nTab
), TRUE
, TRUE
, TRUE
);
2916 aFunc
.RemovePageBreak( FALSE
, ScAddress(0,nRow
,nTab
), TRUE
, TRUE
, TRUE
);
2918 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLBACK
) || aNameString
.EqualsAscii( SC_UNONAME_CELLTRAN
) )
2920 // #i57867# Background color is specified for row styles in the file format,
2921 // so it has to be supported along with the row properties (import only).
2923 // Use ScCellRangeObj to set the property for all cells in the rows
2924 // (this means, the "row attribute" must be set before individual cell attributes).
2926 ScRange
aRange( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
);
2927 uno::Reference
<beans::XPropertySet
> xRangeObj
= new ScCellRangeObj( pDocShell
, aRange
);
2928 xRangeObj
->setPropertyValue( aPropertyName
, aValue
);
2932 uno::Any SAL_CALL
ScTableRowsObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
2933 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
2934 uno::RuntimeException
)
2938 throw uno::RuntimeException();
2940 ScDocument
* pDoc
= pDocShell
->GetDocument();
2941 String
aNameString(aPropertyName
);
2944 //! loop over all rows for current state?
2946 if ( aNameString
.EqualsAscii( SC_UNONAME_CELLHGT
) )
2948 // for hidden row, return original height
2949 USHORT nHeight
= pDoc
->GetOriginalHeight( nStartRow
, nTab
);
2950 aAny
<<= (sal_Int32
)TwipsToHMM(nHeight
);
2952 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLVIS
) )
2955 bool bVis
= !pDoc
->RowHidden(nStartRow
, nTab
, nLastRow
);
2956 ScUnoHelpFunctions::SetBoolInAny( aAny
, bVis
);
2958 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLFILT
) )
2960 bool bVis
= pDoc
->RowFiltered(nStartRow
, nTab
);
2961 ScUnoHelpFunctions::SetBoolInAny( aAny
, bVis
);
2963 else if ( aNameString
.EqualsAscii( SC_UNONAME_OHEIGHT
) )
2965 BOOL bOpt
= !(pDoc
->GetRowFlags( nStartRow
, nTab
) & CR_MANUALSIZE
);
2966 ScUnoHelpFunctions::SetBoolInAny( aAny
, bOpt
);
2968 else if ( aNameString
.EqualsAscii( SC_UNONAME_NEWPAGE
) )
2970 ScBreakType nBreak
= pDoc
->HasRowBreak(nStartRow
, nTab
);
2971 ScUnoHelpFunctions::SetBoolInAny( aAny
, nBreak
);
2973 else if ( aNameString
.EqualsAscii( SC_UNONAME_MANPAGE
) )
2975 ScBreakType nBreak
= pDoc
->HasRowBreak(nStartRow
, nTab
);
2976 ScUnoHelpFunctions::SetBoolInAny( aAny
, (nBreak
& BREAK_MANUAL
) );
2978 else if ( aNameString
.EqualsAscii( SC_UNONAME_CELLBACK
) || aNameString
.EqualsAscii( SC_UNONAME_CELLTRAN
) )
2980 // Use ScCellRangeObj to get the property from the cell range
2981 // (for completeness only, this is not used by the XML filter).
2983 ScRange
aRange( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
);
2984 uno::Reference
<beans::XPropertySet
> xRangeObj
= new ScCellRangeObj( pDocShell
, aRange
);
2985 aAny
= xRangeObj
->getPropertyValue( aPropertyName
);
2991 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableRowsObj
)
2993 //------------------------------------------------------------------------
2995 //UNUSED2008-05 ScSpreadsheetSettingsObj::ScSpreadsheetSettingsObj(ScDocShell* pDocSh) :
2996 //UNUSED2008-05 pDocShell( pDocSh )
2998 //UNUSED2008-05 pDocShell->GetDocument()->AddUnoObject(*this);
3001 ScSpreadsheetSettingsObj::~ScSpreadsheetSettingsObj()
3004 pDocShell
->GetDocument()->RemoveUnoObject(*this);
3007 void ScSpreadsheetSettingsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
3009 // Referenz-Update interessiert hier nicht
3011 if ( rHint
.ISA( SfxSimpleHint
) &&
3012 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
3014 pDocShell
= NULL
; // ungueltig geworden
3020 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScSpreadsheetSettingsObj::getPropertySetInfo()
3021 throw(uno::RuntimeException
)
3027 void SAL_CALL
ScSpreadsheetSettingsObj::setPropertyValue(
3028 const rtl::OUString
& /* aPropertyName */, const uno::Any
& /* aValue */ )
3029 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
3030 lang::IllegalArgumentException
, lang::WrappedTargetException
,
3031 uno::RuntimeException
)
3036 uno::Any SAL_CALL
ScSpreadsheetSettingsObj::getPropertyValue( const rtl::OUString
& /* aPropertyName */ )
3037 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
3038 uno::RuntimeException
)
3044 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettingsObj
)
3046 //------------------------------------------------------------------------
3048 ScAnnotationsObj::ScAnnotationsObj(ScDocShell
* pDocSh
, SCTAB nT
) :
3049 pDocShell( pDocSh
),
3052 pDocShell
->GetDocument()->AddUnoObject(*this);
3055 ScAnnotationsObj::~ScAnnotationsObj()
3058 pDocShell
->GetDocument()->RemoveUnoObject(*this);
3061 void ScAnnotationsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
3063 //! nTab bei Referenz-Update anpassen!!!
3065 if ( rHint
.ISA( SfxSimpleHint
) &&
3066 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
3068 pDocShell
= NULL
; // ungueltig geworden
3072 bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex
, ScAddress
& rPos
) const
3076 sal_Int32 nFound
= 0;
3077 ScDocument
* pDoc
= pDocShell
->GetDocument();
3078 ScCellIterator
aCellIter( pDoc
, 0,0, nTab
, MAXCOL
,MAXROW
, nTab
);
3079 for( ScBaseCell
* pCell
= aCellIter
.GetFirst(); pCell
; pCell
= aCellIter
.GetNext() )
3081 if (pCell
->HasNote())
3083 if (nFound
== nIndex
)
3085 rPos
= ScAddress( aCellIter
.GetCol(), aCellIter
.GetRow(), aCellIter
.GetTab() );
3095 ScAnnotationObj
* ScAnnotationsObj::GetObjectByIndex_Impl( sal_Int32 nIndex
) const
3100 if ( GetAddressByIndex_Impl( nIndex
, aPos
) )
3101 return new ScAnnotationObj( pDocShell
, aPos
);
3106 // XSheetAnnotations
3108 void SAL_CALL
ScAnnotationsObj::insertNew(
3109 const table::CellAddress
& aPosition
, const ::rtl::OUString
& rText
)
3110 throw(uno::RuntimeException
)
3115 DBG_ASSERT( aPosition
.Sheet
== nTab
, "addAnnotation mit falschem Sheet" );
3116 ScAddress
aPos( (SCCOL
)aPosition
.Column
, (SCROW
)aPosition
.Row
, nTab
);
3118 ScDocFunc
aFunc( *pDocShell
);
3119 aFunc
.ReplaceNote( aPos
, rText
, 0, 0, TRUE
);
3123 void SAL_CALL
ScAnnotationsObj::removeByIndex( sal_Int32 nIndex
) throw(uno::RuntimeException
)
3129 if ( GetAddressByIndex_Impl( nIndex
, aPos
) )
3131 ScMarkData aMarkData
;
3132 aMarkData
.SelectTable( aPos
.Tab(), TRUE
);
3133 aMarkData
.SetMultiMarkArea( ScRange(aPos
) );
3135 ScDocFunc
aFunc(*pDocShell
);
3136 aFunc
.DeleteContents( aMarkData
, IDF_NOTE
, TRUE
, TRUE
);
3141 // XEnumerationAccess
3143 uno::Reference
<container::XEnumeration
> SAL_CALL
ScAnnotationsObj::createEnumeration()
3144 throw(uno::RuntimeException
)
3146 //! iterate directly (more efficiently)?
3149 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.CellAnnotationsEnumeration")));
3154 sal_Int32 SAL_CALL
ScAnnotationsObj::getCount() throw(uno::RuntimeException
)
3160 ScCellIterator
aCellIter( pDocShell
->GetDocument(), 0,0, nTab
, MAXCOL
,MAXROW
, nTab
);
3161 for( ScBaseCell
* pCell
= aCellIter
.GetFirst(); pCell
; pCell
= aCellIter
.GetNext() )
3162 if (pCell
->HasNote())
3168 uno::Any SAL_CALL
ScAnnotationsObj::getByIndex( sal_Int32 nIndex
)
3169 throw(lang::IndexOutOfBoundsException
,
3170 lang::WrappedTargetException
, uno::RuntimeException
)
3173 uno::Reference
<sheet::XSheetAnnotation
> xAnnotation(GetObjectByIndex_Impl(nIndex
));
3174 if (xAnnotation
.is())
3175 return uno::makeAny(xAnnotation
);
3177 throw lang::IndexOutOfBoundsException();
3178 // return uno::Any();
3181 uno::Type SAL_CALL
ScAnnotationsObj::getElementType() throw(uno::RuntimeException
)
3184 return getCppuType((uno::Reference
<sheet::XSheetAnnotation
>*)0);
3187 sal_Bool SAL_CALL
ScAnnotationsObj::hasElements() throw(uno::RuntimeException
)
3190 return ( getCount() != 0 );
3193 //------------------------------------------------------------------------
3195 ScScenariosObj::ScScenariosObj(ScDocShell
* pDocSh
, SCTAB nT
) :
3196 pDocShell( pDocSh
),
3199 pDocShell
->GetDocument()->AddUnoObject(*this);
3202 ScScenariosObj::~ScScenariosObj()
3205 pDocShell
->GetDocument()->RemoveUnoObject(*this);
3208 void ScScenariosObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
3210 if ( rHint
.ISA( ScUpdateRefHint
) )
3212 // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
3214 //! Referenz-Update fuer Tab und Start/Ende
3216 else if ( rHint
.ISA( SfxSimpleHint
) &&
3217 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
3219 pDocShell
= NULL
; // ungueltig geworden
3225 BOOL
ScScenariosObj::GetScenarioIndex_Impl( const rtl::OUString
& rName
, SCTAB
& rIndex
)
3227 //! Case-insensitiv ????
3231 String
aString(rName
);
3234 ScDocument
* pDoc
= pDocShell
->GetDocument();
3235 SCTAB nCount
= (SCTAB
)getCount();
3236 for (SCTAB i
=0; i
<nCount
; i
++)
3237 if (pDoc
->GetName( nTab
+i
+1, aTabName
))
3238 if ( aTabName
== aString
)
3248 ScTableSheetObj
* ScScenariosObj::GetObjectByIndex_Impl(sal_Int32 nIndex
)
3250 USHORT nCount
= (USHORT
)getCount();
3251 if ( pDocShell
&& nIndex
>= 0 && nIndex
< nCount
)
3252 return new ScTableSheetObj( pDocShell
, nTab
+static_cast<SCTAB
>(nIndex
)+1 );
3254 return NULL
; // kein Dokument oder falscher Index
3257 ScTableSheetObj
* ScScenariosObj::GetObjectByName_Impl(const rtl::OUString
& aName
)
3260 if ( pDocShell
&& GetScenarioIndex_Impl( aName
, nIndex
) )
3261 return new ScTableSheetObj( pDocShell
, nTab
+nIndex
+1 );
3263 return NULL
; // nicht gefunden
3266 void SAL_CALL
ScScenariosObj::addNewByName( const rtl::OUString
& aName
,
3267 const uno::Sequence
<table::CellRangeAddress
>& aRanges
,
3268 const rtl::OUString
& aComment
)
3269 throw(uno::RuntimeException
)
3274 ScMarkData aMarkData
;
3275 aMarkData
.SelectTable( nTab
, TRUE
);
3277 USHORT nRangeCount
= (USHORT
)aRanges
.getLength();
3280 const table::CellRangeAddress
* pAry
= aRanges
.getConstArray();
3281 for (USHORT i
=0; i
<nRangeCount
; i
++)
3283 DBG_ASSERT( pAry
[i
].Sheet
== nTab
, "addScenario mit falscher Tab" );
3284 ScRange
aRange( (SCCOL
)pAry
[i
].StartColumn
, (SCROW
)pAry
[i
].StartRow
, nTab
,
3285 (SCCOL
)pAry
[i
].EndColumn
, (SCROW
)pAry
[i
].EndRow
, nTab
);
3287 aMarkData
.SetMultiMarkArea( aRange
);
3291 String
aNameStr(aName
);
3292 String
aCommStr(aComment
);
3294 Color
aColor( COL_LIGHTGRAY
); // Default
3295 USHORT nFlags
= SC_SCENARIO_SHOWFRAME
| SC_SCENARIO_PRINTFRAME
| SC_SCENARIO_TWOWAY
| SC_SCENARIO_PROTECT
;
3297 pDocShell
->MakeScenario( nTab
, aNameStr
, aCommStr
, aColor
, nFlags
, aMarkData
);
3301 void SAL_CALL
ScScenariosObj::removeByName( const rtl::OUString
& aName
)
3302 throw(uno::RuntimeException
)
3306 if ( pDocShell
&& GetScenarioIndex_Impl( aName
, nIndex
) )
3308 ScDocFunc
aFunc(*pDocShell
);
3309 aFunc
.DeleteTable( nTab
+nIndex
+1, TRUE
, TRUE
);
3313 // XEnumerationAccess
3315 uno::Reference
<container::XEnumeration
> SAL_CALL
ScScenariosObj::createEnumeration()
3316 throw(uno::RuntimeException
)
3319 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.ScenariosEnumeration")));
3324 sal_Int32 SAL_CALL
ScScenariosObj::getCount() throw(uno::RuntimeException
)
3330 ScDocument
* pDoc
= pDocShell
->GetDocument();
3331 if (!pDoc
->IsScenario(nTab
))
3333 SCTAB nTabCount
= pDoc
->GetTableCount();
3334 SCTAB nNext
= nTab
+ 1;
3335 while (nNext
< nTabCount
&& pDoc
->IsScenario(nNext
))
3345 uno::Any SAL_CALL
ScScenariosObj::getByIndex( sal_Int32 nIndex
)
3346 throw(lang::IndexOutOfBoundsException
,
3347 lang::WrappedTargetException
, uno::RuntimeException
)
3350 uno::Reference
<sheet::XScenario
> xScen(GetObjectByIndex_Impl(nIndex
));
3352 return uno::makeAny(xScen
);
3354 throw lang::IndexOutOfBoundsException();
3355 // return uno::Any();
3358 uno::Type SAL_CALL
ScScenariosObj::getElementType() throw(uno::RuntimeException
)
3361 return getCppuType((uno::Reference
<sheet::XScenario
>*)0);
3364 sal_Bool SAL_CALL
ScScenariosObj::hasElements() throw(uno::RuntimeException
)
3367 return ( getCount() != 0 );
3370 uno::Any SAL_CALL
ScScenariosObj::getByName( const rtl::OUString
& aName
)
3371 throw(container::NoSuchElementException
,
3372 lang::WrappedTargetException
, uno::RuntimeException
)
3375 uno::Reference
<sheet::XScenario
> xScen(GetObjectByName_Impl(aName
));
3377 return uno::makeAny(xScen
);
3379 throw container::NoSuchElementException();
3380 // return uno::Any();
3383 uno::Sequence
<rtl::OUString
> SAL_CALL
ScScenariosObj::getElementNames()
3384 throw(uno::RuntimeException
)
3387 SCTAB nCount
= (SCTAB
)getCount();
3388 uno::Sequence
<rtl::OUString
> aSeq(nCount
);
3390 if ( pDocShell
) // sonst ist auch Count = 0
3393 ScDocument
* pDoc
= pDocShell
->GetDocument();
3394 rtl::OUString
* pAry
= aSeq
.getArray();
3395 for (SCTAB i
=0; i
<nCount
; i
++)
3396 if (pDoc
->GetName( nTab
+i
+1, aTabName
))
3403 sal_Bool SAL_CALL
ScScenariosObj::hasByName( const rtl::OUString
& aName
)
3404 throw(uno::RuntimeException
)
3408 return GetScenarioIndex_Impl( aName
, nIndex
);