Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "scitems.hxx"
31 : : #include <svx/fmdpage.hxx>
32 : : #include <svx/fmview.hxx>
33 : : #include <svx/svditer.hxx>
34 : : #include <svx/svdpage.hxx>
35 : : #include <svx/svxids.hrc>
36 : : #include <svx/unoshape.hxx>
37 : :
38 : : #include <officecfg/Office/Common.hxx>
39 : : #include <svl/numuno.hxx>
40 : : #include <svl/smplhint.hxx>
41 : : #include <unotools/moduleoptions.hxx>
42 : : #include <sfx2/printer.hxx>
43 : : #include <sfx2/bindings.hxx>
44 : : #include <vcl/pdfextoutdevdata.hxx>
45 : : #include <vcl/waitobj.hxx>
46 : : #include <unotools/charclass.hxx>
47 : : #include <tools/multisel.hxx>
48 : : #include <tools/resary.hxx>
49 : : #include <toolkit/awt/vclxdevice.hxx>
50 : :
51 : : #include <ctype.h>
52 : : #include <float.h> // DBL_MAX
53 : :
54 : : #include <com/sun/star/util/Date.hpp>
55 : : #include <com/sun/star/sheet/XNamedRanges.hpp>
56 : : #include <com/sun/star/sheet/XLabelRanges.hpp>
57 : : #include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp>
58 : : #include <com/sun/star/sheet/XUnnamedDatabaseRanges.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/script/vba/XVBAEventProcessor.hpp>
66 : : #include <comphelper/processfactory.hxx>
67 : : #include <comphelper/servicehelper.hxx>
68 : : #include <comphelper/string.hxx>
69 : :
70 : : #include "docuno.hxx"
71 : : #include "cellsuno.hxx"
72 : : #include "nameuno.hxx"
73 : : #include "datauno.hxx"
74 : : #include "miscuno.hxx"
75 : : #include "notesuno.hxx"
76 : : #include "styleuno.hxx"
77 : : #include "linkuno.hxx"
78 : : #include "servuno.hxx"
79 : : #include "targuno.hxx"
80 : : #include "convuno.hxx"
81 : : #include "optuno.hxx"
82 : : #include "forbiuno.hxx"
83 : : #include "docsh.hxx"
84 : : #include "hints.hxx"
85 : : #include "docfunc.hxx"
86 : : #include "postit.hxx"
87 : : #include "dociter.hxx"
88 : : #include "cell.hxx"
89 : : #include "drwlayer.hxx"
90 : : #include "rangeutl.hxx"
91 : : #include "markdata.hxx"
92 : : #include "docoptio.hxx"
93 : : #include "unonames.hxx"
94 : : #include "shapeuno.hxx"
95 : : #include "viewuno.hxx"
96 : : #include "tabvwsh.hxx"
97 : : #include "printfun.hxx"
98 : : #include "pfuncache.hxx"
99 : : #include "scmod.hxx"
100 : : #include "ViewSettingsSequenceDefines.hxx"
101 : : #include "sheetevents.hxx"
102 : : #include "sc.hrc"
103 : : #include "scresid.hxx"
104 : :
105 : : using namespace com::sun::star;
106 : : #define SC_UNO_VBADOCOBJ "ThisVBADocObj" // perhaps we want to actually make this ThisWorkbook ?
107 : :
108 : : //------------------------------------------------------------------------
109 : :
110 : : // alles ohne Which-ID, Map nur fuer PropertySetInfo
111 : :
112 : : //! umbenennen, sind nicht mehr nur Options
113 : 846 : const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap()
114 : : {
115 : : static SfxItemPropertyMapEntry aDocOptPropertyMap_Impl[] =
116 : : {
117 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_APPLYFMDES), 0, &getBooleanCppuType(), 0, 0},
118 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_AREALINKS), 0, &getCppuType((uno::Reference<sheet::XAreaLinks>*)0), 0, 0},
119 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC), 0, &getBooleanCppuType(), 0, 0},
120 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0},
121 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0},
122 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_VBADOCOBJ), 0, &getCppuType((beans::PropertyValue*)0), beans::PropertyAttribute::READONLY, 0},
123 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN, &getBooleanCppuType(), 0, 0},
124 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
125 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
126 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
127 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_COLLABELRNG), 0, &getCppuType((uno::Reference<sheet::XLabelRanges>*)0), 0, 0},
128 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_DDELINKS), 0, &getCppuType((uno::Reference<container::XNameAccess>*)0), 0, 0},
129 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_DEFTABSTOP), PROP_UNO_DEFTABSTOP, &getCppuType((sal_Int16*)0), 0, 0},
130 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_EXTERNALDOCLINKS), 0, &getCppuType((uno::Reference<sheet::XExternalDocLinks>*)0), 0, 0},
131 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_FORBIDDEN), 0, &getCppuType((uno::Reference<i18n::XForbiddenCharacters>*)0), beans::PropertyAttribute::READONLY, 0},
132 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_HASDRAWPAGES), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
133 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_IGNORECASE), PROP_UNO_IGNORECASE, &getBooleanCppuType(), 0, 0},
134 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ITERENABLED), PROP_UNO_ITERENABLED, &getBooleanCppuType(), 0, 0},
135 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ITERCOUNT), PROP_UNO_ITERCOUNT, &getCppuType((sal_Int32*)0), 0, 0},
136 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ITEREPSILON), PROP_UNO_ITEREPSILON, &getCppuType((double*)0), 0, 0},
137 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS, &getBooleanCppuType(), 0, 0},
138 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_MATCHWHOLE), PROP_UNO_MATCHWHOLE, &getBooleanCppuType(), 0, 0},
139 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_NAMEDRANGES), 0, &getCppuType((uno::Reference<sheet::XNamedRanges>*)0), 0, 0},
140 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_DATABASERNG), 0, &getCppuType((uno::Reference<sheet::XDatabaseRanges>*)0), 0, 0},
141 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_NULLDATE), PROP_UNO_NULLDATE, &getCppuType((util::Date*)0), 0, 0},
142 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ROWLABELRNG), 0, &getCppuType((uno::Reference<sheet::XLabelRanges>*)0), 0, 0},
143 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_SHEETLINKS), 0, &getCppuType((uno::Reference<container::XNameAccess>*)0), 0, 0},
144 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_SPELLONLINE), PROP_UNO_SPELLONLINE, &getBooleanCppuType(), 0, 0},
145 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_STANDARDDEC), PROP_UNO_STANDARDDEC, &getCppuType((sal_Int16*)0), 0, 0},
146 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED, &getBooleanCppuType(), 0, 0},
147 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_RUNTIMEUID), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), beans::PropertyAttribute::READONLY, 0},
148 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_HASVALIDSIGNATURES),0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
149 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ISLOADED), 0, &getBooleanCppuType(), 0, 0},
150 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ISUNDOENABLED), 0, &getBooleanCppuType(), 0, 0},
151 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ISADJUSTHEIGHTENABLED), 0, &getBooleanCppuType(), 0, 0},
152 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ISEXECUTELINKENABLED), 0, &getBooleanCppuType(), 0, 0},
153 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_ISCHANGEREADONLYENABLED), 0, &getBooleanCppuType(), 0, 0},
154 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_REFERENCEDEVICE), 0, &getCppuType((uno::Reference<awt::XDevice>*)0), beans::PropertyAttribute::READONLY, 0},
155 [ + - ]: 51 : {MAP_CHAR_LEN("BuildId"), 0, &::getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0},
156 [ + - ]: 51 : {MAP_CHAR_LEN(SC_UNO_CODENAME), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0},
157 : :
158 : : {0,0,0,0,0,0}
159 [ + + ][ + - ]: 897 : };
[ # # ]
160 : 846 : return aDocOptPropertyMap_Impl;
161 : : }
162 : :
163 : : //! StandardDecimals als Property und vom NumberFormatter ????????
164 : :
165 : 27 : const SfxItemPropertyMapEntry* lcl_GetColumnsPropertyMap()
166 : : {
167 : : static SfxItemPropertyMapEntry aColumnsPropertyMap_Impl[] =
168 : : {
169 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), 0, &getBooleanCppuType(), 0, 0 },
170 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), 0, &getBooleanCppuType(), 0, 0 },
171 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), 0, &getBooleanCppuType(), 0, 0 },
172 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_OWIDTH), 0, &getBooleanCppuType(), 0, 0 },
173 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_CELLWID), 0, &getCppuType((sal_Int32*)0), 0, 0 },
174 : : {0,0,0,0,0,0}
175 [ + - ][ + - ]: 54 : };
[ # # ]
176 : 27 : return aColumnsPropertyMap_Impl;
177 : : }
178 : :
179 : 27 : const SfxItemPropertyMapEntry* lcl_GetRowsPropertyMap()
180 : : {
181 : : static SfxItemPropertyMapEntry aRowsPropertyMap_Impl[] =
182 : : {
183 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_CELLHGT), 0, &getCppuType((sal_Int32*)0), 0, 0 },
184 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), 0, &getBooleanCppuType(), 0, 0 },
185 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_OHEIGHT), 0, &getBooleanCppuType(), 0, 0 },
186 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), 0, &getBooleanCppuType(), 0, 0 },
187 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), 0, &getBooleanCppuType(), 0, 0 },
188 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), 0, &getBooleanCppuType(), 0, 0 },
189 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
190 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
191 : : // not sorted, not used with SfxItemPropertyMapEntry::GetByName
192 : : {0,0,0,0,0,0}
193 [ + - ][ + - ]: 54 : };
[ # # ]
194 : 27 : return aRowsPropertyMap_Impl;
195 : : }
196 : :
197 : : using sc::HMMToTwips;
198 : : using sc::TwipsToHMM;
199 : :
200 : : //------------------------------------------------------------------------
201 : :
202 : : #define SCMODELOBJ_SERVICE "com.sun.star.sheet.SpreadsheetDocument"
203 : : #define SCDOCSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetDocumentSettings"
204 : : #define SCDOC_SERVICE "com.sun.star.document.OfficeDocument"
205 : :
206 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScAnnotationsObj, "ScAnnotationsObj", "com.sun.star.sheet.CellAnnotations" )
207 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScDrawPagesObj, "ScDrawPagesObj", "com.sun.star.drawing.DrawPages" )
208 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScScenariosObj, "ScScenariosObj", "com.sun.star.sheet.Scenarios" )
209 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettingsObj, "ScSpreadsheetSettingsObj", "com.sun.star.sheet.SpreadsheetDocumentSettings" )
210 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScTableColumnsObj, "ScTableColumnsObj", "com.sun.star.table.TableColumns" )
211 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScTableRowsObj, "ScTableRowsObj", "com.sun.star.table.TableRows" )
212 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScTableSheetsObj, "ScTableSheetsObj", "com.sun.star.sheet.Spreadsheets" )
213 : :
214 : : //------------------------------------------------------------------------
215 : :
216 : 0 : class ScPrintUIOptions : public vcl::PrinterOptionsHelper
217 : : {
218 : : public:
219 : : ScPrintUIOptions();
220 : : void SetDefaults();
221 : : };
222 : :
223 : 0 : ScPrintUIOptions::ScPrintUIOptions()
224 : : {
225 [ # # ][ # # ]: 0 : const ScPrintOptions& rPrintOpt = SC_MOD()->GetPrintOptions();
226 : 0 : sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1;
227 : 0 : sal_Bool bSuppress = rPrintOpt.GetSkipEmpty();
228 : :
229 [ # # ][ # # ]: 0 : ResStringArray aStrings( ScResId( SCSTR_PRINT_OPTIONS ) );
230 : : OSL_ENSURE( aStrings.Count() >= 10, "resource incomplete" );
231 [ # # ]: 0 : if( aStrings.Count() < 10 ) // bad resource ?
232 : 0 : return;
233 : :
234 [ # # ]: 0 : m_aUIProperties.realloc( 8 );
235 : :
236 : : // create Section for spreadsheet (results in an extra tab page in dialog)
237 [ # # ]: 0 : SvtModuleOptions aOpt;
238 [ # # ][ # # ]: 0 : String aAppGroupname( aStrings.GetString( 9 ) );
239 : : aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
240 [ # # ][ # # ]: 0 : aOpt.GetModuleName( SvtModuleOptions::E_SCALC ) );
[ # # ][ # # ]
[ # # ][ # # ]
241 [ # # ][ # # ]: 0 : m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() );
[ # # ]
242 : :
243 : : // create subgroup for pages
244 [ # # ][ # # ]: 0 : m_aUIProperties[1].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 0 ) ), rtl::OUString() );
[ # # ][ # # ]
[ # # ]
245 : :
246 : : // create a bool option for empty pages
247 [ # # ]: 0 : m_aUIProperties[2].Value = getBoolControlOpt( rtl::OUString( aStrings.GetString( 1 ) ),
248 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:IsIncludeEmptyPages:CheckBox" ) ),
249 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsIncludeEmptyPages" ) ),
250 : : ! bSuppress
251 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
[ # # ][ # # ]
252 : : // create Subgroup for print content
253 [ # # ]: 0 : vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt;
254 [ # # ]: 0 : aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
255 [ # # ]: 0 : m_aUIProperties[3].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 2 ) ),
256 : : rtl::OUString(),
257 : : aPrintRangeOpt
258 [ # # ][ # # ]: 0 : );
259 : :
260 : : // create a choice for the content to create
261 [ # # ][ # # ]: 0 : uno::Sequence< rtl::OUString > aChoices( 3 ), aHelpIds( 3 );
262 [ # # ][ # # ]: 0 : aChoices[0] = aStrings.GetString( 3 );
263 [ # # ][ # # ]: 0 : aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0" ) );
264 [ # # ][ # # ]: 0 : aChoices[1] = aStrings.GetString( 4 );
265 [ # # ][ # # ]: 0 : aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1" ) );
266 [ # # ][ # # ]: 0 : aChoices[2] = aStrings.GetString( 5 );
267 [ # # ][ # # ]: 0 : aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2" ) );
268 [ # # ]: 0 : m_aUIProperties[4].Value = getChoiceControlOpt( rtl::OUString(),
269 : : aHelpIds,
270 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ),
271 : : aChoices,
272 [ # # ][ # # ]: 0 : nContent );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
273 : :
274 : : // create Subgroup for print range
275 : 0 : aPrintRangeOpt.mbInternalOnly = sal_True;
276 [ # # ]: 0 : m_aUIProperties[5].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 6 ) ),
277 : : rtl::OUString(),
278 : : aPrintRangeOpt
279 [ # # ][ # # ]: 0 : );
280 : :
281 : : // create a choice for the range to print
282 [ # # ]: 0 : rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
283 [ # # ]: 0 : aChoices.realloc( 2 );
284 [ # # ]: 0 : aHelpIds.realloc( 2 );
285 [ # # ][ # # ]: 0 : aChoices[0] = aStrings.GetString( 7 );
286 [ # # ][ # # ]: 0 : aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:0" ) );
287 [ # # ][ # # ]: 0 : aChoices[1] = aStrings.GetString( 8 );
288 [ # # ][ # # ]: 0 : aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:1" ) );
289 [ # # ]: 0 : m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(),
290 : : aHelpIds,
291 : : aPrintRangeName,
292 : : aChoices,
293 [ # # ][ # # ]: 0 : 0 );
[ # # ][ # # ]
[ # # ][ # # ]
294 : :
295 : : // create a an Edit dependent on "Pages" selected
296 [ # # ]: 0 : vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True );
297 [ # # ]: 0 : m_aUIProperties[7].Value = getEditControlOpt( rtl::OUString(),
298 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageRange:Edit" ) ),
299 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ),
300 : : rtl::OUString(),
301 : : aPageRangeOpt
302 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
303 : : }
304 : :
305 : 0 : void ScPrintUIOptions::SetDefaults()
306 : : {
307 : : // re-initialize the default values from print options
308 : :
309 [ # # ][ # # ]: 0 : const ScPrintOptions& rPrintOpt = SC_MOD()->GetPrintOptions();
310 : 0 : sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1;
311 : 0 : sal_Bool bSuppress = rPrintOpt.GetSkipEmpty();
312 : :
313 [ # # ]: 0 : for (sal_Int32 nUIPos=0; nUIPos<m_aUIProperties.getLength(); ++nUIPos)
314 : : {
315 [ # # ]: 0 : uno::Sequence<beans::PropertyValue> aUIProp;
316 [ # # ][ # # ]: 0 : if ( m_aUIProperties[nUIPos].Value >>= aUIProp )
[ # # ]
317 : : {
318 [ # # ]: 0 : for (sal_Int32 nPropPos=0; nPropPos<aUIProp.getLength(); ++nPropPos)
319 : : {
320 [ # # ]: 0 : rtl::OUString aName = aUIProp[nPropPos].Name;
321 [ # # ]: 0 : if ( aName == "Property" )
322 : : {
323 : 0 : beans::PropertyValue aPropertyValue;
324 [ # # ][ # # ]: 0 : if ( aUIProp[nPropPos].Value >>= aPropertyValue )
[ # # ]
325 : : {
326 [ # # ]: 0 : if ( aPropertyValue.Name == "PrintContent" )
327 : : {
328 [ # # ]: 0 : aPropertyValue.Value <<= nContent;
329 [ # # ][ # # ]: 0 : aUIProp[nPropPos].Value <<= aPropertyValue;
330 : : }
331 [ # # ]: 0 : else if ( aPropertyValue.Name == "IsIncludeEmptyPages" )
332 : : {
333 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aPropertyValue.Value, ! bSuppress );
334 [ # # ][ # # ]: 0 : aUIProp[nPropPos].Value <<= aPropertyValue;
335 : : }
336 : 0 : }
337 : : }
338 : 0 : }
339 [ # # ][ # # ]: 0 : m_aUIProperties[nUIPos].Value <<= aUIProp;
340 : : }
341 [ # # ]: 0 : }
342 : 0 : }
343 : :
344 : 846 : void ScModelObj::CreateAndSet(ScDocShell* pDocSh)
345 : : {
346 [ + - ]: 846 : if (pDocSh)
347 [ + - ]: 846 : pDocSh->SetBaseModel( new ScModelObj(pDocSh) );
348 : 846 : }
349 : :
350 : 846 : ScModelObj::ScModelObj( ScDocShell* pDocSh ) :
351 : : SfxBaseModel( pDocSh ),
352 : : aPropSet( lcl_GetDocOptPropertyMap() ),
353 : : pDocShell( pDocSh ),
354 : : pPrintFuncCache( NULL ),
355 : : pPrinterOptions( NULL ),
356 [ + - ][ + - ]: 846 : maChangesListeners( m_aMutex )
[ + - ]
357 : : {
358 : : // pDocShell may be NULL if this is the base of a ScDocOptionsObj
359 [ + - ]: 846 : if ( pDocShell )
360 : : {
361 [ + - ]: 846 : pDocShell->GetDocument()->AddUnoObject(*this); // SfxModel is derived from SfxListener
362 : : }
363 : 846 : }
364 : :
365 [ + - ][ + - ]: 685 : ScModelObj::~ScModelObj()
366 : : {
367 [ - + ]: 685 : if (pDocShell)
368 [ # # ]: 0 : pDocShell->GetDocument()->RemoveUnoObject(*this);
369 : :
370 [ + + ]: 685 : if (xNumberAgg.is())
371 [ + - ][ + - ]: 157 : xNumberAgg->setDelegator(uno::Reference<uno::XInterface>());
372 : :
373 [ - + ][ # # ]: 685 : delete pPrintFuncCache;
374 [ - + ][ # # ]: 685 : delete pPrinterOptions;
375 [ - + ]: 1370 : }
376 : :
377 : 3168 : uno::Reference< uno::XAggregation> ScModelObj::GetFormatter()
378 : : {
379 : : // pDocShell may be NULL if this is the base of a ScDocOptionsObj
380 [ + + ][ + - ]: 3168 : if ( !xNumberAgg.is() && pDocShell )
[ + + ]
381 : : {
382 : : // setDelegator veraendert den RefCount, darum eine Referenz selber halten
383 : : // (direkt am m_refCount, um sich beim release nicht selbst zu loeschen)
384 [ + - ]: 177 : comphelper::increment( m_refCount );
385 : : // waehrend des queryInterface braucht man ein Ref auf das
386 : : // SvNumberFormatsSupplierObj, sonst wird es geloescht.
387 [ + - ][ + - ]: 177 : uno::Reference<util::XNumberFormatsSupplier> xFormatter(new SvNumberFormatsSupplierObj(pDocShell->GetDocument()->GetFormatTable() ));
[ + - ][ + - ]
388 : : {
389 [ + - ][ + - ]: 177 : xNumberAgg.set(uno::Reference<uno::XAggregation>( xFormatter, uno::UNO_QUERY ));
390 : : // extra block to force deletion of the temporary before setDelegator
391 : : }
392 : :
393 : : // beim setDelegator darf die zusaetzliche Ref nicht mehr existieren
394 [ + - ]: 177 : xFormatter = NULL;
395 : :
396 [ + - ]: 177 : if (xNumberAgg.is())
397 [ + - ][ + - ]: 177 : xNumberAgg->setDelegator( (cppu::OWeakObject*)this );
[ + - ]
398 [ + - ]: 177 : comphelper::decrement( m_refCount );
399 : : } // if ( !xNumberAgg.is() )
400 : 3168 : return xNumberAgg;
401 : : }
402 : :
403 : 627 : ScDocument* ScModelObj::GetDocument() const
404 : : {
405 [ + - ]: 627 : if (pDocShell)
406 : 627 : return pDocShell->GetDocument();
407 : 627 : return NULL;
408 : : }
409 : :
410 : 191 : SfxObjectShell* ScModelObj::GetEmbeddedObject() const
411 : : {
412 : 191 : return pDocShell;
413 : : }
414 : :
415 : 0 : void ScModelObj::UpdateAllRowHeights(const ScMarkData* pTabMark)
416 : : {
417 [ # # ]: 0 : if (pDocShell)
418 : 0 : pDocShell->UpdateAllRowHeights(pTabMark);
419 : 0 : }
420 : :
421 : 1 : void ScModelObj::BeforeXMLLoading()
422 : : {
423 [ + - ]: 1 : if (pDocShell)
424 : 1 : pDocShell->BeforeXMLLoading();
425 : 1 : }
426 : :
427 : 1 : void ScModelObj::AfterXMLLoading(sal_Bool bRet)
428 : : {
429 [ + - ]: 1 : if (pDocShell)
430 : 1 : pDocShell->AfterXMLLoading(bRet);
431 : 1 : }
432 : :
433 : 2047 : ScSheetSaveData* ScModelObj::GetSheetSaveData()
434 : : {
435 [ + - ]: 2047 : if (pDocShell)
436 : 2047 : return pDocShell->GetSheetSaveData();
437 : 2047 : return NULL;
438 : : }
439 : :
440 : 166 : void ScModelObj::RepaintRange( const ScRange& rRange )
441 : : {
442 [ + - ]: 166 : if (pDocShell)
443 [ + - ]: 166 : pDocShell->PostPaint( rRange, PAINT_GRID );
444 : 166 : }
445 : :
446 : 129906 : uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
447 : : throw(uno::RuntimeException)
448 : : {
449 [ + - ][ + + ]: 129906 : SC_QUERYINTERFACE( sheet::XSpreadsheetDocument )
[ + - ][ + - ]
450 [ + - ][ + + ]: 129222 : SC_QUERYINTERFACE( document::XActionLockable )
[ + - ][ + - ]
451 [ + - ][ + + ]: 128470 : SC_QUERYINTERFACE( sheet::XCalculatable )
[ + - ][ + - ]
452 [ + - ][ + + ]: 128421 : SC_QUERYINTERFACE( util::XProtectable )
[ + - ][ + - ]
453 [ + - ][ + + ]: 128420 : SC_QUERYINTERFACE( drawing::XDrawPagesSupplier )
[ + - ][ + - ]
454 [ + - ][ + + ]: 128408 : SC_QUERYINTERFACE( sheet::XGoalSeek )
[ + - ][ + - ]
455 [ + - ][ + + ]: 128407 : SC_QUERYINTERFACE( sheet::XConsolidatable )
[ + - ][ + - ]
456 [ + - ][ + + ]: 128405 : SC_QUERYINTERFACE( sheet::XDocumentAuditing )
[ + - ][ + - ]
457 [ + - ][ + + ]: 128404 : SC_QUERYINTERFACE( style::XStyleFamiliesSupplier )
[ + - ][ + - ]
458 [ + - ][ - + ]: 127754 : SC_QUERYINTERFACE( view::XRenderable )
[ # # ][ # # ]
459 [ + - ][ + + ]: 127754 : SC_QUERYINTERFACE( document::XLinkTargetSupplier )
[ + - ][ + - ]
460 [ + - ][ + + ]: 127753 : SC_QUERYINTERFACE( beans::XPropertySet )
[ + - ][ + - ]
461 [ + - ][ + + ]: 126186 : SC_QUERYINTERFACE( lang::XMultiServiceFactory )
[ + - ][ + - ]
462 [ + - ][ + + ]: 123697 : SC_QUERYINTERFACE( lang::XServiceInfo )
[ + - ][ + - ]
463 [ + - ][ + + ]: 122712 : SC_QUERYINTERFACE( util::XChangesNotifier )
[ + - ][ + - ]
464 : :
465 [ + - ]: 122708 : uno::Any aRet(SfxBaseModel::queryInterface( rType ));
466 [ + + + - : 180412 : if ( !aRet.hasValue()
+ + + + +
+ + + +
+ ][ + + ]
467 [ + - ]: 14994 : && rType != ::getCppuType((uno::Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0)
468 [ + - ]: 14994 : && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XController>*)0)
469 [ + - ]: 10469 : && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XFrame>*)0)
470 [ + - ]: 5944 : && rType != ::getCppuType((uno::Reference< com::sun::star::script::XInvocation>*)0)
471 [ + - ]: 5673 : && rType != ::getCppuType((uno::Reference< com::sun::star::beans::XFastPropertySet>*)0)
472 [ + - ]: 5630 : && rType != ::getCppuType((uno::Reference< com::sun::star::awt::XWindow>*)0))
473 : : {
474 [ + - ]: 2115 : GetFormatter();
475 [ + - ]: 2115 : if ( xNumberAgg.is() )
476 [ + - ][ + - ]: 2115 : aRet = xNumberAgg->queryAggregation( rType );
477 : : }
478 : :
479 : 129906 : return aRet;
480 : : }
481 : :
482 : 491645 : void SAL_CALL ScModelObj::acquire() throw()
483 : : {
484 : 491645 : SfxBaseModel::acquire();
485 : 491645 : }
486 : :
487 : 491433 : void SAL_CALL ScModelObj::release() throw()
488 : : {
489 : 491433 : SfxBaseModel::release();
490 : 491433 : }
491 : :
492 : 254 : uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeException)
493 : : {
494 [ + + ][ + - ]: 254 : static uno::Sequence<uno::Type> aTypes;
[ + - ][ # # ]
495 [ + + ]: 254 : if ( aTypes.getLength() == 0 )
496 : : {
497 [ + - ]: 43 : uno::Sequence<uno::Type> aParentTypes(SfxBaseModel::getTypes());
498 : 43 : long nParentLen = aParentTypes.getLength();
499 : 43 : const uno::Type* pParentPtr = aParentTypes.getConstArray();
500 : :
501 [ + - ]: 43 : uno::Sequence<uno::Type> aAggTypes;
502 [ + - ][ + - ]: 43 : if ( GetFormatter().is() )
503 : : {
504 [ + - ]: 43 : const uno::Type& rProvType = ::getCppuType((uno::Reference<lang::XTypeProvider>*) 0);
505 [ + - ][ + - ]: 43 : uno::Any aNumProv(xNumberAgg->queryAggregation(rProvType));
506 [ + - ]: 43 : if(aNumProv.getValueType() == rProvType)
507 : : {
508 : : uno::Reference<lang::XTypeProvider> xNumProv(
509 : 43 : *(uno::Reference<lang::XTypeProvider>*)aNumProv.getValue());
510 [ + - ][ + - ]: 43 : aAggTypes = xNumProv->getTypes();
[ + - ][ + - ]
511 : 43 : }
512 : : }
513 : 43 : long nAggLen = aAggTypes.getLength();
514 : 43 : const uno::Type* pAggPtr = aAggTypes.getConstArray();
515 : :
516 : 43 : const long nThisLen = 15;
517 [ + - ]: 43 : aTypes.realloc( nParentLen + nAggLen + nThisLen );
518 [ + - ]: 43 : uno::Type* pPtr = aTypes.getArray();
519 [ + - ]: 43 : pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetDocument>*)0);
520 [ + - ]: 43 : pPtr[nParentLen + 1] = getCppuType((const uno::Reference<document::XActionLockable>*)0);
521 [ + - ]: 43 : pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XCalculatable>*)0);
522 [ + - ]: 43 : pPtr[nParentLen + 3] = getCppuType((const uno::Reference<util::XProtectable>*)0);
523 [ + - ]: 43 : pPtr[nParentLen + 4] = getCppuType((const uno::Reference<drawing::XDrawPagesSupplier>*)0);
524 [ + - ]: 43 : pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XGoalSeek>*)0);
525 [ + - ]: 43 : pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XConsolidatable>*)0);
526 [ + - ]: 43 : pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XDocumentAuditing>*)0);
527 [ + - ]: 43 : pPtr[nParentLen + 8] = getCppuType((const uno::Reference<style::XStyleFamiliesSupplier>*)0);
528 [ + - ]: 43 : pPtr[nParentLen + 9] = getCppuType((const uno::Reference<view::XRenderable>*)0);
529 [ + - ]: 43 : pPtr[nParentLen +10] = getCppuType((const uno::Reference<document::XLinkTargetSupplier>*)0);
530 [ + - ]: 43 : pPtr[nParentLen +11] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
531 [ + - ]: 43 : pPtr[nParentLen +12] = getCppuType((const uno::Reference<lang::XMultiServiceFactory>*)0);
532 [ + - ]: 43 : pPtr[nParentLen +13] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
533 [ + - ]: 43 : pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XChangesNotifier>*)0);
534 : :
535 : : long i;
536 [ + + ]: 1505 : for (i=0; i<nParentLen; i++)
537 : 1462 : pPtr[i] = pParentPtr[i]; // parent types first
538 : :
539 [ + + ]: 258 : for (i=0; i<nAggLen; i++)
540 [ + - ][ + - ]: 258 : pPtr[nParentLen+nThisLen+i] = pAggPtr[i]; // aggregated types last
541 : : }
542 : 254 : return aTypes;
543 : : }
544 : :
545 : : namespace
546 : : {
547 : : class theScModelObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScModelObjImplementationId > {};
548 : : }
549 : :
550 : 254 : uno::Sequence<sal_Int8> SAL_CALL ScModelObj::getImplementationId()
551 : : throw(uno::RuntimeException)
552 : : {
553 : 254 : return theScModelObjImplementationId::get().getSeq();
554 : : }
555 : :
556 : 47178 : void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
557 : : {
558 : : // Not interested in reference update hints here
559 : :
560 [ + + ]: 47178 : if ( rHint.ISA( SfxSimpleHint ) )
561 : : {
562 : 29987 : sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
563 [ + + ]: 29987 : if ( nId == SFX_HINT_DYING )
564 : : {
565 : 695 : pDocShell = NULL; // has become invalid
566 [ + + ]: 695 : if (xNumberAgg.is())
567 : : {
568 : : SvNumberFormatsSupplierObj* pNumFmt =
569 : : SvNumberFormatsSupplierObj::getImplementation(
570 [ + - ]: 167 : uno::Reference<util::XNumberFormatsSupplier>(xNumberAgg, uno::UNO_QUERY) );
571 [ + - ]: 167 : if ( pNumFmt )
572 : 167 : pNumFmt->SetNumberFormatter( NULL );
573 : : }
574 : :
575 [ - + ]: 695 : DELETEZ( pPrintFuncCache ); // must be deleted because it has a pointer to the DocShell
576 : : }
577 [ + + ]: 29292 : else if ( nId == SFX_HINT_DATACHANGED )
578 : : {
579 : : // cached data for rendering become invalid when contents change
580 : : // (if a broadcast is added to SetDrawModified, is has to be tested here, too)
581 : :
582 [ - + ]: 17697 : DELETEZ( pPrintFuncCache );
583 : :
584 : : // handle "OnCalculate" sheet events (search also for VBA event handlers)
585 [ + - ]: 17697 : if ( pDocShell )
586 : : {
587 : 17697 : ScDocument* pDoc = pDocShell->GetDocument();
588 [ + + ]: 17697 : if ( pDoc->GetVbaEventProcessor().is() )
589 : : {
590 : : // If the VBA event processor is set, HasAnyCalcNotification is much faster than HasAnySheetEventScript
591 [ - + ][ # # ]: 54 : if ( pDoc->HasAnyCalcNotification() && pDoc->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ) )
[ - + ]
592 : 0 : HandleCalculateEvents();
593 : : }
594 : : else
595 : : {
596 [ - + ]: 17643 : if ( pDoc->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE ) )
597 : 0 : HandleCalculateEvents();
598 : : }
599 : : }
600 : : }
601 : : }
602 [ - + ]: 17191 : else if ( rHint.ISA( ScPointerChangedHint ) )
603 : : {
604 : 0 : sal_uInt16 nFlags = ((const ScPointerChangedHint&)rHint).GetFlags();
605 [ # # ]: 0 : if (nFlags & SC_POINTERCHANGED_NUMFMT)
606 : : {
607 : : // NumberFormatter-Pointer am Uno-Objekt neu setzen
608 : :
609 [ # # ]: 0 : if (GetFormatter().is())
610 : : {
611 : : SvNumberFormatsSupplierObj* pNumFmt =
612 : : SvNumberFormatsSupplierObj::getImplementation(
613 [ # # ]: 0 : uno::Reference<util::XNumberFormatsSupplier>(xNumberAgg, uno::UNO_QUERY) );
614 [ # # ][ # # ]: 0 : if ( pNumFmt && pDocShell )
615 : 0 : pNumFmt->SetNumberFormatter( pDocShell->GetDocument()->GetFormatTable() );
616 : : }
617 : : }
618 : : }
619 : :
620 : : // always call parent - SfxBaseModel might need to handle the same hints again
621 : 47178 : SfxBaseModel::Notify( rBC, rHint ); // SfxBaseModel is derived from SfxListener
622 : 47178 : }
623 : :
624 : : // XSpreadsheetDocument
625 : :
626 : 868 : uno::Reference<sheet::XSpreadsheets> SAL_CALL ScModelObj::getSheets() throw(uno::RuntimeException)
627 : : {
628 [ + - ]: 868 : SolarMutexGuard aGuard;
629 [ + - ]: 868 : if (pDocShell)
630 [ + - ][ + - ]: 868 : return new ScTableSheetsObj(pDocShell);
[ + - ]
631 [ # # ][ + - ]: 868 : return NULL;
632 : : }
633 : :
634 : : // XStyleFamiliesSupplier
635 : :
636 : 650 : uno::Reference<container::XNameAccess> SAL_CALL ScModelObj::getStyleFamilies()
637 : : throw(uno::RuntimeException)
638 : : {
639 [ + - ]: 650 : SolarMutexGuard aGuard;
640 [ + - ]: 650 : if (pDocShell)
641 [ + - ][ + - ]: 650 : return new ScStyleFamiliesObj(pDocShell);
[ + - ]
642 [ # # ][ + - ]: 650 : return NULL;
643 : : }
644 : :
645 : : // XRenderable
646 : :
647 : 0 : OutputDevice* lcl_GetRenderDevice( const uno::Sequence<beans::PropertyValue>& rOptions )
648 : : {
649 : 0 : OutputDevice* pRet = NULL;
650 : 0 : const beans::PropertyValue* pPropArray = rOptions.getConstArray();
651 : 0 : long nPropCount = rOptions.getLength();
652 [ # # ]: 0 : for (long i = 0; i < nPropCount; i++)
653 : : {
654 : 0 : const beans::PropertyValue& rProp = pPropArray[i];
655 [ # # ]: 0 : String aPropName(rProp.Name);
656 : :
657 [ # # ][ # # ]: 0 : if (aPropName.EqualsAscii( SC_UNONAME_RENDERDEV ))
658 : : {
659 [ # # ]: 0 : uno::Reference<awt::XDevice> xRenderDevice(rProp.Value, uno::UNO_QUERY);
660 [ # # ]: 0 : if ( xRenderDevice.is() )
661 : : {
662 : 0 : VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
663 [ # # ]: 0 : if ( pDevice )
664 : : {
665 : 0 : pRet = pDevice->GetOutputDevice();
666 [ # # ][ # # ]: 0 : pRet->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
[ # # ]
667 : : }
668 : 0 : }
669 : : }
670 [ # # ]: 0 : }
671 : 0 : return pRet;
672 : : }
673 : :
674 : 0 : bool lcl_ParseTarget( const String& rTarget, ScRange& rTargetRange, Rectangle& rTargetRect,
675 : : bool& rIsSheet, ScDocument* pDoc, SCTAB nSourceTab )
676 : : {
677 : : // test in same order as in SID_CURRENTCELL execute
678 : :
679 : 0 : ScAddress aAddress;
680 : 0 : ScRangeUtil aRangeUtil;
681 : : SCTAB nNameTab;
682 : 0 : sal_Int32 nNumeric = 0;
683 : :
684 : 0 : bool bRangeValid = false;
685 : 0 : bool bRectValid = false;
686 : :
687 [ # # ][ # # ]: 0 : if ( rTargetRange.Parse( rTarget, pDoc ) & SCA_VALID )
688 : : {
689 : 0 : bRangeValid = true; // range reference
690 : : }
691 [ # # ][ # # ]: 0 : else if ( aAddress.Parse( rTarget, pDoc ) & SCA_VALID )
692 : : {
693 : 0 : rTargetRange = aAddress;
694 : 0 : bRangeValid = true; // cell reference
695 : : }
696 [ # # ][ # # ]: 0 : else if ( aRangeUtil.MakeRangeFromName( rTarget, pDoc, nSourceTab, rTargetRange, RUTL_NAMES ) ||
[ # # ][ # # ]
697 [ # # ]: 0 : aRangeUtil.MakeRangeFromName( rTarget, pDoc, nSourceTab, rTargetRange, RUTL_DBASE ) )
698 : : {
699 : 0 : bRangeValid = true; // named range or database range
700 : : }
701 [ # # ][ # # ]: 0 : else if ( comphelper::string::isdigitAsciiString(rTarget) &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
702 : : ( nNumeric = rTarget.ToInt32() ) > 0 && nNumeric <= MAXROW+1 )
703 : : {
704 : : // row number is always mapped to cell A(row) on the same sheet
705 : 0 : rTargetRange = ScAddress( 0, (SCROW)(nNumeric-1), nSourceTab ); // target row number is 1-based
706 : 0 : bRangeValid = true; // row number
707 : : }
708 [ # # ][ # # ]: 0 : else if ( pDoc->GetTable( rTarget, nNameTab ) )
[ # # ]
709 : : {
710 : 0 : rTargetRange = ScAddress(0,0,nNameTab);
711 : 0 : bRangeValid = true; // sheet name
712 : 0 : rIsSheet = true; // needs special handling (first page of the sheet)
713 : : }
714 : : else
715 : : {
716 : : // look for named drawing object
717 : :
718 [ # # ]: 0 : ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
719 [ # # ]: 0 : if ( pDrawLayer )
720 : : {
721 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
722 [ # # ][ # # ]: 0 : for (SCTAB i=0; i<nTabCount && !bRangeValid; i++)
[ # # ]
723 : : {
724 [ # # ]: 0 : SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
725 : : OSL_ENSURE(pPage,"Page ?");
726 [ # # ]: 0 : if (pPage)
727 : : {
728 [ # # ]: 0 : SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
729 [ # # ]: 0 : SdrObject* pObject = aIter.Next();
730 [ # # ][ # # ]: 0 : while (pObject && !bRangeValid)
[ # # ]
731 : : {
732 [ # # ][ # # ]: 0 : if ( ScDrawLayer::GetVisibleName( pObject ) == rTarget )
[ # # ][ # # ]
733 : : {
734 [ # # ]: 0 : rTargetRect = pObject->GetLogicRect(); // 1/100th mm
735 [ # # ]: 0 : rTargetRange = pDoc->GetRange( i, rTargetRect ); // underlying cells
736 : 0 : bRangeValid = bRectValid = true; // rectangle is valid
737 : : }
738 [ # # ]: 0 : pObject = aIter.Next();
739 : 0 : }
740 : : }
741 : : }
742 : : }
743 : : }
744 [ # # ][ # # ]: 0 : if ( bRangeValid && !bRectValid )
745 : : {
746 : : // get rectangle for cell range
747 : 0 : rTargetRect = pDoc->GetMMRect( rTargetRange.aStart.Col(), rTargetRange.aStart.Row(),
748 : 0 : rTargetRange.aEnd.Col(), rTargetRange.aEnd.Row(),
749 [ # # ]: 0 : rTargetRange.aStart.Tab() );
750 : : }
751 : :
752 : 0 : return bRangeValid;
753 : : }
754 : :
755 : 0 : bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
756 : : const uno::Sequence< beans::PropertyValue >& rOptions,
757 : : ScMarkData& rMark,
758 : : ScPrintSelectionStatus& rStatus, String& rPagesStr ) const
759 : : {
760 : : OSL_ENSURE( !rMark.IsMarked() && !rMark.IsMultiMarked(), "FillRenderMarkData: MarkData must be empty" );
761 : : OSL_ENSURE( pDocShell, "FillRenderMarkData: DocShell must be set" );
762 : :
763 : 0 : bool bDone = false;
764 : :
765 : 0 : uno::Reference<frame::XController> xView;
766 : :
767 : : // defaults when no options are passed: all sheets, include empty pages
768 : 0 : sal_Bool bSelectedSheetsOnly = false;
769 : 0 : sal_Bool bIncludeEmptyPages = true;
770 : :
771 : 0 : bool bHasPrintContent = false;
772 : 0 : sal_Int32 nPrintContent = 0; // all sheets / selected sheets / selected cells
773 : 0 : sal_Int32 nPrintRange = 0; // all pages / pages
774 : 0 : rtl::OUString aPageRange; // "pages" edit value
775 : :
776 [ # # ]: 0 : for( sal_Int32 i = 0, nLen = rOptions.getLength(); i < nLen; i++ )
777 : : {
778 [ # # ]: 0 : if ( rOptions[i].Name == "IsOnlySelectedSheets" )
779 : : {
780 : 0 : rOptions[i].Value >>= bSelectedSheetsOnly;
781 : : }
782 [ # # ]: 0 : else if ( rOptions[i].Name == "IsIncludeEmptyPages" )
783 : : {
784 : 0 : rOptions[i].Value >>= bIncludeEmptyPages;
785 : : }
786 [ # # ]: 0 : else if ( rOptions[i].Name == "PageRange" )
787 : : {
788 : 0 : rOptions[i].Value >>= aPageRange;
789 : : }
790 [ # # ]: 0 : else if ( rOptions[i].Name == "PrintRange" )
791 : : {
792 : 0 : rOptions[i].Value >>= nPrintRange;
793 : : }
794 [ # # ]: 0 : else if ( rOptions[i].Name == "PrintContent" )
795 : : {
796 : 0 : bHasPrintContent = true;
797 : 0 : rOptions[i].Value >>= nPrintContent;
798 : : }
799 [ # # ]: 0 : else if ( rOptions[i].Name == "View" )
800 : : {
801 [ # # ]: 0 : rOptions[i].Value >>= xView;
802 : : }
803 : : }
804 : :
805 : : // "Print Content" selection wins over "Selected Sheets" option
806 [ # # ]: 0 : if ( bHasPrintContent )
807 : 0 : bSelectedSheetsOnly = ( nPrintContent != 0 );
808 : :
809 [ # # ]: 0 : uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
810 [ # # ]: 0 : if ( xInterface.is() )
811 : : {
812 [ # # ]: 0 : ScCellRangesBase* pSelObj = ScCellRangesBase::getImplementation( xInterface );
813 [ # # ]: 0 : uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY );
814 [ # # ][ # # ]: 0 : if ( pSelObj && pSelObj->GetDocShell() == pDocShell )
[ # # ]
815 : : {
816 [ # # ]: 0 : bool bSheet = ( ScTableSheetObj::getImplementation( xInterface ) != NULL );
817 : 0 : bool bCursor = pSelObj->IsCursorOnly();
818 : 0 : const ScRangeList& rRanges = pSelObj->GetRangeList();
819 : :
820 [ # # ]: 0 : rMark.MarkFromRangeList( rRanges, false );
821 [ # # ]: 0 : rMark.MarkToSimple();
822 : :
823 [ # # ]: 0 : if ( rMark.IsMultiMarked() )
824 : : {
825 : : // #i115266# copy behavior of old printing:
826 : : // treat multiple selection like a single selection with the enclosing range
827 : 0 : ScRange aMultiMarkArea;
828 [ # # ]: 0 : rMark.GetMultiMarkArea( aMultiMarkArea );
829 [ # # ]: 0 : rMark.ResetMark();
830 [ # # ]: 0 : rMark.SetMarkArea( aMultiMarkArea );
831 : : }
832 : :
833 [ # # ][ # # ]: 0 : if ( rMark.IsMarked() && !rMark.IsMultiMarked() )
[ # # ]
834 : : {
835 : : // a sheet object is treated like an empty selection: print the used area of the sheet
836 : :
837 [ # # ][ # # ]: 0 : if ( bCursor || bSheet ) // nothing selected -> use whole tables
838 : : {
839 [ # # ]: 0 : rMark.ResetMark(); // doesn't change table selection
840 : 0 : rStatus.SetMode( SC_PRINTSEL_CURSOR );
841 : : }
842 : : else
843 : 0 : rStatus.SetMode( SC_PRINTSEL_RANGE );
844 : :
845 [ # # ]: 0 : rStatus.SetRanges( rRanges );
846 : 0 : bDone = true;
847 : : }
848 : : // multi selection isn't supported
849 : : }
850 [ # # ]: 0 : else if( xShapes.is() )
851 : : {
852 : : //print a selected ole object
853 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY );
854 [ # # ]: 0 : if( xIndexAccess.is() )
855 : : {
856 : : // multi selection isn't supported yet
857 [ # # ][ # # ]: 0 : uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY );
[ # # ]
858 [ # # ]: 0 : SvxShape* pShape = SvxShape::getImplementation( xShape );
859 [ # # ]: 0 : if( pShape )
860 : : {
861 [ # # ]: 0 : SdrObject *pSdrObj = pShape->GetSdrObject();
862 [ # # ]: 0 : if( pDocShell )
863 : : {
864 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
865 [ # # ][ # # ]: 0 : if( pDoc && pSdrObj )
866 : : {
867 [ # # ]: 0 : Rectangle aObjRect = pSdrObj->GetCurrentBoundRect();
868 [ # # ]: 0 : SCTAB nCurrentTab = ScDocShell::GetCurTab();
869 [ # # ]: 0 : ScRange aRange = pDoc->GetRange( nCurrentTab, aObjRect );
870 [ # # ]: 0 : rMark.SetMarkArea( aRange );
871 : :
872 [ # # ][ # # ]: 0 : if( rMark.IsMarked() && !rMark.IsMultiMarked() )
[ # # ]
873 : : {
874 : 0 : rStatus.SetMode( SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
875 : 0 : bDone = true;
876 : : }
877 : : }
878 : : }
879 : 0 : }
880 : 0 : }
881 : : }
882 [ # # ][ # # ]: 0 : else if ( ScModelObj::getImplementation( xInterface ) == this )
883 : : {
884 : : // render the whole document
885 : : // -> no selection, all sheets
886 : :
887 [ # # ]: 0 : SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
888 [ # # ]: 0 : for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
889 [ # # ]: 0 : rMark.SelectTable( nTab, sal_True );
890 : 0 : rStatus.SetMode( SC_PRINTSEL_DOCUMENT );
891 : 0 : bDone = true;
892 : 0 : }
893 : : // other selection types aren't supported
894 : : }
895 : :
896 : : // restrict to selected sheets if a view is available
897 [ # # ]: 0 : uno::Reference<sheet::XSelectedSheetsSupplier> xSelectedSheets(xView, uno::UNO_QUERY);
898 [ # # ][ # # ]: 0 : if (bSelectedSheetsOnly && xSelectedSheets.is())
[ # # ]
899 : : {
900 [ # # ][ # # ]: 0 : uno::Sequence<sal_Int32> aSelected = xSelectedSheets->getSelectedSheets();
901 [ # # ]: 0 : ScMarkData::MarkedTabsType aSelectedTabs;
902 [ # # ]: 0 : SCTAB nMaxTab = pDocShell->GetDocument()->GetTableCount() -1;
903 [ # # ]: 0 : for (sal_Int32 i = 0, n = aSelected.getLength(); i < n; ++i)
904 : : {
905 [ # # ]: 0 : SCTAB nSelected = static_cast<SCTAB>(aSelected[i]);
906 [ # # ]: 0 : if (ValidTab(nSelected, nMaxTab))
907 [ # # ][ # # ]: 0 : aSelectedTabs.insert(static_cast<SCTAB>(aSelected[i]));
908 : : }
909 [ # # ][ # # ]: 0 : rMark.SetSelectedTabs(aSelectedTabs);
910 : : }
911 : :
912 [ # # ]: 0 : ScPrintOptions aNewOptions;
913 : 0 : aNewOptions.SetSkipEmpty( !bIncludeEmptyPages );
914 : 0 : aNewOptions.SetAllSheets( !bSelectedSheetsOnly );
915 [ # # ]: 0 : rStatus.SetOptions( aNewOptions );
916 : :
917 : : // "PrintRange" enables (1) or disables (0) the "PageRange" edit
918 [ # # ]: 0 : if ( nPrintRange == 1 )
919 [ # # ]: 0 : rPagesStr = aPageRange;
920 : : else
921 [ # # ]: 0 : rPagesStr.Erase();
922 : :
923 [ # # ]: 0 : return bDone;
924 : : }
925 : :
926 : :
927 : 0 : sal_Int32 SAL_CALL ScModelObj::getRendererCount( const uno::Any& aSelection,
928 : : const uno::Sequence<beans::PropertyValue>& rOptions )
929 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
930 : : {
931 [ # # ]: 0 : SolarMutexGuard aGuard;
932 [ # # ]: 0 : if (!pDocShell)
933 : : {
934 : : throw lang::DisposedException( ::rtl::OUString(),
935 [ # # ][ # # ]: 0 : static_cast< sheet::XSpreadsheetDocument* >(this) );
936 : : }
937 : :
938 [ # # ]: 0 : ScMarkData aMark;
939 [ # # ]: 0 : ScPrintSelectionStatus aStatus;
940 [ # # ]: 0 : String aPagesStr;
941 [ # # ][ # # ]: 0 : if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) )
942 : 0 : return 0;
943 : :
944 : : // The same ScPrintFuncCache object in pPrintFuncCache is used as long as
945 : : // the same selection is used (aStatus) and the document isn't changed
946 : : // (pPrintFuncCache is cleared in Notify handler)
947 : :
948 [ # # ][ # # ]: 0 : if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
[ # # ][ # # ]
949 : : {
950 [ # # ][ # # ]: 0 : delete pPrintFuncCache;
951 [ # # ][ # # ]: 0 : pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
952 : : }
953 : 0 : sal_Int32 nPages = pPrintFuncCache->GetPageCount();
954 : :
955 : 0 : sal_Int32 nSelectCount = nPages;
956 [ # # ]: 0 : if ( aPagesStr.Len() )
957 : : {
958 [ # # ][ # # ]: 0 : StringRangeEnumerator aRangeEnum( aPagesStr, 0, nPages-1 );
959 : 0 : nSelectCount = aRangeEnum.size();
960 : : }
961 [ # # ][ # # ]: 0 : return nSelectCount;
[ # # ][ # # ]
962 : : }
963 : :
964 : 0 : sal_Int32 lcl_GetRendererNum( sal_Int32 nSelRenderer, const String& rPagesStr, sal_Int32 nTotalPages )
965 : : {
966 [ # # ]: 0 : if ( !rPagesStr.Len() )
967 : 0 : return nSelRenderer;
968 : :
969 [ # # ][ # # ]: 0 : StringRangeEnumerator aRangeEnum( rPagesStr, 0, nTotalPages-1 );
970 [ # # ]: 0 : StringRangeEnumerator::Iterator aIter = aRangeEnum.begin();
971 [ # # ]: 0 : StringRangeEnumerator::Iterator aEnd = aRangeEnum.end();
972 [ # # ][ # # ]: 0 : for ( ; nSelRenderer > 0 && aIter != aEnd; --nSelRenderer )
[ # # ][ # # ]
973 [ # # ]: 0 : ++aIter;
974 : :
975 [ # # ]: 0 : return *aIter; // returns -1 if reached the end
976 : : }
977 : :
978 : 0 : uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 nSelRenderer,
979 : : const uno::Any& aSelection, const uno::Sequence<beans::PropertyValue>& rOptions )
980 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
981 : : {
982 [ # # ]: 0 : SolarMutexGuard aGuard;
983 [ # # ]: 0 : if (!pDocShell)
984 : : {
985 : : throw lang::DisposedException( ::rtl::OUString(),
986 [ # # ][ # # ]: 0 : static_cast< sheet::XSpreadsheetDocument* >(this) );
987 : : }
988 : :
989 [ # # ]: 0 : ScMarkData aMark;
990 [ # # ]: 0 : ScPrintSelectionStatus aStatus;
991 [ # # ]: 0 : String aPagesStr;
992 : : // #i115266# if FillRenderMarkData fails, keep nTotalPages at 0, but still handle getRenderer(0) below
993 : 0 : long nTotalPages = 0;
994 [ # # ][ # # ]: 0 : if ( FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) )
995 : : {
996 [ # # ][ # # ]: 0 : if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
[ # # ][ # # ]
997 : : {
998 [ # # ][ # # ]: 0 : delete pPrintFuncCache;
999 [ # # ][ # # ]: 0 : pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
1000 : : }
1001 : 0 : nTotalPages = pPrintFuncCache->GetPageCount();
1002 : : }
1003 [ # # ]: 0 : sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages );
1004 [ # # ]: 0 : if ( nRenderer < 0 )
1005 : : {
1006 [ # # ]: 0 : if ( nSelRenderer == 0 )
1007 : : {
1008 : : // getRenderer(0) is used to query the settings, so it must always return something
1009 : :
1010 : 0 : SCTAB nCurTab = 0; //! use current sheet from view?
1011 [ # # ][ # # ]: 0 : ScPrintFunc aDefaultFunc( pDocShell, pDocShell->GetPrinter(), nCurTab );
1012 : 0 : Size aTwips = aDefaultFunc.GetPageSize();
1013 : 0 : awt::Size aPageSize( TwipsToHMM( aTwips.Width() ), TwipsToHMM( aTwips.Height() ) );
1014 : :
1015 [ # # ]: 0 : uno::Sequence<beans::PropertyValue> aSequence(1);
1016 [ # # ]: 0 : beans::PropertyValue* pArray = aSequence.getArray();
1017 [ # # ]: 0 : pArray[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_PAGESIZE ));
1018 [ # # ]: 0 : pArray[0].Value <<= aPageSize;
1019 : :
1020 [ # # ]: 0 : if( ! pPrinterOptions )
1021 [ # # ][ # # ]: 0 : pPrinterOptions = new ScPrintUIOptions;
1022 : : else
1023 [ # # ]: 0 : pPrinterOptions->SetDefaults();
1024 [ # # ]: 0 : pPrinterOptions->appendPrintUIOptions( aSequence );
1025 [ # # ][ # # ]: 0 : return aSequence;
[ # # ]
1026 : : }
1027 : : else
1028 [ # # ]: 0 : throw lang::IllegalArgumentException();
1029 : : }
1030 : :
1031 : : // printer is used as device (just for page layout), draw view is not needed
1032 : :
1033 [ # # ]: 0 : SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer );
1034 : :
1035 : 0 : ScRange aRange;
1036 : 0 : const ScRange* pSelRange = NULL;
1037 [ # # ]: 0 : if ( aMark.IsMarked() )
1038 : : {
1039 [ # # ]: 0 : aMark.GetMarkArea( aRange );
1040 : 0 : pSelRange = &aRange;
1041 : : }
1042 : : ScPrintFunc aFunc( pDocShell, pDocShell->GetPrinter(), nTab,
1043 [ # # ][ # # ]: 0 : pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() );
[ # # ]
1044 [ # # ]: 0 : aFunc.SetRenderFlag( sal_True );
1045 : :
1046 : 0 : Range aPageRange( nRenderer+1, nRenderer+1 );
1047 [ # # ]: 0 : MultiSelection aPage( aPageRange );
1048 [ # # ]: 0 : aPage.SetTotalRange( Range(0,RANGE_MAX) );
1049 [ # # ]: 0 : aPage.Select( aPageRange );
1050 : :
1051 [ # # ]: 0 : long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab );
1052 [ # # ]: 0 : long nTabStart = pPrintFuncCache->GetTabStart( nTab );
1053 : :
1054 [ # # ]: 0 : (void)aFunc.DoPrint( aPage, nTabStart, nDisplayStart, false, NULL );
1055 : :
1056 : 0 : ScRange aCellRange;
1057 [ # # ]: 0 : sal_Bool bWasCellRange = aFunc.GetLastSourceRange( aCellRange );
1058 : 0 : Size aTwips = aFunc.GetPageSize();
1059 : 0 : awt::Size aPageSize( TwipsToHMM( aTwips.Width() ), TwipsToHMM( aTwips.Height() ) );
1060 : :
1061 [ # # ]: 0 : long nPropCount = bWasCellRange ? 3 : 2;
1062 [ # # ]: 0 : uno::Sequence<beans::PropertyValue> aSequence(nPropCount);
1063 [ # # ]: 0 : beans::PropertyValue* pArray = aSequence.getArray();
1064 [ # # ]: 0 : pArray[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_PAGESIZE ));
1065 [ # # ]: 0 : pArray[0].Value <<= aPageSize;
1066 : : // #i111158# all positions are relative to the whole page, including non-printable area
1067 [ # # ]: 0 : pArray[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_INC_NP_AREA ));
1068 [ # # ]: 0 : pArray[1].Value = uno::makeAny( sal_True );
1069 [ # # ]: 0 : if ( bWasCellRange )
1070 : : {
1071 : : table::CellRangeAddress aRangeAddress( nTab,
1072 : 0 : aCellRange.aStart.Col(), aCellRange.aStart.Row(),
1073 : 0 : aCellRange.aEnd.Col(), aCellRange.aEnd.Row() );
1074 [ # # ]: 0 : pArray[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SOURCERANGE ));
1075 [ # # ]: 0 : pArray[2].Value <<= aRangeAddress;
1076 : : }
1077 : :
1078 [ # # ]: 0 : if( ! pPrinterOptions )
1079 [ # # ][ # # ]: 0 : pPrinterOptions = new ScPrintUIOptions;
1080 : : else
1081 [ # # ]: 0 : pPrinterOptions->SetDefaults();
1082 [ # # ]: 0 : pPrinterOptions->appendPrintUIOptions( aSequence );
1083 [ # # ][ # # ]: 0 : return aSequence;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1084 : : }
1085 : :
1086 : 0 : void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelection,
1087 : : const uno::Sequence<beans::PropertyValue>& rOptions )
1088 : : throw(lang::IllegalArgumentException, uno::RuntimeException)
1089 : : {
1090 [ # # ]: 0 : SolarMutexGuard aGuard;
1091 [ # # ]: 0 : if (!pDocShell)
1092 : : {
1093 : : throw lang::DisposedException( ::rtl::OUString(),
1094 [ # # ][ # # ]: 0 : static_cast< sheet::XSpreadsheetDocument* >(this) );
1095 : : }
1096 : :
1097 [ # # ]: 0 : ScMarkData aMark;
1098 [ # # ]: 0 : ScPrintSelectionStatus aStatus;
1099 [ # # ]: 0 : String aPagesStr;
1100 [ # # ][ # # ]: 0 : if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) )
1101 [ # # ]: 0 : throw lang::IllegalArgumentException();
1102 : :
1103 [ # # ][ # # ]: 0 : if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
[ # # ][ # # ]
1104 : : {
1105 [ # # ][ # # ]: 0 : delete pPrintFuncCache;
1106 [ # # ][ # # ]: 0 : pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
1107 : : }
1108 : 0 : long nTotalPages = pPrintFuncCache->GetPageCount();
1109 [ # # ]: 0 : sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages );
1110 [ # # ]: 0 : if ( nRenderer < 0 )
1111 [ # # ]: 0 : throw lang::IllegalArgumentException();
1112 : :
1113 [ # # ]: 0 : OutputDevice* pDev = lcl_GetRenderDevice( rOptions );
1114 [ # # ]: 0 : if ( !pDev )
1115 [ # # ]: 0 : throw lang::IllegalArgumentException();
1116 : :
1117 [ # # ]: 0 : SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer );
1118 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1119 : :
1120 : 0 : FmFormView* pDrawView = NULL;
1121 [ # # ]: 0 : Rectangle aFull( 0, 0, LONG_MAX, LONG_MAX );
1122 : :
1123 : : // #114135#
1124 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
1125 : :
1126 [ # # ]: 0 : if( pModel )
1127 : : {
1128 [ # # ][ # # ]: 0 : pDrawView = new FmFormView( pModel, pDev );
1129 [ # # ][ # # ]: 0 : pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
1130 : 0 : pDrawView->SetPrintPreview( sal_True );
1131 : : }
1132 : :
1133 : 0 : ScRange aRange;
1134 : 0 : const ScRange* pSelRange = NULL;
1135 [ # # ]: 0 : if ( aMark.IsMarked() )
1136 : : {
1137 [ # # ]: 0 : aMark.GetMarkArea( aRange );
1138 : 0 : pSelRange = &aRange;
1139 : : }
1140 : :
1141 : : // to increase performance, ScPrintState might be used here for subsequent
1142 : : // pages of the same sheet
1143 : :
1144 [ # # ][ # # ]: 0 : ScPrintFunc aFunc( pDev, pDocShell, nTab, pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() );
1145 [ # # ]: 0 : aFunc.SetDrawView( pDrawView );
1146 [ # # ]: 0 : aFunc.SetRenderFlag( sal_True );
1147 [ # # ]: 0 : if( aStatus.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS )
1148 [ # # ]: 0 : aFunc.SetExclusivelyDrawOleAndDrawObjects();
1149 : :
1150 : 0 : Range aPageRange( nRenderer+1, nRenderer+1 );
1151 [ # # ]: 0 : MultiSelection aPage( aPageRange );
1152 [ # # ]: 0 : aPage.SetTotalRange( Range(0,RANGE_MAX) );
1153 [ # # ]: 0 : aPage.Select( aPageRange );
1154 : :
1155 [ # # ]: 0 : long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab );
1156 [ # # ]: 0 : long nTabStart = pPrintFuncCache->GetTabStart( nTab );
1157 : :
1158 [ # # ][ # # ]: 0 : vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() );
[ # # ][ # # ]
1159 [ # # ]: 0 : if ( nRenderer == nTabStart )
1160 : : {
1161 : : // first page of a sheet: add outline item for the sheet name
1162 : :
1163 [ # # ][ # # ]: 0 : if ( pPDFData && pPDFData->GetIsExportBookmarks() )
[ # # ][ # # ]
1164 : : {
1165 : : // the sheet starts at the top of the page
1166 [ # # ][ # # ]: 0 : Rectangle aArea( pDev->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
1167 [ # # ]: 0 : sal_Int32 nDestID = pPDFData->CreateDest( aArea );
1168 : 0 : rtl::OUString aTabName;
1169 [ # # ]: 0 : pDoc->GetName( nTab, aTabName );
1170 : 0 : sal_Int32 nParent = -1; // top-level
1171 [ # # ]: 0 : pPDFData->CreateOutlineItem( nParent, aTabName, nDestID );
1172 : : }
1173 : : // #i56629# add the named destination stuff
1174 [ # # ][ # # ]: 0 : if( pPDFData && pPDFData->GetIsExportNamedDestinations() )
[ # # ][ # # ]
1175 : : {
1176 [ # # ][ # # ]: 0 : Rectangle aArea( pDev->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
1177 : 0 : rtl::OUString aTabName;
1178 [ # # ]: 0 : pDoc->GetName( nTab, aTabName );
1179 : : //need the PDF page number here
1180 [ # # ][ # # ]: 0 : pPDFData->CreateNamedDest( aTabName, aArea );
[ # # ]
1181 : : }
1182 : : }
1183 : :
1184 [ # # ]: 0 : (void)aFunc.DoPrint( aPage, nTabStart, nDisplayStart, true, NULL );
1185 : :
1186 : : // resolve the hyperlinks for PDF export
1187 : :
1188 [ # # ]: 0 : if ( pPDFData )
1189 : : {
1190 : : // iterate over the hyperlinks that were output for this page
1191 : :
1192 [ # # ]: 0 : std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->GetBookmarks();
1193 : 0 : std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIter = rBookmarks.begin();
1194 : 0 : std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end();
1195 [ # # ][ # # ]: 0 : while ( aIter != aIEnd )
1196 : : {
1197 : 0 : rtl::OUString aBookmark = aIter->aBookmark;
1198 [ # # ]: 0 : if ( aBookmark.toChar() == (sal_Unicode) '#' )
1199 : : {
1200 : : // try to resolve internal link
1201 : :
1202 [ # # ]: 0 : String aTarget( aBookmark.copy( 1 ) );
1203 : :
1204 : 0 : ScRange aTargetRange;
1205 [ # # ]: 0 : Rectangle aTargetRect; // 1/100th mm
1206 : 0 : bool bIsSheet = false;
1207 [ # # ]: 0 : bool bValid = lcl_ParseTarget( aTarget, aTargetRange, aTargetRect, bIsSheet, pDoc, nTab );
1208 : :
1209 [ # # ]: 0 : if ( bValid )
1210 : : {
1211 : 0 : sal_Int32 nPage = -1;
1212 [ # # ]: 0 : Rectangle aArea;
1213 [ # # ]: 0 : if ( bIsSheet )
1214 : : {
1215 : : // Get first page for sheet (if nothing from that sheet is printed,
1216 : : // this page can show a different sheet)
1217 [ # # ]: 0 : nPage = pPrintFuncCache->GetTabStart( aTargetRange.aStart.Tab() );
1218 [ # # ][ # # ]: 0 : aArea = pDev->PixelToLogic( Rectangle( 0,0,0,0 ) );
1219 : : }
1220 : : else
1221 : : {
1222 [ # # ]: 0 : pPrintFuncCache->InitLocations( aMark, pDev ); // does nothing if already initialized
1223 : :
1224 [ # # ]: 0 : ScPrintPageLocation aLocation;
1225 [ # # ][ # # ]: 0 : if ( pPrintFuncCache->FindLocation( aTargetRange.aStart, aLocation ) )
1226 : : {
1227 : 0 : nPage = aLocation.nPage;
1228 : :
1229 : : // get the rectangle of the page's cell range in 1/100th mm
1230 : 0 : ScRange aLocRange = aLocation.aCellRange;
1231 : : Rectangle aLocationMM = pDoc->GetMMRect(
1232 : 0 : aLocRange.aStart.Col(), aLocRange.aStart.Row(),
1233 : 0 : aLocRange.aEnd.Col(), aLocRange.aEnd.Row(),
1234 [ # # ]: 0 : aLocRange.aStart.Tab() );
1235 : 0 : Rectangle aLocationPixel = aLocation.aRectangle;
1236 : :
1237 : : // Scale and move the target rectangle from aLocationMM to aLocationPixel,
1238 : : // to get the target rectangle in pixels.
1239 : :
1240 [ # # ][ # # ]: 0 : Fraction aScaleX( aLocationPixel.GetWidth(), aLocationMM.GetWidth() );
[ # # ]
1241 [ # # ][ # # ]: 0 : Fraction aScaleY( aLocationPixel.GetHeight(), aLocationMM.GetHeight() );
[ # # ]
1242 : :
1243 : 0 : long nX1 = aLocationPixel.Left() + (long)
1244 [ # # ][ # # ]: 0 : ( Fraction( aTargetRect.Left() - aLocationMM.Left(), 1 ) * aScaleX );
[ # # ]
1245 : 0 : long nX2 = aLocationPixel.Left() + (long)
1246 [ # # ][ # # ]: 0 : ( Fraction( aTargetRect.Right() - aLocationMM.Left(), 1 ) * aScaleX );
[ # # ]
1247 : 0 : long nY1 = aLocationPixel.Top() + (long)
1248 [ # # ][ # # ]: 0 : ( Fraction( aTargetRect.Top() - aLocationMM.Top(), 1 ) * aScaleY );
[ # # ]
1249 : 0 : long nY2 = aLocationPixel.Top() + (long)
1250 [ # # ][ # # ]: 0 : ( Fraction( aTargetRect.Bottom() - aLocationMM.Top(), 1 ) * aScaleY );
[ # # ]
1251 : :
1252 [ # # ]: 0 : if ( nX1 > aLocationPixel.Right() ) nX1 = aLocationPixel.Right();
1253 [ # # ]: 0 : if ( nX2 > aLocationPixel.Right() ) nX2 = aLocationPixel.Right();
1254 [ # # ]: 0 : if ( nY1 > aLocationPixel.Bottom() ) nY1 = aLocationPixel.Bottom();
1255 [ # # ]: 0 : if ( nY2 > aLocationPixel.Bottom() ) nY2 = aLocationPixel.Bottom();
1256 : :
1257 : : // The link target area is interpreted using the device's MapMode at
1258 : : // the time of the CreateDest call, so PixelToLogic can be used here,
1259 : : // regardless of the MapMode that is actually selected.
1260 : :
1261 [ # # ][ # # ]: 0 : aArea = pDev->PixelToLogic( Rectangle( nX1, nY1, nX2, nY2 ) );
1262 : : }
1263 : : }
1264 : :
1265 [ # # ]: 0 : if ( nPage >= 0 )
1266 [ # # ][ # # ]: 0 : pPDFData->SetLinkDest( aIter->nLinkId, pPDFData->CreateDest( aArea, nPage ) );
1267 [ # # ]: 0 : }
1268 : : }
1269 : : else
1270 : : {
1271 : : // external link, use as-is
1272 [ # # ]: 0 : pPDFData->SetLinkURL( aIter->nLinkId, aBookmark );
1273 : : }
1274 : 0 : ++aIter;
1275 : 0 : }
1276 : 0 : rBookmarks.clear();
1277 : : }
1278 : :
1279 [ # # ]: 0 : if ( pDrawView )
1280 [ # # ]: 0 : pDrawView->HideSdrPage();
1281 [ # # ][ # # ]: 0 : delete pDrawView;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1282 : 0 : }
1283 : :
1284 : : // XLinkTargetSupplier
1285 : :
1286 : 1 : uno::Reference<container::XNameAccess> SAL_CALL ScModelObj::getLinks() throw(uno::RuntimeException)
1287 : : {
1288 [ + - ]: 1 : SolarMutexGuard aGuard;
1289 [ + - ]: 1 : if (pDocShell)
1290 [ + - ][ + - ]: 1 : return new ScLinkTargetTypesObj(pDocShell);
[ + - ]
1291 [ # # ][ + - ]: 1 : return NULL;
1292 : : }
1293 : :
1294 : : // XActionLockable
1295 : :
1296 : 3 : sal_Bool SAL_CALL ScModelObj::isActionLocked() throw(uno::RuntimeException)
1297 : : {
1298 [ + - ]: 3 : SolarMutexGuard aGuard;
1299 : 3 : sal_Bool bLocked = false;
1300 [ + - ]: 3 : if (pDocShell)
1301 [ + - ]: 3 : bLocked = ( pDocShell->GetLockCount() != 0 );
1302 [ + - ]: 3 : return bLocked;
1303 : : }
1304 : :
1305 : 380 : void SAL_CALL ScModelObj::addActionLock() throw(uno::RuntimeException)
1306 : : {
1307 [ + - ]: 380 : SolarMutexGuard aGuard;
1308 [ + - ]: 380 : if (pDocShell)
1309 [ + - ][ + - ]: 380 : pDocShell->LockDocument();
1310 : 380 : }
1311 : :
1312 : 374 : void SAL_CALL ScModelObj::removeActionLock() throw(uno::RuntimeException)
1313 : : {
1314 [ + - ]: 374 : SolarMutexGuard aGuard;
1315 [ + - ]: 374 : if (pDocShell)
1316 [ + - ][ + - ]: 374 : pDocShell->UnlockDocument();
1317 : 374 : }
1318 : :
1319 : 1 : void SAL_CALL ScModelObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException)
1320 : : {
1321 [ + - ]: 1 : SolarMutexGuard aGuard;
1322 [ + - ]: 1 : if (pDocShell)
1323 [ + - ][ + - ]: 1 : pDocShell->SetLockCount(nLock);
1324 : 1 : }
1325 : :
1326 : 1 : sal_Int16 SAL_CALL ScModelObj::resetActionLocks() throw(uno::RuntimeException)
1327 : : {
1328 [ + - ]: 1 : SolarMutexGuard aGuard;
1329 : 1 : sal_uInt16 nRet = 0;
1330 [ + - ]: 1 : if (pDocShell)
1331 : : {
1332 [ + - ]: 1 : nRet = pDocShell->GetLockCount();
1333 [ + - ]: 1 : pDocShell->SetLockCount(0);
1334 : : }
1335 [ + - ]: 1 : return nRet;
1336 : : }
1337 : :
1338 : 25 : void SAL_CALL ScModelObj::lockControllers() throw (::com::sun::star::uno::RuntimeException)
1339 : : {
1340 [ + - ]: 25 : SolarMutexGuard aGuard;
1341 [ + - ]: 25 : SfxBaseModel::lockControllers();
1342 [ + - ]: 25 : if (pDocShell)
1343 [ + - ][ + - ]: 25 : pDocShell->LockPaint();
1344 : 25 : }
1345 : :
1346 : 29 : void SAL_CALL ScModelObj::unlockControllers() throw (::com::sun::star::uno::RuntimeException)
1347 : : {
1348 [ + - ]: 29 : SolarMutexGuard aGuard;
1349 [ + - ][ + + ]: 29 : if (hasControllersLocked())
1350 : : {
1351 [ + - ]: 25 : SfxBaseModel::unlockControllers();
1352 [ + - ]: 25 : if (pDocShell)
1353 [ + - ]: 25 : pDocShell->UnlockPaint();
1354 [ + - ]: 29 : }
1355 : 29 : }
1356 : :
1357 : : // XCalculate
1358 : :
1359 : 25 : void SAL_CALL ScModelObj::calculate() throw(uno::RuntimeException)
1360 : : {
1361 [ + - ]: 25 : SolarMutexGuard aGuard;
1362 [ + - ]: 25 : if (pDocShell)
1363 [ + - ]: 25 : pDocShell->DoRecalc(sal_True);
1364 : : else
1365 : : {
1366 : : OSL_FAIL("keine DocShell"); //! Exception oder so?
1367 [ + - ]: 25 : }
1368 : 25 : }
1369 : :
1370 : 2 : void SAL_CALL ScModelObj::calculateAll() throw(uno::RuntimeException)
1371 : : {
1372 [ + - ]: 2 : SolarMutexGuard aGuard;
1373 [ + - ]: 2 : if (pDocShell)
1374 [ + - ]: 2 : pDocShell->DoHardRecalc(sal_True);
1375 : : else
1376 : : {
1377 : : OSL_FAIL("keine DocShell"); //! Exception oder so?
1378 [ + - ]: 2 : }
1379 : 2 : }
1380 : :
1381 : 2 : sal_Bool SAL_CALL ScModelObj::isAutomaticCalculationEnabled() throw(uno::RuntimeException)
1382 : : {
1383 [ + - ]: 2 : SolarMutexGuard aGuard;
1384 [ + - ]: 2 : if (pDocShell)
1385 : 2 : return pDocShell->GetDocument()->GetAutoCalc();
1386 : :
1387 : : OSL_FAIL("keine DocShell"); //! Exception oder so?
1388 [ + - ]: 2 : return false;
1389 : : }
1390 : :
1391 : 27 : void SAL_CALL ScModelObj::enableAutomaticCalculation( sal_Bool bEnabledIn )
1392 : : throw(uno::RuntimeException)
1393 : : {
1394 : 27 : bool bEnabled(bEnabledIn);
1395 [ + - ]: 27 : SolarMutexGuard aGuard;
1396 [ + - ]: 27 : if (pDocShell)
1397 : : {
1398 : 27 : ScDocument* pDoc = pDocShell->GetDocument();
1399 [ + + ]: 27 : if ( pDoc->GetAutoCalc() != bEnabled )
1400 : : {
1401 [ + - ]: 2 : pDoc->SetAutoCalc( bEnabled );
1402 [ + - ]: 2 : pDocShell->SetDocumentModified();
1403 : : }
1404 : : }
1405 : : else
1406 : : {
1407 : : OSL_FAIL("keine DocShell"); //! Exception oder so?
1408 [ + - ]: 27 : }
1409 : 27 : }
1410 : :
1411 : : // XProtectable
1412 : :
1413 : 1 : void SAL_CALL ScModelObj::protect( const rtl::OUString& aPassword ) throw(uno::RuntimeException)
1414 : : {
1415 [ + - ]: 1 : SolarMutexGuard aGuard;
1416 : : // #i108245# if already protected, don't change anything
1417 [ + - ][ + - ]: 1 : if ( pDocShell && !pDocShell->GetDocument()->IsDocProtected() )
[ + - ][ + - ]
1418 : : {
1419 [ + - ]: 1 : String aString(aPassword);
1420 [ + - ][ + - ]: 1 : pDocShell->GetDocFunc().Protect( TABLEID_DOC, aString, sal_True );
1421 [ + - ]: 1 : }
1422 : 1 : }
1423 : :
1424 : 2 : void SAL_CALL ScModelObj::unprotect( const rtl::OUString& aPassword )
1425 : : throw(lang::IllegalArgumentException, uno::RuntimeException)
1426 : : {
1427 [ + - ]: 2 : SolarMutexGuard aGuard;
1428 [ + - ]: 2 : if (pDocShell)
1429 : : {
1430 [ + - ]: 2 : String aString(aPassword);
1431 [ + - ]: 2 : sal_Bool bDone = pDocShell->GetDocFunc().Unprotect( TABLEID_DOC, aString, sal_True );
1432 [ + + ]: 2 : if (!bDone)
1433 [ + - ][ + - ]: 2 : throw lang::IllegalArgumentException();
1434 [ + - ]: 2 : }
1435 : 1 : }
1436 : :
1437 : 3 : sal_Bool SAL_CALL ScModelObj::isProtected() throw(uno::RuntimeException)
1438 : : {
1439 [ + - ]: 3 : SolarMutexGuard aGuard;
1440 [ + - ]: 3 : if (pDocShell)
1441 [ + - ]: 3 : return pDocShell->GetDocument()->IsDocProtected();
1442 : :
1443 : : OSL_FAIL("keine DocShell"); //! Exception oder so?
1444 [ + - ]: 3 : return false;
1445 : : }
1446 : :
1447 : : // XDrawPagesSupplier
1448 : :
1449 : 14 : uno::Reference<drawing::XDrawPages> SAL_CALL ScModelObj::getDrawPages() throw(uno::RuntimeException)
1450 : : {
1451 [ + - ]: 14 : SolarMutexGuard aGuard;
1452 [ + - ]: 14 : if (pDocShell)
1453 [ + - ][ + - ]: 14 : return new ScDrawPagesObj(pDocShell);
[ + - ]
1454 : :
1455 : : OSL_FAIL("keine DocShell"); //! Exception oder so?
1456 [ # # ][ + - ]: 14 : return NULL;
1457 : : }
1458 : :
1459 : : // XGoalSeek
1460 : :
1461 : 3 : sheet::GoalResult SAL_CALL ScModelObj::seekGoal(
1462 : : const table::CellAddress& aFormulaPosition,
1463 : : const table::CellAddress& aVariablePosition,
1464 : : const ::rtl::OUString& aGoalValue )
1465 : : throw(uno::RuntimeException)
1466 : : {
1467 [ + - ]: 3 : SolarMutexGuard aGuard;
1468 : 3 : sheet::GoalResult aResult;
1469 : 3 : aResult.Divergence = DBL_MAX; // nichts gefunden
1470 [ + - ]: 3 : if (pDocShell)
1471 : : {
1472 [ + - ][ + - ]: 3 : WaitObject aWait( pDocShell->GetActiveDialogParent() );
1473 [ + - ]: 3 : String aGoalString(aGoalValue);
1474 : 3 : ScDocument* pDoc = pDocShell->GetDocument();
1475 : 3 : double fValue = 0.0;
1476 : : sal_Bool bFound = pDoc->Solver(
1477 : : (SCCOL)aFormulaPosition.Column, (SCROW)aFormulaPosition.Row, aFormulaPosition.Sheet,
1478 : : (SCCOL)aVariablePosition.Column, (SCROW)aVariablePosition.Row, aVariablePosition.Sheet,
1479 [ + - ][ + - ]: 3 : aGoalString, fValue );
1480 : 3 : aResult.Result = fValue;
1481 [ + + ]: 3 : if (bFound)
1482 [ + - ][ + - ]: 3 : aResult.Divergence = 0.0; //! das ist gelogen
1483 : : }
1484 [ + - ]: 3 : return aResult;
1485 : : }
1486 : :
1487 : : // XConsolidatable
1488 : :
1489 : 2 : uno::Reference<sheet::XConsolidationDescriptor> SAL_CALL ScModelObj::createConsolidationDescriptor(
1490 : : sal_Bool bEmpty ) throw(uno::RuntimeException)
1491 : : {
1492 [ + - ]: 2 : SolarMutexGuard aGuard;
1493 [ + - ]: 2 : ScConsolidationDescriptor* pNew = new ScConsolidationDescriptor;
1494 [ + - ][ - + ]: 2 : if ( pDocShell && !bEmpty )
1495 : : {
1496 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1497 : 0 : const ScConsolidateParam* pParam = pDoc->GetConsolidateDlgData();
1498 [ # # ]: 0 : if (pParam)
1499 [ # # ]: 0 : pNew->SetParam( *pParam );
1500 : : }
1501 [ + - ][ + - ]: 2 : return pNew;
[ + - ]
1502 : : }
1503 : :
1504 : 1 : void SAL_CALL ScModelObj::consolidate(
1505 : : const uno::Reference<sheet::XConsolidationDescriptor>& xDescriptor )
1506 : : throw(uno::RuntimeException)
1507 : : {
1508 [ + - ]: 1 : SolarMutexGuard aGuard;
1509 : : // das koennte theoretisch ein fremdes Objekt sein, also nur das
1510 : : // oeffentliche XConsolidationDescriptor Interface benutzen, um
1511 : : // die Daten in ein ScConsolidationDescriptor Objekt zu kopieren:
1512 : : //! wenn es schon ein ScConsolidationDescriptor ist, direkt per getImplementation?
1513 : :
1514 [ + - ]: 1 : ScConsolidationDescriptor aImpl;
1515 [ + - ][ + - ]: 1 : aImpl.setFunction( xDescriptor->getFunction() );
[ + - ]
1516 [ + - ][ + - ]: 1 : aImpl.setSources( xDescriptor->getSources() );
[ + - ][ + - ]
1517 [ + - ][ + - ]: 1 : aImpl.setStartOutputPosition( xDescriptor->getStartOutputPosition() );
[ + - ]
1518 [ + - ][ + - ]: 1 : aImpl.setUseColumnHeaders( xDescriptor->getUseColumnHeaders() );
[ + - ]
1519 [ + - ][ + - ]: 1 : aImpl.setUseRowHeaders( xDescriptor->getUseRowHeaders() );
[ + - ]
1520 [ + - ][ + - ]: 1 : aImpl.setInsertLinks( xDescriptor->getInsertLinks() );
[ + - ]
1521 : :
1522 [ + - ]: 1 : if (pDocShell)
1523 : : {
1524 : 1 : const ScConsolidateParam& rParam = aImpl.GetParam();
1525 [ + - ]: 1 : pDocShell->DoConsolidate( rParam, sal_True );
1526 [ + - ]: 1 : pDocShell->GetDocument()->SetConsolidateDlgData( &rParam );
1527 [ + - ][ + - ]: 1 : }
1528 : 1 : }
1529 : :
1530 : : // XDocumentAuditing
1531 : :
1532 : 1 : void SAL_CALL ScModelObj::refreshArrows() throw(uno::RuntimeException)
1533 : : {
1534 [ + - ]: 1 : SolarMutexGuard aGuard;
1535 [ + - ]: 1 : if (pDocShell)
1536 [ + - ][ + - ]: 1 : pDocShell->GetDocFunc().DetectiveRefresh();
1537 : 1 : }
1538 : :
1539 : : // XViewDataSupplier
1540 : 587 : uno::Reference< container::XIndexAccess > SAL_CALL ScModelObj::getViewData( )
1541 : : throw (uno::RuntimeException)
1542 : : {
1543 : 587 : uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() );
1544 : :
1545 [ + + ]: 587 : if( !xRet.is() )
1546 : : {
1547 [ + - ]: 199 : SolarMutexGuard aGuard;
1548 [ + - ][ - + ]: 199 : if (pDocShell && pDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
[ - + ]
1549 : : {
1550 [ # # ][ # # ]: 0 : xRet.set(uno::Reference < container::XIndexAccess >::query(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")))));
[ # # ][ # # ]
[ # # ][ # # ]
1551 : :
1552 [ # # ]: 0 : uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY );
1553 : : OSL_ENSURE( xCont.is(), "ScModelObj::getViewData() failed for OLE object" );
1554 [ # # ]: 0 : if( xCont.is() )
1555 : : {
1556 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aSeq;
1557 [ # # ]: 0 : aSeq.realloc(1);
1558 : 0 : rtl::OUString sName;
1559 [ # # ]: 0 : pDocShell->GetDocument()->GetName( pDocShell->GetDocument()->GetVisibleTab(), sName );
1560 : 0 : rtl::OUString sOUName(sName);
1561 [ # # ][ # # ]: 0 : aSeq[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE));
1562 [ # # ][ # # ]: 0 : aSeq[0].Value <<= sOUName;
1563 [ # # ][ # # ]: 0 : xCont->insertByIndex( 0, uno::makeAny( aSeq ) );
[ # # ][ # # ]
1564 : 0 : }
1565 [ + - ]: 199 : }
1566 : : }
1567 : :
1568 : 587 : return xRet;
1569 : : }
1570 : :
1571 : : // XPropertySet (Doc-Optionen)
1572 : : //! auch an der Applikation anbieten?
1573 : :
1574 : 799 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScModelObj::getPropertySetInfo()
1575 : : throw(uno::RuntimeException)
1576 : : {
1577 [ + - ]: 799 : SolarMutexGuard aGuard;
1578 : : static uno::Reference<beans::XPropertySetInfo> aRef(
1579 [ + + ][ + - ]: 799 : new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
[ + - ][ + - ]
[ + - ][ # # ]
1580 [ + - ]: 799 : return aRef;
1581 : : }
1582 : :
1583 : 1692 : void SAL_CALL ScModelObj::setPropertyValue(
1584 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
1585 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1586 : : lang::IllegalArgumentException, lang::WrappedTargetException,
1587 : : uno::RuntimeException)
1588 : : {
1589 [ + - ]: 1692 : SolarMutexGuard aGuard;
1590 [ + - ]: 1692 : String aString(aPropertyName);
1591 : :
1592 [ + - ]: 1692 : if (pDocShell)
1593 : : {
1594 : 1692 : ScDocument* pDoc = pDocShell->GetDocument();
1595 [ + - ]: 1692 : const ScDocOptions& rOldOpt = pDoc->GetDocOptions();
1596 [ + - ]: 1692 : ScDocOptions aNewOpt = rOldOpt;
1597 : : // Don't recalculate while loading XML, when the formula text is stored
1598 : : // Recalculation after loading is handled separately.
1599 : 1692 : bool bHardRecalc = !pDoc->IsImportingXML();
1600 : :
1601 [ + - ]: 1692 : sal_Bool bOpt = ScDocOptionsHelper::setPropertyValue( aNewOpt, aPropSet.getPropertyMap(), aPropertyName, aValue );
1602 [ + + ]: 1692 : if (bOpt)
1603 : : {
1604 : : // done...
1605 [ + - ][ + + ]: 2922 : if ( aString.EqualsAscii( SC_UNO_IGNORECASE ) ||
[ + + ][ + + ]
[ + + ]
1606 [ + - ]: 974 : aString.EqualsAscii( SC_UNONAME_REGEXP ) ||
1607 [ + - ]: 851 : aString.EqualsAscii( SC_UNO_LOOKUPLABELS ) )
1608 : 369 : bHardRecalc = false;
1609 : : }
1610 [ + - ][ + + ]: 595 : else if ( aString.EqualsAscii( SC_UNONAME_CLOCAL ) )
1611 : : {
1612 : 6 : lang::Locale aLocale;
1613 [ + - ][ + - ]: 6 : if ( aValue >>= aLocale )
1614 : : {
1615 : : LanguageType eLatin, eCjk, eCtl;
1616 [ + - ]: 6 : pDoc->GetLanguage( eLatin, eCjk, eCtl );
1617 [ + - ]: 6 : eLatin = ScUnoConversion::GetLanguage(aLocale);
1618 [ + - ]: 6 : pDoc->SetLanguage( eLatin, eCjk, eCtl );
1619 : 6 : }
1620 : : }
1621 [ + - ][ + + ]: 589 : else if ( aString.EqualsAscii( SC_UNO_CODENAME ) )
1622 : : {
1623 : 28 : rtl::OUString sCodeName;
1624 [ + - ]: 28 : if ( aValue >>= sCodeName )
1625 : 28 : pDoc->SetCodeName( sCodeName );
1626 : : }
1627 [ + - ][ + + ]: 561 : else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) )
1628 : : {
1629 : 6 : lang::Locale aLocale;
1630 [ + - ][ + - ]: 6 : if ( aValue >>= aLocale )
1631 : : {
1632 : : LanguageType eLatin, eCjk, eCtl;
1633 [ + - ]: 6 : pDoc->GetLanguage( eLatin, eCjk, eCtl );
1634 [ + - ]: 6 : eCjk = ScUnoConversion::GetLanguage(aLocale);
1635 [ + - ]: 6 : pDoc->SetLanguage( eLatin, eCjk, eCtl );
1636 : 6 : }
1637 : : }
1638 [ + - ][ + + ]: 555 : else if ( aString.EqualsAscii( SC_UNO_CTL_CLOCAL ) )
1639 : : {
1640 : 6 : lang::Locale aLocale;
1641 [ + - ][ + - ]: 6 : if ( aValue >>= aLocale )
1642 : : {
1643 : : LanguageType eLatin, eCjk, eCtl;
1644 [ + - ]: 6 : pDoc->GetLanguage( eLatin, eCjk, eCtl );
1645 [ + - ]: 6 : eCtl = ScUnoConversion::GetLanguage(aLocale);
1646 [ + - ]: 6 : pDoc->SetLanguage( eLatin, eCjk, eCtl );
1647 : 6 : }
1648 : : }
1649 [ + - ][ + + ]: 549 : else if ( aString.EqualsAscii( SC_UNO_APPLYFMDES ) )
1650 : : {
1651 : : // model is created if not there
1652 [ + - ]: 111 : ScDrawLayer* pModel = pDocShell->MakeDrawLayer();
1653 [ + - ][ + - ]: 111 : pModel->SetOpenInDesignMode( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1654 : :
1655 [ + - ]: 111 : SfxBindings* pBindings = pDocShell->GetViewBindings();
1656 [ + + ]: 111 : if (pBindings)
1657 [ + - ]: 5 : pBindings->Invalidate( SID_FM_OPEN_READONLY );
1658 : : }
1659 [ + - ][ + + ]: 438 : else if ( aString.EqualsAscii( SC_UNO_AUTOCONTFOC ) )
1660 : : {
1661 : : // model is created if not there
1662 [ + - ]: 32 : ScDrawLayer* pModel = pDocShell->MakeDrawLayer();
1663 [ + - ][ + - ]: 32 : pModel->SetAutoControlFocus( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1664 : :
1665 [ + - ]: 32 : SfxBindings* pBindings = pDocShell->GetViewBindings();
1666 [ + + ]: 32 : if (pBindings)
1667 [ + - ]: 5 : pBindings->Invalidate( SID_FM_AUTOCONTROLFOCUS );
1668 : : }
1669 [ + - ][ + + ]: 406 : else if ( aString.EqualsAscii( SC_UNO_ISLOADED ) )
1670 : : {
1671 [ + - ][ + - ]: 28 : pDocShell->SetEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1672 : : }
1673 [ + - ][ + + ]: 378 : else if ( aString.EqualsAscii( SC_UNO_ISUNDOENABLED ) )
1674 : : {
1675 [ + - ]: 52 : sal_Bool bUndoEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1676 [ + - ]: 52 : pDoc->EnableUndo( bUndoEnabled );
1677 [ + - ]: 52 : pDocShell->GetUndoManager()->SetMaxUndoActionCount(
1678 : : bUndoEnabled
1679 [ + + ][ + - ]: 78 : ? officecfg::Office::Common::Undo::Steps::get() : 0);
1680 : : }
1681 [ + - ][ + + ]: 326 : else if ( aString.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED ) )
1682 : : {
1683 : 52 : bool bOldAdjustHeightEnabled = pDoc->IsAdjustHeightEnabled();
1684 [ + - ]: 52 : bool bAdjustHeightEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue );
1685 [ + - ]: 52 : if( bOldAdjustHeightEnabled != bAdjustHeightEnabled )
1686 : 52 : pDoc->EnableAdjustHeight( bAdjustHeightEnabled );
1687 : : }
1688 [ + - ][ + + ]: 274 : else if ( aString.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED ) )
1689 : : {
1690 [ + - ]: 52 : pDoc->EnableExecuteLink( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1691 : : }
1692 [ + - ][ + + ]: 222 : else if ( aString.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED ) )
1693 : : {
1694 [ + - ]: 52 : pDoc->EnableChangeReadOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1695 : : }
1696 [ + - ][ + + ]: 170 : else if ( aString.EqualsAscii( "BuildId" ) )
1697 : : {
1698 : 97 : aValue >>= maBuildId;
1699 : : }
1700 [ + - ][ + + ]: 73 : else if ( aString.EqualsAscii( "SavedObject" ) ) // set from chart after saving
1701 : : {
1702 : 7 : rtl::OUString aObjName;
1703 : 7 : aValue >>= aObjName;
1704 [ + - ]: 7 : if ( !aObjName.isEmpty() )
1705 [ + - ]: 7 : pDoc->RestoreChartListener( aObjName );
1706 : : }
1707 : :
1708 [ + + ]: 1692 : if ( aNewOpt != rOldOpt )
1709 : : {
1710 [ + - ]: 156 : pDoc->SetDocOptions( aNewOpt );
1711 : : //! Recalc only for options that need it?
1712 [ + + ]: 156 : if ( bHardRecalc )
1713 [ + - ]: 56 : pDocShell->DoHardRecalc( sal_True );
1714 [ + - ]: 156 : pDocShell->SetDocumentModified();
1715 [ + - ]: 1692 : }
1716 [ + - ][ + - ]: 1692 : }
1717 : 1692 : }
1718 : :
1719 : 1407 : uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyName )
1720 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1721 : : uno::RuntimeException)
1722 : : {
1723 [ + - ]: 1407 : SolarMutexGuard aGuard;
1724 [ + - ]: 1407 : String aString(aPropertyName);
1725 : 1407 : uno::Any aRet;
1726 : :
1727 [ + - ]: 1407 : if (pDocShell)
1728 : : {
1729 : 1407 : ScDocument* pDoc = pDocShell->GetDocument();
1730 [ + - ]: 1407 : const ScDocOptions& rOpt = pDoc->GetDocOptions();
1731 [ + - ]: 1407 : aRet = ScDocOptionsHelper::getPropertyValue( rOpt, aPropSet.getPropertyMap(), aPropertyName );
1732 [ + + ]: 1407 : if ( aRet.hasValue() )
1733 : : {
1734 : : // done...
1735 : : }
1736 [ + - ][ + + ]: 1211 : else if ( aString.EqualsAscii( SC_UNONAME_CLOCAL ) )
1737 : : {
1738 : : LanguageType eLatin, eCjk, eCtl;
1739 [ + - ]: 14 : pDoc->GetLanguage( eLatin, eCjk, eCtl );
1740 : :
1741 : 14 : lang::Locale aLocale;
1742 [ + - ]: 14 : ScUnoConversion::FillLocale( aLocale, eLatin );
1743 [ + - ]: 14 : aRet <<= aLocale;
1744 : : }
1745 [ + - ][ + + ]: 1197 : else if ( aString.EqualsAscii( SC_UNO_CODENAME ) )
1746 : : {
1747 : 10 : rtl::OUString sCodeName = pDoc->GetCodeName();
1748 [ + - ]: 10 : aRet <<= sCodeName;
1749 : : }
1750 : :
1751 [ + - ][ + + ]: 1187 : else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) )
1752 : : {
1753 : : LanguageType eLatin, eCjk, eCtl;
1754 [ + - ]: 14 : pDoc->GetLanguage( eLatin, eCjk, eCtl );
1755 : :
1756 : 14 : lang::Locale aLocale;
1757 [ + - ]: 14 : ScUnoConversion::FillLocale( aLocale, eCjk );
1758 [ + - ]: 14 : aRet <<= aLocale;
1759 : : }
1760 [ + - ][ + + ]: 1173 : else if ( aString.EqualsAscii( SC_UNO_CTL_CLOCAL ) )
1761 : : {
1762 : : LanguageType eLatin, eCjk, eCtl;
1763 [ + - ]: 14 : pDoc->GetLanguage( eLatin, eCjk, eCtl );
1764 : :
1765 : 14 : lang::Locale aLocale;
1766 [ + - ]: 14 : ScUnoConversion::FillLocale( aLocale, eCtl );
1767 [ + - ]: 14 : aRet <<= aLocale;
1768 : : }
1769 [ + - ][ + + ]: 1159 : else if ( aString.EqualsAscii( SC_UNO_NAMEDRANGES ) )
1770 : : {
1771 [ + - ][ + - ]: 207 : aRet <<= uno::Reference<sheet::XNamedRanges>(new ScGlobalNamedRangesObj( pDocShell ));
[ + - ][ + - ]
1772 : : }
1773 [ + - ][ + + ]: 952 : else if ( aString.EqualsAscii( SC_UNO_DATABASERNG ) )
1774 : : {
1775 [ + - ][ + - ]: 23 : aRet <<= uno::Reference<sheet::XDatabaseRanges>(new ScDatabaseRangesObj( pDocShell ));
[ + - ][ + - ]
1776 : : }
1777 [ + - ][ - + ]: 929 : else if ( aString.EqualsAscii( SC_UNO_UNNAMEDDBRNG ) )
1778 : : {
1779 [ # # ][ # # ]: 0 : aRet <<= uno::Reference<sheet::XUnnamedDatabaseRanges>(new ScUnnamedDatabaseRangesObj(pDocShell));
[ # # ][ # # ]
1780 : : }
1781 [ + - ][ + + ]: 929 : else if ( aString.EqualsAscii( SC_UNO_COLLABELRNG ) )
1782 : : {
1783 [ + - ][ + - ]: 11 : aRet <<= uno::Reference<sheet::XLabelRanges>(new ScLabelRangesObj( pDocShell, sal_True ));
[ + - ][ + - ]
1784 : : }
1785 [ + - ][ + + ]: 918 : else if ( aString.EqualsAscii( SC_UNO_ROWLABELRNG ) )
1786 : : {
1787 [ + - ][ + - ]: 8 : aRet <<= uno::Reference<sheet::XLabelRanges>(new ScLabelRangesObj( pDocShell, false ));
[ + - ][ + - ]
1788 : : }
1789 [ + - ][ + + ]: 910 : else if ( aString.EqualsAscii( SC_UNO_AREALINKS ) )
1790 : : {
1791 [ + - ][ + - ]: 11 : aRet <<= uno::Reference<sheet::XAreaLinks>(new ScAreaLinksObj( pDocShell ));
[ + - ][ + - ]
1792 : : }
1793 [ + - ][ + + ]: 899 : else if ( aString.EqualsAscii( SC_UNO_DDELINKS ) )
1794 : : {
1795 [ + - ][ + - ]: 11 : aRet <<= uno::Reference<container::XNameAccess>(new ScDDELinksObj( pDocShell ));
[ + - ][ + - ]
1796 : : }
1797 [ + - ][ + + ]: 888 : else if ( aString.EqualsAscii( SC_UNO_EXTERNALDOCLINKS ) )
1798 : : {
1799 [ + - ][ + - ]: 2 : aRet <<= uno::Reference<sheet::XExternalDocLinks>(new ScExternalDocLinksObj(pDocShell));
[ + - ][ + - ]
1800 : : }
1801 [ + - ][ + + ]: 886 : else if ( aString.EqualsAscii( SC_UNO_SHEETLINKS ) )
1802 : : {
1803 [ + - ][ + - ]: 6 : aRet <<= uno::Reference<container::XNameAccess>(new ScSheetLinksObj( pDocShell ));
[ + - ][ + - ]
1804 : : }
1805 [ + - ][ + + ]: 880 : else if ( aString.EqualsAscii( SC_UNO_APPLYFMDES ) )
1806 : : {
1807 : : // default for no model is TRUE
1808 [ + - ]: 12 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
1809 [ + - ]: 12 : sal_Bool bOpenInDesign = pModel ? pModel->GetOpenInDesignMode() : sal_True;
1810 [ + - ]: 12 : ScUnoHelpFunctions::SetBoolInAny( aRet, bOpenInDesign );
1811 : : }
1812 [ + - ][ + + ]: 868 : else if ( aString.EqualsAscii( SC_UNO_AUTOCONTFOC ) )
1813 : : {
1814 : : // default for no model is FALSE
1815 [ + - ]: 12 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
1816 [ + - ]: 12 : sal_Bool bAutoControlFocus = pModel ? pModel->GetAutoControlFocus() : false;
1817 [ + - ]: 12 : ScUnoHelpFunctions::SetBoolInAny( aRet, bAutoControlFocus );
1818 : : }
1819 [ + - ][ + + ]: 856 : else if ( aString.EqualsAscii( SC_UNO_FORBIDDEN ) )
1820 : : {
1821 [ + - ][ + - ]: 4 : aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell ));
[ + - ][ + - ]
1822 : : }
1823 [ + - ][ + + ]: 852 : else if ( aString.EqualsAscii( SC_UNO_HASDRAWPAGES ) )
1824 : : {
1825 [ + - ][ + - ]: 4 : ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetDocument()->GetDrawLayer() != 0) );
1826 : : }
1827 [ + - ][ + + ]: 848 : else if ( aString.EqualsAscii( SC_UNO_BASICLIBRARIES ) )
1828 : : {
1829 [ + - ][ + - ]: 37 : aRet <<= pDocShell->GetBasicContainer();
1830 : : }
1831 [ + - ][ - + ]: 811 : else if ( aString.EqualsAscii( SC_UNO_DIALOGLIBRARIES ) )
1832 : : {
1833 [ # # ][ # # ]: 0 : aRet <<= pDocShell->GetDialogContainer();
1834 : : }
1835 [ + - ][ - + ]: 811 : else if ( aString.EqualsAscii( SC_UNO_VBADOCOBJ ) )
1836 : : {
1837 : : // PropertyValue seems extreme because we store
1838 : : // the model ( as the value member ) of the PropertyValue that is
1839 : : // itself a property of the model ( the intention however is to
1840 : : // store something like a Workbook object... but we don't do that )
1841 : : // yet
1842 : 0 : beans::PropertyValue aProp;
1843 [ # # ]: 0 : aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") );
1844 [ # # ][ # # ]: 0 : aProp.Value <<= pDocShell->GetModel();
1845 [ # # ]: 0 : aRet <<= aProp;
1846 : : }
1847 [ + - ][ + + ]: 811 : else if ( aString.EqualsAscii( SC_UNO_RUNTIMEUID ) )
1848 : : {
1849 [ + - ][ + - ]: 68 : aRet <<= getRuntimeUID();
1850 : : }
1851 [ + - ][ - + ]: 743 : else if ( aString.EqualsAscii( SC_UNO_HASVALIDSIGNATURES ) )
1852 : : {
1853 [ # # ][ # # ]: 0 : aRet <<= hasValidSignatures();
1854 : : }
1855 [ + - ][ + + ]: 743 : else if ( aString.EqualsAscii( SC_UNO_ISLOADED ) )
1856 : : {
1857 [ + - ][ + - ]: 10 : ScUnoHelpFunctions::SetBoolInAny( aRet, !pDocShell->IsEmpty() );
1858 : : }
1859 [ + - ][ + + ]: 733 : else if ( aString.EqualsAscii( SC_UNO_ISUNDOENABLED ) )
1860 : : {
1861 [ + - ]: 10 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsUndoEnabled() );
1862 : : }
1863 [ + - ][ + + ]: 723 : else if ( aString.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED ) )
1864 : : {
1865 [ + - ]: 10 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsAdjustHeightEnabled() );
1866 : : }
1867 [ + - ][ + + ]: 713 : else if ( aString.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED ) )
1868 : : {
1869 [ + - ]: 10 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsExecuteLinkEnabled() );
1870 : : }
1871 [ + - ][ + + ]: 703 : else if ( aString.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED ) )
1872 : : {
1873 [ + - ]: 10 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsChangeReadOnlyEnabled() );
1874 : : }
1875 [ + - ][ + + ]: 693 : else if ( aString.EqualsAscii( SC_UNO_REFERENCEDEVICE ) )
1876 : : {
1877 [ + - ]: 237 : VCLXDevice* pXDev = new VCLXDevice();
1878 [ + - ]: 237 : pXDev->SetOutputDevice( pDoc->GetRefDevice() );
1879 [ + - ][ + - ]: 237 : aRet <<= uno::Reference< awt::XDevice >( pXDev );
1880 : : }
1881 [ + - ][ + + ]: 456 : else if ( aString.EqualsAscii( "BuildId" ) )
1882 : : {
1883 [ + - ]: 10 : aRet <<= maBuildId;
1884 : : }
1885 [ + - ][ - + ]: 446 : else if ( aString.EqualsAscii( "InternalDocument" ) )
1886 : : {
1887 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL) );
1888 : : }
1889 : : }
1890 : :
1891 [ + - ][ + - ]: 1407 : return aRet;
1892 : : }
1893 : :
1894 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScModelObj )
1895 : :
1896 : : // XMultiServiceFactory
1897 : :
1898 : 2810 : uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance(
1899 : : const rtl::OUString& aServiceSpecifier )
1900 : : throw(uno::Exception, uno::RuntimeException)
1901 : : {
1902 [ + - ]: 2810 : SolarMutexGuard aGuard;
1903 : 2810 : uno::Reference<uno::XInterface> xRet;
1904 [ + - ]: 2810 : String aNameStr(aServiceSpecifier);
1905 [ + - ]: 2810 : sal_uInt16 nType = ScServiceProvider::GetProviderType(aNameStr);
1906 [ + + ]: 2810 : if ( nType != SC_SERVICE_INVALID )
1907 : : {
1908 : : // drawing layer tables must be kept as long as the model is alive
1909 : : // return stored instance if already set
1910 [ + + + + : 2585 : switch ( nType )
+ + + +
+ ]
1911 : : {
1912 [ + - ]: 5 : case SC_SERVICE_GRADTAB: xRet.set(xDrawGradTab); break;
1913 [ + - ]: 5 : case SC_SERVICE_HATCHTAB: xRet.set(xDrawHatchTab); break;
1914 [ + - ]: 5 : case SC_SERVICE_BITMAPTAB: xRet.set(xDrawBitmapTab); break;
1915 [ + - ]: 6 : case SC_SERVICE_TRGRADTAB: xRet.set(xDrawTrGradTab); break;
1916 [ + - ]: 16 : case SC_SERVICE_MARKERTAB: xRet.set(xDrawMarkerTab); break;
1917 [ + - ]: 5 : case SC_SERVICE_DASHTAB: xRet.set(xDrawDashTab); break;
1918 [ + - ]: 7 : case SC_SERVICE_CHDATAPROV: xRet.set(xChartDataProv); break;
1919 [ + - ]: 14 : case SC_SERVICE_VBAOBJECTPROVIDER: xRet.set(xObjProvider); break;
1920 : : }
1921 : :
1922 : : // #i64497# If a chart is in a temporary document during clipoard paste,
1923 : : // there should be no data provider, so that own data is used
1924 : : bool bCreate =
1925 : : ! ( nType == SC_SERVICE_CHDATAPROV &&
1926 [ + + ][ + - ]: 2585 : ( pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL ));
1927 : : // this should never happen, i.e. the temporary document should never be
1928 : : // loaded, becuase this unlinks the data
1929 : : OSL_ASSERT( bCreate );
1930 : :
1931 [ + + ][ + - ]: 2585 : if ( !xRet.is() && bCreate )
[ + + ]
1932 : : {
1933 [ + + ][ + - ]: 2570 : xRet.set(ScServiceProvider::MakeInstance( nType, pDocShell ));
1934 : :
1935 : : // store created instance
1936 [ + + + + : 2552 : switch ( nType )
+ + + +
+ ]
1937 : : {
1938 [ + - ]: 3 : case SC_SERVICE_GRADTAB: xDrawGradTab.set(xRet); break;
1939 [ + - ]: 3 : case SC_SERVICE_HATCHTAB: xDrawHatchTab.set(xRet); break;
1940 [ + - ]: 3 : case SC_SERVICE_BITMAPTAB: xDrawBitmapTab.set(xRet); break;
1941 [ + - ]: 4 : case SC_SERVICE_TRGRADTAB: xDrawTrGradTab.set(xRet); break;
1942 [ + - ]: 14 : case SC_SERVICE_MARKERTAB: xDrawMarkerTab.set(xRet); break;
1943 [ + - ]: 3 : case SC_SERVICE_DASHTAB: xDrawDashTab.set(xRet); break;
1944 [ + - ]: 4 : case SC_SERVICE_CHDATAPROV: xChartDataProv.set(xRet); break;
1945 [ + - ]: 2552 : case SC_SERVICE_VBAOBJECTPROVIDER: xObjProvider.set(xRet); break;
1946 : : }
1947 : : }
1948 : : }
1949 : : else
1950 : : {
1951 : : // alles was ich nicht kenn, werf ich der SvxFmMSFactory an den Hals,
1952 : : // da wird dann 'ne Exception geworfen, wenn's nicht passt...
1953 : :
1954 : : try
1955 : : {
1956 [ + + ][ + - ]: 225 : xRet.set(SvxFmMSFactory::createInstance(aServiceSpecifier));
[ - + ]
1957 : : // extra block to force deletion of the temporary before ScShapeObj ctor (setDelegator)
1958 : : }
1959 [ + - ]: 26 : catch ( lang::ServiceNotRegisteredException & )
1960 : : {
1961 : : }
1962 : :
1963 : : // if the drawing factory created a shape, a ScShapeObj has to be used
1964 : : // to support own properties like ImageMap:
1965 : :
1966 [ + - ]: 225 : uno::Reference<drawing::XShape> xShape( xRet, uno::UNO_QUERY );
1967 [ + + ]: 225 : if ( xShape.is() )
1968 : : {
1969 : 152 : xRet.clear(); // for aggregation, xShape must be the object's only ref
1970 [ + - ]: 152 : new ScShapeObj( xShape ); // aggregates object and modifies xShape
1971 [ + - ]: 152 : xRet.set(xShape);
1972 : 225 : }
1973 : : }
1974 [ + - ][ + - ]: 2810 : return xRet;
1975 : : }
1976 : :
1977 : 12 : uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstanceWithArguments(
1978 : : const rtl::OUString& ServiceSpecifier,
1979 : : const uno::Sequence<uno::Any>& aArgs )
1980 : : throw(uno::Exception, uno::RuntimeException)
1981 : : {
1982 : : //! unterscheiden zwischen eigenen Services und denen vom Drawing-Layer?
1983 : :
1984 [ + - ]: 12 : SolarMutexGuard aGuard;
1985 [ + - ]: 12 : uno::Reference<uno::XInterface> xInt(createInstance(ServiceSpecifier));
1986 : :
1987 [ + - ]: 12 : if ( aArgs.getLength() )
1988 : : {
1989 : : // used only for cell value binding so far - it can be initialized after creating
1990 : :
1991 [ + - ]: 12 : uno::Reference<lang::XInitialization> xInit( xInt, uno::UNO_QUERY );
1992 [ + - ]: 12 : if ( xInit.is() )
1993 [ + - ][ + - ]: 12 : xInit->initialize( aArgs );
1994 : : }
1995 : :
1996 [ + - ]: 12 : return xInt;
1997 : : }
1998 : :
1999 : 10 : uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getAvailableServiceNames()
2000 : : throw(uno::RuntimeException)
2001 : : {
2002 [ + - ]: 10 : SolarMutexGuard aGuard;
2003 : :
2004 : : //! warum sind die Parameter bei concatServiceNames nicht const ???
2005 : : //! return concatServiceNames( ScServiceProvider::GetAllServiceNames(),
2006 : : //! SvxFmMSFactory::getAvailableServiceNames() );
2007 : :
2008 [ + - ]: 10 : uno::Sequence<rtl::OUString> aMyServices(ScServiceProvider::GetAllServiceNames());
2009 [ + - ]: 10 : uno::Sequence<rtl::OUString> aDrawServices(SvxFmMSFactory::getAvailableServiceNames());
2010 : :
2011 [ + - ][ + - ]: 10 : return concatServiceNames( aMyServices, aDrawServices );
[ + - ]
2012 : : }
2013 : :
2014 : : // XServiceInfo
2015 : :
2016 : 0 : rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException)
2017 : : {
2018 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ScModelObj" ));
2019 : : }
2020 : :
2021 : 952 : sal_Bool SAL_CALL ScModelObj::supportsService( const rtl::OUString& rServiceName )
2022 : : throw(uno::RuntimeException)
2023 : : {
2024 [ + - ]: 952 : String aServiceStr(rServiceName);
2025 [ + - ]: 952 : return aServiceStr.EqualsAscii( SCMODELOBJ_SERVICE ) ||
2026 [ + - ]: 738 : aServiceStr.EqualsAscii( SCDOCSETTINGS_SERVICE ) ||
2027 [ + + ][ + + ]: 1690 : aServiceStr.EqualsAscii( SCDOC_SERVICE );
[ + - ][ + + ]
[ + - ]
2028 : : }
2029 : :
2030 : 270 : uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getSupportedServiceNames()
2031 : : throw(uno::RuntimeException)
2032 : : {
2033 : 270 : uno::Sequence<rtl::OUString> aRet(2);
2034 [ + - ]: 270 : rtl::OUString* pArray = aRet.getArray();
2035 [ + - ]: 270 : pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCMODELOBJ_SERVICE ));
2036 [ + - ]: 270 : pArray[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCDOCSETTINGS_SERVICE ));
2037 : 270 : return aRet;
2038 : : }
2039 : :
2040 : : // XUnoTunnel
2041 : :
2042 : 20817 : sal_Int64 SAL_CALL ScModelObj::getSomething(
2043 : : const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
2044 : : {
2045 [ + - + + ]: 41634 : if ( rId.getLength() == 16 &&
[ + + ]
2046 : 20817 : 0 == memcmp( getUnoTunnelId().getConstArray(),
2047 : 20817 : rId.getConstArray(), 16 ) )
2048 : : {
2049 : 3028 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2050 : : }
2051 : :
2052 [ + - + + ]: 35578 : if ( rId.getLength() == 16 &&
[ + + ]
2053 : 17789 : 0 == memcmp( SfxObjectShell::getUnoTunnelId().getConstArray(),
2054 : 17789 : rId.getConstArray(), 16 ) )
2055 : : {
2056 : 13 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
2057 : : }
2058 : :
2059 : : // aggregated number formats supplier has XUnoTunnel, too
2060 : : // interface from aggregated object must be obtained via queryAggregation
2061 : :
2062 : 17776 : sal_Int64 nRet = SfxBaseModel::getSomething( rId );
2063 [ + + ]: 17776 : if ( nRet )
2064 : 16766 : return nRet;
2065 : :
2066 [ + - ]: 1010 : if ( GetFormatter().is() )
2067 : : {
2068 [ + - ]: 1010 : const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*) 0);
2069 [ + - ][ + - ]: 1010 : uno::Any aNumTunnel(xNumberAgg->queryAggregation(rTunnelType));
2070 [ + - ]: 1010 : if(aNumTunnel.getValueType() == rTunnelType)
2071 : : {
2072 : : uno::Reference<lang::XUnoTunnel> xTunnelAgg(
2073 : 1010 : *(uno::Reference<lang::XUnoTunnel>*)aNumTunnel.getValue());
2074 [ + - ][ + - ]: 1010 : return xTunnelAgg->getSomething( rId );
2075 [ - + ]: 1010 : }
2076 : : }
2077 : :
2078 : 20817 : return 0;
2079 : : }
2080 : :
2081 : : namespace
2082 : : {
2083 : : class theScModelObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScModelObjUnoTunnelId> {};
2084 : : }
2085 : :
2086 : 23845 : const uno::Sequence<sal_Int8>& ScModelObj::getUnoTunnelId()
2087 : : {
2088 : 23845 : return theScModelObjUnoTunnelId::get().getSeq();
2089 : : }
2090 : :
2091 : 3028 : ScModelObj* ScModelObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
2092 : : {
2093 : 3028 : ScModelObj* pRet = NULL;
2094 [ + - ]: 3028 : uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
2095 [ + - ]: 3028 : if (xUT.is())
2096 [ + - ][ + - ]: 3028 : pRet = reinterpret_cast<ScModelObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
[ + - ]
2097 : 3028 : return pRet;
2098 : : }
2099 : :
2100 : : // XChangesNotifier
2101 : :
2102 : 4 : void ScModelObj::addChangesListener( const uno::Reference< util::XChangesListener >& aListener )
2103 : : throw (uno::RuntimeException)
2104 : : {
2105 [ + - ]: 4 : SolarMutexGuard aGuard;
2106 [ + - ][ + - ]: 4 : maChangesListeners.addInterface( aListener );
2107 : 4 : }
2108 : :
2109 : 0 : void ScModelObj::removeChangesListener( const uno::Reference< util::XChangesListener >& aListener )
2110 : : throw (uno::RuntimeException)
2111 : : {
2112 [ # # ]: 0 : SolarMutexGuard aGuard;
2113 [ # # ][ # # ]: 0 : maChangesListeners.removeInterface( aListener );
2114 : 0 : }
2115 : :
2116 : 16 : bool ScModelObj::HasChangesListeners() const
2117 : : {
2118 [ - + ]: 16 : if ( maChangesListeners.getLength() > 0 )
2119 : 0 : return true;
2120 : :
2121 : : // "change" event set in any sheet?
2122 [ + - ][ - + ]: 16 : return pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript(SC_SHEETEVENT_CHANGE);
2123 : : }
2124 : :
2125 : 0 : void ScModelObj::NotifyChanges( const ::rtl::OUString& rOperation, const ScRangeList& rRanges,
2126 : : const uno::Sequence< beans::PropertyValue >& rProperties )
2127 : : {
2128 [ # # ][ # # ]: 0 : if ( pDocShell && HasChangesListeners() )
[ # # ]
2129 : : {
2130 [ # # ]: 0 : util::ChangesEvent aEvent;
2131 [ # # ]: 0 : aEvent.Source.set( static_cast< cppu::OWeakObject* >( this ) );
2132 [ # # ]: 0 : aEvent.Base <<= aEvent.Source;
2133 : :
2134 [ # # ]: 0 : size_t nRangeCount = rRanges.size();
2135 [ # # ]: 0 : aEvent.Changes.realloc( static_cast< sal_Int32 >( nRangeCount ) );
2136 [ # # ]: 0 : for ( size_t nIndex = 0; nIndex < nRangeCount; ++nIndex )
2137 : : {
2138 : 0 : uno::Reference< table::XCellRange > xRangeObj;
2139 : :
2140 [ # # ]: 0 : ScRange aRange( *rRanges[ nIndex ] );
2141 [ # # ]: 0 : if ( aRange.aStart == aRange.aEnd )
2142 : : {
2143 [ # # ][ # # ]: 0 : xRangeObj.set( new ScCellObj( pDocShell, aRange.aStart ) );
[ # # ]
2144 : : }
2145 : : else
2146 : : {
2147 [ # # ][ # # ]: 0 : xRangeObj.set( new ScCellRangeObj( pDocShell, aRange ) );
[ # # ]
2148 : : }
2149 : :
2150 [ # # ]: 0 : util::ElementChange& rChange = aEvent.Changes[ static_cast< sal_Int32 >( nIndex ) ];
2151 [ # # ]: 0 : rChange.Accessor <<= rOperation;
2152 [ # # ]: 0 : rChange.Element <<= rProperties;
2153 [ # # ]: 0 : rChange.ReplacedElement <<= xRangeObj;
2154 [ # # ]: 0 : }
2155 : :
2156 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper aIter( maChangesListeners );
2157 [ # # ]: 0 : while ( aIter.hasMoreElements() )
2158 : : {
2159 : : try
2160 : : {
2161 [ # # ][ # # ]: 0 : static_cast< util::XChangesListener* >( aIter.next() )->changesOccurred( aEvent );
2162 : : }
2163 [ # # ]: 0 : catch( uno::Exception& )
2164 : : {
2165 : : }
2166 [ # # ][ # # ]: 0 : }
2167 : : }
2168 : :
2169 : : // handle sheet events
2170 : : //! separate method with ScMarkData? Then change HasChangesListeners back.
2171 [ # # ][ # # ]: 0 : if ( rOperation.compareToAscii("cell-change") == 0 && pDocShell )
[ # # ]
2172 : : {
2173 [ # # ]: 0 : ScMarkData aMarkData;
2174 [ # # ]: 0 : aMarkData.MarkFromRangeList( rRanges, false );
2175 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
2176 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
2177 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
2178 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
2179 : : {
2180 [ # # ]: 0 : SCTAB nTab = *itr;
2181 [ # # ]: 0 : const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
2182 [ # # ]: 0 : if (pEvents)
2183 : : {
2184 [ # # ]: 0 : const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CHANGE);
2185 [ # # ]: 0 : if (pScript)
2186 : : {
2187 [ # # ]: 0 : ScRangeList aTabRanges; // collect ranges on this sheet
2188 [ # # ]: 0 : size_t nRangeCount = rRanges.size();
2189 [ # # ]: 0 : for ( size_t nIndex = 0; nIndex < nRangeCount; ++nIndex )
2190 : : {
2191 [ # # ]: 0 : ScRange aRange( *rRanges[ nIndex ] );
2192 [ # # ]: 0 : if ( aRange.aStart.Tab() == nTab )
2193 [ # # ]: 0 : aTabRanges.Append( aRange );
2194 : : }
2195 [ # # ]: 0 : size_t nTabRangeCount = aTabRanges.size();
2196 [ # # ]: 0 : if ( nTabRangeCount > 0 )
2197 : : {
2198 : 0 : uno::Reference<uno::XInterface> xTarget;
2199 [ # # ]: 0 : if ( nTabRangeCount == 1 )
2200 : : {
2201 [ # # ]: 0 : ScRange aRange( *aTabRanges[ 0 ] );
2202 [ # # ]: 0 : if ( aRange.aStart == aRange.aEnd )
2203 [ # # ][ # # ]: 0 : xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellObj( pDocShell, aRange.aStart ) ) );
[ # # ]
2204 : : else
2205 [ # # ][ # # ]: 0 : xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellRangeObj( pDocShell, aRange ) ) );
[ # # ]
2206 : : }
2207 : : else
2208 [ # # ][ # # ]: 0 : xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellRangesObj( pDocShell, aTabRanges ) ) );
[ # # ]
2209 : :
2210 [ # # ]: 0 : uno::Sequence<uno::Any> aParams(1);
2211 [ # # ][ # # ]: 0 : aParams[0] <<= xTarget;
2212 : :
2213 : 0 : uno::Any aRet;
2214 [ # # ]: 0 : uno::Sequence<sal_Int16> aOutArgsIndex;
2215 [ # # ]: 0 : uno::Sequence<uno::Any> aOutArgs;
2216 : :
2217 [ # # ][ # # ]: 0 : /*ErrCode eRet =*/ pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
[ # # ][ # # ]
[ # # ][ # # ]
2218 [ # # ]: 0 : }
2219 : : }
2220 : : }
2221 [ # # ]: 0 : }
2222 : : }
2223 : 0 : }
2224 : :
2225 : 0 : void ScModelObj::HandleCalculateEvents()
2226 : : {
2227 [ # # ]: 0 : if (pDocShell)
2228 : : {
2229 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
2230 : : // don't call events before the document is visible
2231 : : // (might also set a flag on SFX_EVENT_LOADFINISHED and only disable while loading)
2232 [ # # ]: 0 : if ( pDoc->IsDocVisible() )
2233 : : {
2234 : 0 : SCTAB nTabCount = pDoc->GetTableCount();
2235 [ # # ]: 0 : for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
2236 : : {
2237 [ # # ][ # # ]: 0 : if (pDoc->HasCalcNotification(nTab))
2238 : : {
2239 [ # # ][ # # ]: 0 : if (const ScSheetEvents* pEvents = pDoc->GetSheetEvents( nTab ))
2240 : : {
2241 [ # # ][ # # ]: 0 : if (const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CALCULATE))
2242 : : {
2243 : 0 : uno::Any aRet;
2244 [ # # ]: 0 : uno::Sequence<uno::Any> aParams;
2245 [ # # ]: 0 : uno::Sequence<sal_Int16> aOutArgsIndex;
2246 [ # # ]: 0 : uno::Sequence<uno::Any> aOutArgs;
2247 [ # # ][ # # ]: 0 : pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
[ # # ][ # # ]
[ # # ][ # # ]
2248 : : }
2249 : : }
2250 : :
2251 : : try
2252 : : {
2253 [ # # ][ # # ]: 0 : uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
2254 [ # # ]: 0 : uno::Sequence< uno::Any > aArgs( 1 );
2255 [ # # ][ # # ]: 0 : aArgs[ 0 ] <<= nTab;
2256 [ # # ][ # # ]: 0 : xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_CALCULATE ), aArgs );
[ # # ][ # # ]
[ # # ]
2257 : : }
2258 [ # # ]: 0 : catch( uno::Exception& )
2259 : : {
2260 : : }
2261 : : }
2262 : : }
2263 : : }
2264 : 0 : pDoc->ResetCalcNotifications();
2265 : : }
2266 : 0 : }
2267 : :
2268 : : //------------------------------------------------------------------------
2269 : :
2270 : 14 : ScDrawPagesObj::ScDrawPagesObj(ScDocShell* pDocSh) :
2271 [ + - ]: 14 : pDocShell( pDocSh )
2272 : : {
2273 [ + - ]: 14 : pDocShell->GetDocument()->AddUnoObject(*this);
2274 : 14 : }
2275 : :
2276 [ + - ]: 14 : ScDrawPagesObj::~ScDrawPagesObj()
2277 : : {
2278 [ + + ]: 14 : if (pDocShell)
2279 [ + - ]: 2 : pDocShell->GetDocument()->RemoveUnoObject(*this);
2280 [ - + ]: 28 : }
2281 : :
2282 : 133 : void ScDrawPagesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
2283 : : {
2284 : : // Referenz-Update interessiert hier nicht
2285 : :
2286 [ + + + + ]: 264 : if ( rHint.ISA( SfxSimpleHint ) &&
[ + + ]
2287 : 131 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
2288 : : {
2289 : 12 : pDocShell = NULL; // ungueltig geworden
2290 : : }
2291 : 133 : }
2292 : :
2293 : 25 : uno::Reference<drawing::XDrawPage> ScDrawPagesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
2294 : : {
2295 [ + - ]: 25 : if (pDocShell)
2296 : : {
2297 : 25 : ScDrawLayer* pDrawLayer = pDocShell->MakeDrawLayer();
2298 : : OSL_ENSURE(pDrawLayer,"kann Draw-Layer nicht anlegen");
2299 [ + - ][ + + ]: 25 : if ( pDrawLayer && nIndex >= 0 && nIndex < pDocShell->GetDocument()->GetTableCount() )
[ + + ][ + - ]
2300 : : {
2301 : 24 : SdrPage* pPage = pDrawLayer->GetPage((sal_uInt16)nIndex);
2302 : : OSL_ENSURE(pPage,"Draw-Page nicht gefunden");
2303 [ + - ]: 24 : if (pPage)
2304 : : {
2305 [ + - ]: 24 : return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
2306 : : }
2307 : : }
2308 : : }
2309 : 25 : return NULL;
2310 : : }
2311 : :
2312 : : // XDrawPages
2313 : :
2314 : 9 : uno::Reference<drawing::XDrawPage> SAL_CALL ScDrawPagesObj::insertNewByIndex( sal_Int32 nPos )
2315 : : throw(uno::RuntimeException)
2316 : : {
2317 [ + - ]: 9 : SolarMutexGuard aGuard;
2318 : 9 : uno::Reference<drawing::XDrawPage> xRet;
2319 [ + - ]: 9 : if (pDocShell)
2320 : : {
2321 : 9 : rtl::OUString aNewName;
2322 [ + - ]: 9 : pDocShell->GetDocument()->CreateValidTabName(aNewName);
2323 [ + - ]: 18 : if ( pDocShell->GetDocFunc().InsertTable( static_cast<SCTAB>(nPos),
2324 [ + - ][ + - ]: 9 : aNewName, true, true ) )
[ + - ]
2325 [ + - ][ + - ]: 9 : xRet.set(GetObjectByIndex_Impl( nPos ));
2326 : : }
2327 [ + - ]: 9 : return xRet;
2328 : : }
2329 : :
2330 : 1 : void SAL_CALL ScDrawPagesObj::remove( const uno::Reference<drawing::XDrawPage>& xPage )
2331 : : throw(uno::RuntimeException)
2332 : : {
2333 [ + - ]: 1 : SolarMutexGuard aGuard;
2334 [ + - ]: 1 : SvxDrawPage* pImp = SvxDrawPage::getImplementation( xPage );
2335 [ + - ][ + - ]: 1 : if ( pDocShell && pImp )
2336 : : {
2337 : 1 : SdrPage* pPage = pImp->GetSdrPage();
2338 [ + - ]: 1 : if (pPage)
2339 : : {
2340 [ + - ]: 1 : SCTAB nPageNum = static_cast<SCTAB>(pPage->GetPageNum());
2341 [ + - ]: 1 : pDocShell->GetDocFunc().DeleteTable( nPageNum, sal_True, sal_True );
2342 : : }
2343 [ + - ]: 1 : }
2344 : 1 : }
2345 : :
2346 : : // XIndexAccess
2347 : :
2348 : 8 : sal_Int32 SAL_CALL ScDrawPagesObj::getCount() throw(uno::RuntimeException)
2349 : : {
2350 [ + - ]: 8 : SolarMutexGuard aGuard;
2351 [ + - ]: 8 : if (pDocShell)
2352 [ + - ]: 8 : return pDocShell->GetDocument()->GetTableCount();
2353 [ + - ]: 8 : return 0;
2354 : : }
2355 : :
2356 : 16 : uno::Any SAL_CALL ScDrawPagesObj::getByIndex( sal_Int32 nIndex )
2357 : : throw(lang::IndexOutOfBoundsException,
2358 : : lang::WrappedTargetException, uno::RuntimeException)
2359 : : {
2360 [ + - ]: 16 : SolarMutexGuard aGuard;
2361 [ + - ]: 16 : uno::Reference<drawing::XDrawPage> xPage(GetObjectByIndex_Impl(nIndex));
2362 [ + + ]: 16 : if (xPage.is())
2363 [ + - ]: 30 : return uno::makeAny(xPage);
2364 : : else
2365 [ + - ][ + - ]: 16 : throw lang::IndexOutOfBoundsException();
2366 : : }
2367 : :
2368 : 1 : uno::Type SAL_CALL ScDrawPagesObj::getElementType() throw(uno::RuntimeException)
2369 : : {
2370 [ + - ]: 1 : SolarMutexGuard aGuard;
2371 [ + - ][ + - ]: 1 : return getCppuType((uno::Reference<drawing::XDrawPage>*)0);
2372 : : }
2373 : :
2374 : 1 : sal_Bool SAL_CALL ScDrawPagesObj::hasElements() throw(uno::RuntimeException)
2375 : : {
2376 [ + - ]: 1 : SolarMutexGuard aGuard;
2377 [ + - ][ + - ]: 1 : return ( getCount() != 0 );
2378 : : }
2379 : :
2380 : : //------------------------------------------------------------------------
2381 : :
2382 : 868 : ScTableSheetsObj::ScTableSheetsObj(ScDocShell* pDocSh) :
2383 [ + - ]: 868 : pDocShell( pDocSh )
2384 : : {
2385 [ + - ]: 868 : pDocShell->GetDocument()->AddUnoObject(*this);
2386 : 868 : }
2387 : :
2388 [ + - ]: 868 : ScTableSheetsObj::~ScTableSheetsObj()
2389 : : {
2390 [ + + ]: 868 : if (pDocShell)
2391 [ + - ]: 718 : pDocShell->GetDocument()->RemoveUnoObject(*this);
2392 [ - + ]: 1736 : }
2393 : :
2394 : 4190 : void ScTableSheetsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
2395 : : {
2396 : : // Referenz-Update interessiert hier nicht
2397 : :
2398 [ + + + + ]: 8236 : if ( rHint.ISA( SfxSimpleHint ) &&
[ + + ]
2399 : 4046 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
2400 : : {
2401 : 150 : pDocShell = NULL; // ungueltig geworden
2402 : : }
2403 : 4190 : }
2404 : :
2405 : : // XSpreadsheets
2406 : :
2407 : 747 : ScTableSheetObj* ScTableSheetsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
2408 : : {
2409 [ + - ][ + - ]: 747 : if ( pDocShell && nIndex >= 0 && nIndex < pDocShell->GetDocument()->GetTableCount() )
[ + + ][ + + ]
2410 [ + - ]: 746 : return new ScTableSheetObj( pDocShell, static_cast<SCTAB>(nIndex) );
2411 : :
2412 : 747 : return NULL;
2413 : : }
2414 : :
2415 : 113 : ScTableSheetObj* ScTableSheetsObj::GetObjectByName_Impl(const rtl::OUString& aName) const
2416 : : {
2417 [ + - ]: 113 : if (pDocShell)
2418 : : {
2419 : : SCTAB nIndex;
2420 [ + - ][ + - ]: 113 : if ( pDocShell->GetDocument()->GetTable( aName, nIndex ) )
2421 [ + - ]: 113 : return new ScTableSheetObj( pDocShell, nIndex );
2422 : : }
2423 : 113 : return NULL;
2424 : : }
2425 : :
2426 : 52 : void SAL_CALL ScTableSheetsObj::insertNewByName( const rtl::OUString& aName, sal_Int16 nPosition )
2427 : : throw(uno::RuntimeException)
2428 : : {
2429 [ + - ]: 52 : SolarMutexGuard aGuard;
2430 : 52 : sal_Bool bDone = false;
2431 [ + - ]: 52 : if (pDocShell)
2432 : : {
2433 [ + - ]: 52 : String aNamStr(aName);
2434 [ + - ][ + - ]: 52 : bDone = pDocShell->GetDocFunc().InsertTable( nPosition, aNamStr, sal_True, sal_True );
2435 : : }
2436 [ - + ]: 52 : if (!bDone)
2437 [ # # ][ + - ]: 52 : throw uno::RuntimeException(); // no other exceptions specified
2438 : 52 : }
2439 : :
2440 : 0 : void SAL_CALL ScTableSheetsObj::moveByName( const rtl::OUString& aName, sal_Int16 nDestination )
2441 : : throw(uno::RuntimeException)
2442 : : {
2443 [ # # ]: 0 : SolarMutexGuard aGuard;
2444 : 0 : sal_Bool bDone = false;
2445 [ # # ]: 0 : if (pDocShell)
2446 : : {
2447 : : SCTAB nSource;
2448 [ # # ][ # # ]: 0 : if ( pDocShell->GetDocument()->GetTable( aName, nSource ) )
2449 [ # # ]: 0 : bDone = pDocShell->MoveTable( nSource, nDestination, false, sal_True );
2450 : : }
2451 [ # # ]: 0 : if (!bDone)
2452 [ # # ][ # # ]: 0 : throw uno::RuntimeException(); // no other exceptions specified
2453 : 0 : }
2454 : :
2455 : 0 : void SAL_CALL ScTableSheetsObj::copyByName( const rtl::OUString& aName,
2456 : : const rtl::OUString& aCopy, sal_Int16 nDestination )
2457 : : throw(uno::RuntimeException)
2458 : : {
2459 [ # # ]: 0 : SolarMutexGuard aGuard;
2460 : 0 : sal_Bool bDone = false;
2461 [ # # ]: 0 : if (pDocShell)
2462 : : {
2463 [ # # ]: 0 : String aNewStr(aCopy);
2464 : : SCTAB nSource;
2465 [ # # ][ # # ]: 0 : if ( pDocShell->GetDocument()->GetTable( aName, nSource ) )
2466 : : {
2467 [ # # ]: 0 : bDone = pDocShell->MoveTable( nSource, nDestination, sal_True, sal_True );
2468 [ # # ]: 0 : if (bDone)
2469 : : {
2470 : : // #i92477# any index past the last sheet means "append" in MoveTable
2471 : 0 : SCTAB nResultTab = static_cast<SCTAB>(nDestination);
2472 [ # # ]: 0 : SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); // count after copying
2473 [ # # ]: 0 : if (nResultTab >= nTabCount)
2474 : 0 : nResultTab = nTabCount - 1;
2475 : :
2476 : 0 : bDone = pDocShell->GetDocFunc().RenameTable( nResultTab, aNewStr,
2477 [ # # ]: 0 : sal_True, sal_True );
2478 : : }
2479 [ # # ]: 0 : }
2480 : : }
2481 [ # # ]: 0 : if (!bDone)
2482 [ # # ][ # # ]: 0 : throw uno::RuntimeException(); // no other exceptions specified
2483 : 0 : }
2484 : :
2485 : 0 : void SAL_CALL ScTableSheetsObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
2486 : : throw(lang::IllegalArgumentException, container::ElementExistException,
2487 : : lang::WrappedTargetException, uno::RuntimeException)
2488 : : {
2489 [ # # ]: 0 : SolarMutexGuard aGuard;
2490 : 0 : sal_Bool bDone = false;
2491 : 0 : sal_Bool bIllArg = false;
2492 : :
2493 : : //! Type of aElement can be some specific interface instead of XInterface
2494 : :
2495 [ # # ]: 0 : if ( pDocShell )
2496 : : {
2497 [ # # ]: 0 : uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
2498 [ # # ]: 0 : if ( xInterface.is() )
2499 : : {
2500 [ # # ]: 0 : ScTableSheetObj* pSheetObj = ScTableSheetObj::getImplementation( xInterface );
2501 [ # # ][ # # ]: 0 : if ( pSheetObj && !pSheetObj->GetDocShell() ) // noch nicht eingefuegt?
[ # # ]
2502 : : {
2503 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
2504 [ # # ]: 0 : String aNamStr(aName);
2505 : : SCTAB nDummy;
2506 [ # # ][ # # ]: 0 : if ( pDoc->GetTable( aNamStr, nDummy ) )
[ # # ]
2507 : : {
2508 : : // name already exists
2509 [ # # ]: 0 : throw container::ElementExistException();
2510 : : }
2511 : : else
2512 : : {
2513 [ # # ]: 0 : SCTAB nPosition = pDoc->GetTableCount();
2514 : 0 : bDone = pDocShell->GetDocFunc().InsertTable( nPosition, aNamStr,
2515 [ # # ]: 0 : sal_True, sal_True );
2516 [ # # ]: 0 : if (bDone)
2517 [ # # ]: 0 : pSheetObj->InitInsertSheet( pDocShell, nPosition );
2518 : : // Dokument und neuen Range am Objekt setzen
2519 [ # # ]: 0 : }
2520 : : }
2521 : : else
2522 : 0 : bIllArg = sal_True;
2523 : : }
2524 : : else
2525 : 0 : bIllArg = sal_True;
2526 : : }
2527 : :
2528 [ # # ]: 0 : if (!bDone)
2529 : : {
2530 [ # # ]: 0 : if (bIllArg)
2531 [ # # ]: 0 : throw lang::IllegalArgumentException();
2532 : : else
2533 [ # # ]: 0 : throw uno::RuntimeException(); // ElementExistException is handled above
2534 [ # # ]: 0 : }
2535 : 0 : }
2536 : :
2537 : 0 : void SAL_CALL ScTableSheetsObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
2538 : : throw(lang::IllegalArgumentException, container::NoSuchElementException,
2539 : : lang::WrappedTargetException, uno::RuntimeException)
2540 : : {
2541 [ # # ]: 0 : SolarMutexGuard aGuard;
2542 : 0 : sal_Bool bDone = false;
2543 : 0 : sal_Bool bIllArg = false;
2544 : :
2545 : : //! Type of aElement can be some specific interface instead of XInterface
2546 : :
2547 [ # # ]: 0 : if ( pDocShell )
2548 : : {
2549 [ # # ]: 0 : uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
2550 [ # # ]: 0 : if ( xInterface.is() )
2551 : : {
2552 [ # # ]: 0 : ScTableSheetObj* pSheetObj = ScTableSheetObj::getImplementation( xInterface );
2553 [ # # ][ # # ]: 0 : if ( pSheetObj && !pSheetObj->GetDocShell() ) // noch nicht eingefuegt?
[ # # ]
2554 : : {
2555 : : SCTAB nPosition;
2556 [ # # ][ # # ]: 0 : if ( pDocShell->GetDocument()->GetTable( aName, nPosition ) )
2557 : : {
2558 [ # # ][ # # ]: 0 : if ( pDocShell->GetDocFunc().DeleteTable( nPosition, sal_True, sal_True ) )
2559 : : {
2560 : : // InsertTable kann jetzt eigentlich nicht schiefgehen...
2561 [ # # ]: 0 : String aNamStr(aName);
2562 [ # # ]: 0 : bDone = pDocShell->GetDocFunc().InsertTable( nPosition, aNamStr, sal_True, sal_True );
2563 [ # # ]: 0 : if (bDone)
2564 [ # # ][ # # ]: 0 : pSheetObj->InitInsertSheet( pDocShell, nPosition );
2565 : : }
2566 : : }
2567 : : else
2568 : : {
2569 : : // not found
2570 [ # # ]: 0 : throw container::NoSuchElementException();
2571 : : }
2572 : : }
2573 : : else
2574 : 0 : bIllArg = sal_True;
2575 : : }
2576 : : else
2577 : 0 : bIllArg = sal_True;
2578 : : }
2579 : :
2580 [ # # ]: 0 : if (!bDone)
2581 : : {
2582 [ # # ]: 0 : if (bIllArg)
2583 [ # # ]: 0 : throw lang::IllegalArgumentException();
2584 : : else
2585 [ # # ]: 0 : throw uno::RuntimeException(); // NoSuchElementException is handled above
2586 [ # # ]: 0 : }
2587 : 0 : }
2588 : :
2589 : 20 : void SAL_CALL ScTableSheetsObj::removeByName( const rtl::OUString& aName )
2590 : : throw(container::NoSuchElementException,
2591 : : lang::WrappedTargetException, uno::RuntimeException)
2592 : : {
2593 [ + - ]: 20 : SolarMutexGuard aGuard;
2594 : 20 : sal_Bool bDone = false;
2595 [ + - ]: 20 : if (pDocShell)
2596 : : {
2597 : : SCTAB nIndex;
2598 [ + - ][ + + ]: 20 : if ( pDocShell->GetDocument()->GetTable( aName, nIndex ) )
2599 [ + - ]: 18 : bDone = pDocShell->GetDocFunc().DeleteTable( nIndex, sal_True, sal_True );
2600 : : else // not found
2601 [ + - ]: 2 : throw container::NoSuchElementException();
2602 : : }
2603 : :
2604 [ - + ]: 18 : if (!bDone)
2605 [ # # ][ + - ]: 20 : throw uno::RuntimeException(); // NoSuchElementException is handled above
2606 : 18 : }
2607 : :
2608 : 2 : sal_Int32 ScTableSheetsObj::importSheet(
2609 : : const uno::Reference < sheet::XSpreadsheetDocument > & xDocSrc,
2610 : : const rtl::OUString& srcName, const sal_Int32 nDestPosition )
2611 : : throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException, uno::RuntimeException )
2612 : : {
2613 : : //pDocShell is the destination
2614 : 2 : ScDocument* pDocDest = pDocShell->GetDocument();
2615 : :
2616 : : // Source document docShell
2617 [ - + ]: 2 : if ( !xDocSrc.is() )
2618 [ # # ]: 0 : throw uno::RuntimeException();
2619 [ + - ]: 2 : ScModelObj* pObj = ScModelObj::getImplementation(xDocSrc);
2620 [ + - ]: 2 : ScDocShell* pDocShellSrc = static_cast<ScDocShell*>(pObj->GetEmbeddedObject());
2621 : :
2622 : : // SourceSheet Position and does srcName exists ?
2623 : : SCTAB nIndexSrc;
2624 [ + - ][ - + ]: 2 : if ( !pDocShellSrc->GetDocument()->GetTable( srcName, nIndexSrc ) )
2625 [ # # ]: 0 : throw lang::IllegalArgumentException();
2626 : :
2627 : : // Check the validity of destination index.
2628 [ + - ]: 2 : SCTAB nCount = pDocDest->GetTableCount();
2629 : 2 : SCTAB nIndexDest = static_cast<SCTAB>(nDestPosition);
2630 [ + - ][ - + ]: 2 : if (nIndexDest > nCount || nIndexDest < 0)
2631 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
2632 : :
2633 : : // Transfert Tab
2634 : 2 : bool bInsertNew = true;
2635 : 2 : bool bNotifyAndPaint = true;
2636 : : pDocShell->TransferTab(
2637 [ + - ]: 2 : *pDocShellSrc, nIndexSrc, nIndexDest, bInsertNew, bNotifyAndPaint );
2638 : :
2639 : 2 : return nIndexDest;
2640 : : }
2641 : :
2642 : : // XCellRangesAccess
2643 : :
2644 : 0 : uno::Reference< table::XCell > SAL_CALL ScTableSheetsObj::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow, sal_Int32 nSheet )
2645 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2646 : : {
2647 [ # # ]: 0 : SolarMutexGuard aGuard;
2648 [ # # ][ # # ]: 0 : uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((sal_uInt16)nSheet)));
[ # # ]
2649 [ # # ]: 0 : if (! xSheet.is())
2650 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
2651 : :
2652 [ # # ][ # # ]: 0 : return xSheet->getCellByPosition(nColumn, nRow);
[ # # ]
2653 : : }
2654 : :
2655 : 0 : uno::Reference< table::XCellRange > SAL_CALL ScTableSheetsObj::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom, sal_Int32 nSheet )
2656 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2657 : : {
2658 [ # # ]: 0 : SolarMutexGuard aGuard;
2659 [ # # ][ # # ]: 0 : uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((sal_uInt16)nSheet)));
[ # # ]
2660 [ # # ]: 0 : if (! xSheet.is())
2661 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
2662 : :
2663 [ # # ][ # # ]: 0 : return xSheet->getCellRangeByPosition(nLeft, nTop, nRight, nBottom);
[ # # ]
2664 : : }
2665 : :
2666 : 0 : uno::Sequence < uno::Reference< table::XCellRange > > SAL_CALL ScTableSheetsObj::getCellRangesByName( const rtl::OUString& aRange )
2667 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
2668 : : {
2669 [ # # ]: 0 : SolarMutexGuard aGuard;
2670 [ # # ]: 0 : uno::Sequence < uno::Reference < table::XCellRange > > xRet;
2671 : :
2672 [ # # ]: 0 : ScRangeList aRangeList;
2673 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
2674 [ # # ][ # # ]: 0 : if (ScRangeStringConverter::GetRangeListFromString( aRangeList, aRange, pDoc, ::formula::FormulaGrammar::CONV_OOO, ';' ))
2675 : : {
2676 [ # # ]: 0 : size_t nCount = aRangeList.size();
2677 [ # # ]: 0 : if (nCount)
2678 : : {
2679 [ # # ]: 0 : xRet.realloc(nCount);
2680 [ # # ]: 0 : for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
2681 : : {
2682 [ # # ]: 0 : const ScRange* pRange = aRangeList[ nIndex ];
2683 [ # # ]: 0 : if( pRange )
2684 [ # # ][ # # ]: 0 : xRet[nIndex] = new ScCellRangeObj(pDocShell, *pRange);
[ # # ][ # # ]
2685 : : }
2686 : : }
2687 : : else
2688 [ # # ]: 0 : throw lang::IllegalArgumentException();
2689 : : }
2690 : : else
2691 [ # # ]: 0 : throw lang::IllegalArgumentException();
2692 [ # # ][ # # ]: 0 : return xRet;
2693 : : }
2694 : :
2695 : : // XEnumerationAccess
2696 : :
2697 : 1 : uno::Reference<container::XEnumeration> SAL_CALL ScTableSheetsObj::createEnumeration()
2698 : : throw(uno::RuntimeException)
2699 : : {
2700 [ + - ]: 1 : SolarMutexGuard aGuard;
2701 [ + - ][ + - ]: 1 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetsEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
2702 : : }
2703 : :
2704 : : // XIndexAccess
2705 : :
2706 : 173 : sal_Int32 SAL_CALL ScTableSheetsObj::getCount() throw(uno::RuntimeException)
2707 : : {
2708 [ + - ]: 173 : SolarMutexGuard aGuard;
2709 [ + - ]: 173 : if (pDocShell)
2710 [ + - ]: 173 : return pDocShell->GetDocument()->GetTableCount();
2711 [ + - ]: 173 : return 0;
2712 : : }
2713 : :
2714 : 747 : uno::Any SAL_CALL ScTableSheetsObj::getByIndex( sal_Int32 nIndex )
2715 : : throw(lang::IndexOutOfBoundsException,
2716 : : lang::WrappedTargetException, uno::RuntimeException)
2717 : : {
2718 [ + - ]: 747 : SolarMutexGuard aGuard;
2719 [ + - ][ + + ]: 747 : uno::Reference<sheet::XSpreadsheet> xSheet(GetObjectByIndex_Impl(nIndex));
[ + - ]
2720 [ + + ]: 747 : if (xSheet.is())
2721 [ + - ]: 1492 : return uno::makeAny(xSheet);
2722 : : else
2723 [ + - ][ + - ]: 747 : throw lang::IndexOutOfBoundsException();
2724 : : // return uno::Any();
2725 : : }
2726 : :
2727 : 0 : uno::Type SAL_CALL ScTableSheetsObj::getElementType() throw(uno::RuntimeException)
2728 : : {
2729 [ # # ]: 0 : SolarMutexGuard aGuard;
2730 [ # # ][ # # ]: 0 : return getCppuType((uno::Reference<sheet::XSpreadsheet>*)0);
2731 : : }
2732 : :
2733 : 0 : sal_Bool SAL_CALL ScTableSheetsObj::hasElements() throw(uno::RuntimeException)
2734 : : {
2735 [ # # ]: 0 : SolarMutexGuard aGuard;
2736 [ # # ][ # # ]: 0 : return ( getCount() != 0 );
2737 : : }
2738 : :
2739 : : // XNameAccess
2740 : :
2741 : 113 : uno::Any SAL_CALL ScTableSheetsObj::getByName( const rtl::OUString& aName )
2742 : : throw(container::NoSuchElementException,
2743 : : lang::WrappedTargetException, uno::RuntimeException)
2744 : : {
2745 [ + - ]: 113 : SolarMutexGuard aGuard;
2746 [ + - ][ + - ]: 113 : uno::Reference<sheet::XSpreadsheet> xSheet(GetObjectByName_Impl(aName));
[ + - ]
2747 [ + - ]: 113 : if (xSheet.is())
2748 [ + - ]: 226 : return uno::makeAny(xSheet);
2749 : : else
2750 [ # # ][ + - ]: 113 : throw container::NoSuchElementException();
2751 : : }
2752 : :
2753 : 29 : uno::Sequence<rtl::OUString> SAL_CALL ScTableSheetsObj::getElementNames()
2754 : : throw(uno::RuntimeException)
2755 : : {
2756 [ + - ]: 29 : SolarMutexGuard aGuard;
2757 [ + - ]: 29 : if (pDocShell)
2758 : : {
2759 : 29 : ScDocument* pDoc = pDocShell->GetDocument();
2760 [ + - ]: 29 : SCTAB nCount = pDoc->GetTableCount();
2761 : 29 : rtl::OUString aName;
2762 [ + - ]: 29 : uno::Sequence<rtl::OUString> aSeq(nCount);
2763 [ + - ]: 29 : rtl::OUString* pAry = aSeq.getArray();
2764 [ + + ]: 58 : for (SCTAB i=0; i<nCount; i++)
2765 : : {
2766 [ + - ]: 29 : pDoc->GetName( i, aName );
2767 : 29 : pAry[i] = aName;
2768 : : }
2769 [ + - ][ + - ]: 29 : return aSeq;
2770 : : }
2771 [ # # ][ + - ]: 29 : return uno::Sequence<rtl::OUString>();
2772 : : }
2773 : :
2774 : 42 : sal_Bool SAL_CALL ScTableSheetsObj::hasByName( const rtl::OUString& aName )
2775 : : throw(uno::RuntimeException)
2776 : : {
2777 [ + - ]: 42 : SolarMutexGuard aGuard;
2778 [ + - ]: 42 : if (pDocShell)
2779 : : {
2780 : : SCTAB nIndex;
2781 [ + - ][ + + ]: 42 : if ( pDocShell->GetDocument()->GetTable( aName, nIndex ) )
2782 : 42 : return sal_True;
2783 : : }
2784 [ + - ]: 42 : return false;
2785 : : }
2786 : :
2787 : : //------------------------------------------------------------------------
2788 : :
2789 : 446 : ScTableColumnsObj::ScTableColumnsObj(ScDocShell* pDocSh, SCTAB nT, SCCOL nSC, SCCOL nEC) :
2790 : : pDocShell( pDocSh ),
2791 : : nTab ( nT ),
2792 : : nStartCol( nSC ),
2793 [ + - ]: 446 : nEndCol ( nEC )
2794 : : {
2795 [ + - ]: 446 : pDocShell->GetDocument()->AddUnoObject(*this);
2796 : 446 : }
2797 : :
2798 [ + - ]: 446 : ScTableColumnsObj::~ScTableColumnsObj()
2799 : : {
2800 [ + + ]: 446 : if (pDocShell)
2801 [ + - ]: 430 : pDocShell->GetDocument()->RemoveUnoObject(*this);
2802 [ - + ]: 892 : }
2803 : :
2804 : 934 : void ScTableColumnsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
2805 : : {
2806 [ + + ]: 934 : if ( rHint.ISA( ScUpdateRefHint ) )
2807 : : {
2808 : : //! Referenz-Update fuer Tab und Start/Ende
2809 : : }
2810 [ + + + + ]: 1844 : else if ( rHint.ISA( SfxSimpleHint ) &&
[ + + ]
2811 : 916 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
2812 : : {
2813 : 16 : pDocShell = NULL; // ungueltig geworden
2814 : : }
2815 : 934 : }
2816 : :
2817 : : // XTableColumns
2818 : :
2819 : 1037 : ScTableColumnObj* ScTableColumnsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
2820 : : {
2821 : 1037 : SCCOL nCol = static_cast<SCCOL>(nIndex) + nStartCol;
2822 [ + - ][ + + ]: 1037 : if ( pDocShell && nCol <= nEndCol )
2823 [ + - ]: 1035 : return new ScTableColumnObj( pDocShell, nCol, nTab );
2824 : :
2825 : 1037 : return NULL; // falscher Index
2826 : : }
2827 : :
2828 : 2 : ScTableColumnObj* ScTableColumnsObj::GetObjectByName_Impl(const rtl::OUString& aName) const
2829 : : {
2830 : 2 : SCCOL nCol = 0;
2831 [ + - ]: 2 : String aString(aName);
2832 [ + - ][ + + ]: 2 : if ( ::AlphaToCol( nCol, aString) )
2833 [ + - ][ + - ]: 1 : if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol )
[ + - ]
2834 [ + - ]: 1 : return new ScTableColumnObj( pDocShell, nCol, nTab );
2835 : :
2836 [ + - ]: 2 : return NULL;
2837 : : }
2838 : :
2839 : 6 : void SAL_CALL ScTableColumnsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 nCount )
2840 : : throw(uno::RuntimeException)
2841 : : {
2842 [ + - ]: 6 : SolarMutexGuard aGuard;
2843 : 6 : sal_Bool bDone = false;
2844 [ + - ][ + + ]: 6 : if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartCol+nPosition <= nEndCol &&
[ + + ][ + + ]
[ + - ]
2845 : : nStartCol+nPosition+nCount-1 <= MAXCOL )
2846 : : {
2847 : : ScRange aRange( (SCCOL)(nStartCol+nPosition), 0, nTab,
2848 : 3 : (SCCOL)(nStartCol+nPosition+nCount-1), MAXROW, nTab );
2849 [ + - ]: 3 : bDone = pDocShell->GetDocFunc().InsertCells( aRange, NULL, INS_INSCOLS, sal_True, sal_True );
2850 : : }
2851 [ + + ]: 6 : if (!bDone)
2852 [ + - ][ + - ]: 6 : throw uno::RuntimeException(); // no other exceptions specified
2853 : 3 : }
2854 : :
2855 : 6 : void SAL_CALL ScTableColumnsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount )
2856 : : throw(uno::RuntimeException)
2857 : : {
2858 [ + - ]: 6 : SolarMutexGuard aGuard;
2859 : 6 : sal_Bool bDone = false;
2860 : : // Der zu loeschende Bereich muss innerhalb des Objekts liegen
2861 [ + - ][ + + ]: 6 : if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartCol+nIndex+nCount-1 <= nEndCol )
[ + + ][ + + ]
2862 : : {
2863 : : ScRange aRange( (SCCOL)(nStartCol+nIndex), 0, nTab,
2864 : 3 : (SCCOL)(nStartCol+nIndex+nCount-1), MAXROW, nTab );
2865 [ + - ]: 3 : bDone = pDocShell->GetDocFunc().DeleteCells( aRange, NULL, DEL_DELCOLS, sal_True, sal_True );
2866 : : }
2867 [ + + ]: 6 : if (!bDone)
2868 [ + - ][ + - ]: 6 : throw uno::RuntimeException(); // no other exceptions specified
2869 : 3 : }
2870 : :
2871 : : // XEnumerationAccess
2872 : :
2873 : 2 : uno::Reference<container::XEnumeration> SAL_CALL ScTableColumnsObj::createEnumeration()
2874 : : throw(uno::RuntimeException)
2875 : : {
2876 [ + - ]: 2 : SolarMutexGuard aGuard;
2877 [ + - ][ + - ]: 2 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableColumnsEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
2878 : : }
2879 : :
2880 : : // XIndexAccess
2881 : :
2882 : 1083 : sal_Int32 SAL_CALL ScTableColumnsObj::getCount() throw(uno::RuntimeException)
2883 : : {
2884 [ + - ]: 1083 : SolarMutexGuard aGuard;
2885 [ + - ]: 1083 : return nEndCol - nStartCol + 1;
2886 : : }
2887 : :
2888 : 1037 : uno::Any SAL_CALL ScTableColumnsObj::getByIndex( sal_Int32 nIndex )
2889 : : throw(lang::IndexOutOfBoundsException,
2890 : : lang::WrappedTargetException, uno::RuntimeException)
2891 : : {
2892 [ + - ]: 1037 : SolarMutexGuard aGuard;
2893 [ + - ][ + + ]: 1037 : uno::Reference<table::XCellRange> xColumn(GetObjectByIndex_Impl(nIndex));
[ + - ]
2894 [ + + ]: 1037 : if (xColumn.is())
2895 [ + - ]: 2070 : return uno::makeAny(xColumn);
2896 : : else
2897 [ + - ][ + - ]: 1037 : throw lang::IndexOutOfBoundsException();
2898 : : }
2899 : :
2900 : 1 : uno::Type SAL_CALL ScTableColumnsObj::getElementType() throw(uno::RuntimeException)
2901 : : {
2902 [ + - ]: 1 : SolarMutexGuard aGuard;
2903 [ + - ][ + - ]: 1 : return getCppuType((uno::Reference<table::XCellRange>*)0);
2904 : : }
2905 : :
2906 : 1 : sal_Bool SAL_CALL ScTableColumnsObj::hasElements() throw(uno::RuntimeException)
2907 : : {
2908 [ + - ]: 1 : SolarMutexGuard aGuard;
2909 [ + - ][ + - ]: 1 : return ( getCount() != 0 );
2910 : : }
2911 : :
2912 : 2 : uno::Any SAL_CALL ScTableColumnsObj::getByName( const rtl::OUString& aName )
2913 : : throw(container::NoSuchElementException,
2914 : : lang::WrappedTargetException, uno::RuntimeException)
2915 : : {
2916 [ + - ]: 2 : SolarMutexGuard aGuard;
2917 [ + - ][ + + ]: 2 : uno::Reference<table::XCellRange> xColumn(GetObjectByName_Impl(aName));
[ + - ]
2918 [ + + ]: 2 : if (xColumn.is())
2919 [ + - ]: 2 : return uno::makeAny(xColumn);
2920 : : else
2921 [ + - ][ + - ]: 2 : throw container::NoSuchElementException();
2922 : : }
2923 : :
2924 : 1 : uno::Sequence<rtl::OUString> SAL_CALL ScTableColumnsObj::getElementNames()
2925 : : throw(uno::RuntimeException)
2926 : : {
2927 [ + - ]: 1 : SolarMutexGuard aGuard;
2928 : 1 : SCCOL nCount = nEndCol - nStartCol + 1;
2929 [ + - ]: 1 : uno::Sequence<rtl::OUString> aSeq(nCount);
2930 [ + - ]: 1 : rtl::OUString* pAry = aSeq.getArray();
2931 [ + + ]: 1025 : for (SCCOL i=0; i<nCount; i++)
2932 [ + - ][ + - ]: 1024 : pAry[i] = ::ScColToAlpha( nStartCol + i );
[ + - ]
2933 : :
2934 [ + - ]: 1 : return aSeq;
2935 : : }
2936 : :
2937 : 2 : sal_Bool SAL_CALL ScTableColumnsObj::hasByName( const rtl::OUString& aName )
2938 : : throw(uno::RuntimeException)
2939 : : {
2940 [ + - ]: 2 : SolarMutexGuard aGuard;
2941 : 2 : SCCOL nCol = 0;
2942 [ + - ]: 2 : String aString(aName);
2943 [ + - ][ + + ]: 2 : if ( ::AlphaToCol( nCol, aString) )
2944 [ + - ][ + - ]: 1 : if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol )
[ + - ]
2945 : 1 : return sal_True;
2946 : :
2947 [ + - ][ + - ]: 2 : return false; // nicht gefunden
2948 : : }
2949 : :
2950 : : // XPropertySet
2951 : :
2952 : 416 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnsObj::getPropertySetInfo()
2953 : : throw(uno::RuntimeException)
2954 : : {
2955 [ + - ]: 416 : SolarMutexGuard aGuard;
2956 : : static uno::Reference<beans::XPropertySetInfo> aRef(
2957 [ + + ][ + - ]: 416 : new SfxItemPropertySetInfo( lcl_GetColumnsPropertyMap() ));
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ]
2958 [ + - ]: 416 : return aRef;
2959 : : }
2960 : :
2961 : 1074 : void SAL_CALL ScTableColumnsObj::setPropertyValue(
2962 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
2963 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
2964 : : lang::IllegalArgumentException, lang::WrappedTargetException,
2965 : : uno::RuntimeException)
2966 : : {
2967 [ + - ]: 1074 : SolarMutexGuard aGuard;
2968 [ - + ]: 1074 : if (!pDocShell)
2969 [ # # ]: 0 : throw uno::RuntimeException();
2970 : :
2971 : : SCCOLROW nColArr[2];
2972 : 1074 : nColArr[0] = nStartCol;
2973 : 1074 : nColArr[1] = nEndCol;
2974 [ + - ]: 1074 : String aNameString(aPropertyName);
2975 : 1074 : ScDocFunc& rFunc = pDocShell->GetDocFunc();
2976 : :
2977 [ + + ][ + - ]: 1074 : if ( aNameString.EqualsAscii( SC_UNONAME_CELLWID ) )
2978 : : {
2979 : 416 : sal_Int32 nNewWidth = 0;
2980 [ + - ]: 416 : if ( aValue >>= nNewWidth )
2981 : : rFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab, SC_SIZE_ORIGINAL,
2982 [ + - ]: 416 : (sal_uInt16)HMMToTwips(nNewWidth), sal_True, sal_True );
2983 : : }
2984 [ + - ][ + + ]: 658 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
2985 : : {
2986 [ + - ]: 329 : sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2987 [ + - ]: 329 : ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
2988 [ + - ]: 329 : rFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab, eMode, 0, sal_True, sal_True );
2989 : : // SC_SIZE_DIRECT with size 0: hide
2990 : : }
2991 [ + - ][ - + ]: 329 : else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) )
2992 : : {
2993 [ # # ]: 0 : sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2994 [ # # ]: 0 : if (bOpt)
2995 : : rFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab,
2996 [ # # ]: 0 : SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, sal_True, sal_True );
2997 : : // sal_False for columns currently has no effect
2998 : : }
2999 [ + - ][ + - ]: 329 : else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
[ + - ][ + - ]
[ + - ]
3000 : : {
3001 : : //! single function to set/remove all breaks?
3002 [ + - ]: 329 : sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
3003 [ + + ]: 2764 : for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
3004 [ - + ]: 2435 : if (bSet)
3005 [ # # ]: 0 : rFunc.InsertPageBreak( sal_True, ScAddress(nCol,0,nTab), sal_True, sal_True, sal_True );
3006 : : else
3007 [ + - ]: 2435 : rFunc.RemovePageBreak( sal_True, ScAddress(nCol,0,nTab), sal_True, sal_True, sal_True );
3008 [ + - ][ + - ]: 1074 : }
3009 : 1074 : }
3010 : :
3011 : 0 : uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const rtl::OUString& aPropertyName )
3012 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
3013 : : uno::RuntimeException)
3014 : : {
3015 [ # # ]: 0 : SolarMutexGuard aGuard;
3016 [ # # ]: 0 : if (!pDocShell)
3017 [ # # ]: 0 : throw uno::RuntimeException();
3018 : :
3019 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
3020 [ # # ]: 0 : String aNameString(aPropertyName);
3021 : 0 : uno::Any aAny;
3022 : :
3023 : : //! loop over all columns for current state?
3024 : :
3025 [ # # ][ # # ]: 0 : if ( aNameString.EqualsAscii( SC_UNONAME_CELLWID ) )
3026 : : {
3027 : : // for hidden column, return original height
3028 [ # # ]: 0 : sal_uInt16 nWidth = pDoc->GetOriginalWidth( nStartCol, nTab );
3029 [ # # ]: 0 : aAny <<= (sal_Int32)TwipsToHMM(nWidth);
3030 : : }
3031 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
3032 : : {
3033 [ # # ]: 0 : bool bVis = !pDoc->ColHidden(nStartCol, nTab);
3034 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
3035 : : }
3036 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) )
3037 : : {
3038 [ # # ]: 0 : sal_Bool bOpt = !(pDoc->GetColFlags( nStartCol, nTab ) & CR_MANUALSIZE);
3039 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, bOpt );
3040 : : }
3041 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) )
3042 : : {
3043 [ # # ]: 0 : ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab);
3044 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
3045 : : }
3046 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
3047 : : {
3048 [ # # ]: 0 : ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab);
3049 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) );
3050 : : }
3051 : :
3052 [ # # ][ # # ]: 0 : return aAny;
3053 : : }
3054 : :
3055 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableColumnsObj )
3056 : :
3057 : : //------------------------------------------------------------------------
3058 : :
3059 : 4616 : ScTableRowsObj::ScTableRowsObj(ScDocShell* pDocSh, SCTAB nT, SCROW nSR, SCROW nER) :
3060 : : pDocShell( pDocSh ),
3061 : : nTab ( nT ),
3062 : : nStartRow( nSR ),
3063 [ + - ]: 4616 : nEndRow ( nER )
3064 : : {
3065 [ + - ]: 4616 : pDocShell->GetDocument()->AddUnoObject(*this);
3066 : 4616 : }
3067 : :
3068 [ + - ]: 4616 : ScTableRowsObj::~ScTableRowsObj()
3069 : : {
3070 [ + + ]: 4616 : if (pDocShell)
3071 [ + - ]: 4603 : pDocShell->GetDocument()->RemoveUnoObject(*this);
3072 [ - + ]: 9232 : }
3073 : :
3074 : 377 : void ScTableRowsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
3075 : : {
3076 [ + + ]: 377 : if ( rHint.ISA( ScUpdateRefHint ) )
3077 : : {
3078 : : //! Referenz-Update fuer Tab und Start/Ende
3079 : : }
3080 [ + + + + ]: 738 : else if ( rHint.ISA( SfxSimpleHint ) &&
[ + + ]
3081 : 363 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
3082 : : {
3083 : 13 : pDocShell = NULL; // ungueltig geworden
3084 : : }
3085 : 377 : }
3086 : :
3087 : : // XTableRows
3088 : :
3089 : 28 : ScTableRowObj* ScTableRowsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
3090 : : {
3091 : 28 : SCROW nRow = static_cast<SCROW>(nIndex) + nStartRow;
3092 [ + - ][ + + ]: 28 : if ( pDocShell && nRow <= nEndRow )
3093 [ + - ]: 27 : return new ScTableRowObj( pDocShell, nRow, nTab );
3094 : :
3095 : 28 : return NULL; // falscher Index
3096 : : }
3097 : :
3098 : 2 : void SAL_CALL ScTableRowsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 nCount )
3099 : : throw(uno::RuntimeException)
3100 : : {
3101 [ + - ]: 2 : SolarMutexGuard aGuard;
3102 : 2 : sal_Bool bDone = false;
3103 [ + - ][ + - ]: 2 : if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartRow+nPosition <= nEndRow &&
[ + + ][ + - ]
[ + - ]
3104 : : nStartRow+nPosition+nCount-1 <= MAXROW )
3105 : : {
3106 : : ScRange aRange( 0, (SCROW)(nStartRow+nPosition), nTab,
3107 : 1 : MAXCOL, (SCROW)(nStartRow+nPosition+nCount-1), nTab );
3108 [ + - ]: 1 : bDone = pDocShell->GetDocFunc().InsertCells( aRange, NULL, INS_INSROWS, sal_True, sal_True );
3109 : : }
3110 [ + + ]: 2 : if (!bDone)
3111 [ + - ][ + - ]: 2 : throw uno::RuntimeException(); // no other exceptions specified
3112 : 1 : }
3113 : :
3114 : 2 : void SAL_CALL ScTableRowsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount )
3115 : : throw(uno::RuntimeException)
3116 : : {
3117 [ + - ]: 2 : SolarMutexGuard aGuard;
3118 : 2 : sal_Bool bDone = false;
3119 : : // Der zu loeschende Bereich muss innerhalb des Objekts liegen
3120 [ + - ][ + - ]: 2 : if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartRow+nIndex+nCount-1 <= nEndRow )
[ + + ][ + - ]
3121 : : {
3122 : : ScRange aRange( 0, (SCROW)(nStartRow+nIndex), nTab,
3123 : 1 : MAXCOL, (SCROW)(nStartRow+nIndex+nCount-1), nTab );
3124 [ + - ]: 1 : bDone = pDocShell->GetDocFunc().DeleteCells( aRange, NULL, DEL_DELROWS, sal_True, sal_True );
3125 : : }
3126 [ + + ]: 2 : if (!bDone)
3127 [ + - ][ + - ]: 2 : throw uno::RuntimeException(); // no other exceptions specified
3128 : 1 : }
3129 : :
3130 : : // XEnumerationAccess
3131 : :
3132 : 1 : uno::Reference<container::XEnumeration> SAL_CALL ScTableRowsObj::createEnumeration()
3133 : : throw(uno::RuntimeException)
3134 : : {
3135 [ + - ]: 1 : SolarMutexGuard aGuard;
3136 [ + - ][ + - ]: 1 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableRowsEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
3137 : : }
3138 : :
3139 : : // XIndexAccess
3140 : :
3141 : 19 : sal_Int32 SAL_CALL ScTableRowsObj::getCount() throw(uno::RuntimeException)
3142 : : {
3143 [ + - ]: 19 : SolarMutexGuard aGuard;
3144 [ + - ]: 19 : return nEndRow - nStartRow + 1;
3145 : : }
3146 : :
3147 : 28 : uno::Any SAL_CALL ScTableRowsObj::getByIndex( sal_Int32 nIndex )
3148 : : throw(lang::IndexOutOfBoundsException,
3149 : : lang::WrappedTargetException, uno::RuntimeException)
3150 : : {
3151 [ + - ]: 28 : SolarMutexGuard aGuard;
3152 [ + - ][ + + ]: 28 : uno::Reference<table::XCellRange> xRow(GetObjectByIndex_Impl(nIndex));
[ + - ]
3153 [ + + ]: 28 : if (xRow.is())
3154 [ + - ]: 54 : return uno::makeAny(xRow);
3155 : : else
3156 [ + - ][ + - ]: 28 : throw lang::IndexOutOfBoundsException();
3157 : : }
3158 : :
3159 : 1 : uno::Type SAL_CALL ScTableRowsObj::getElementType() throw(uno::RuntimeException)
3160 : : {
3161 [ + - ]: 1 : SolarMutexGuard aGuard;
3162 [ + - ][ + - ]: 1 : return getCppuType((uno::Reference<table::XCellRange>*)0);
3163 : : }
3164 : :
3165 : 1 : sal_Bool SAL_CALL ScTableRowsObj::hasElements() throw(uno::RuntimeException)
3166 : : {
3167 [ + - ]: 1 : SolarMutexGuard aGuard;
3168 [ + - ][ + - ]: 1 : return ( getCount() != 0 );
3169 : : }
3170 : :
3171 : : // XPropertySet
3172 : :
3173 : 4575 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowsObj::getPropertySetInfo()
3174 : : throw(uno::RuntimeException)
3175 : : {
3176 [ + - ]: 4575 : SolarMutexGuard aGuard;
3177 : : static uno::Reference<beans::XPropertySetInfo> aRef(
3178 [ + + ][ + - ]: 4575 : new SfxItemPropertySetInfo( lcl_GetRowsPropertyMap() ));
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ]
3179 [ + - ]: 4575 : return aRef;
3180 : : }
3181 : :
3182 : 4572 : void SAL_CALL ScTableRowsObj::setPropertyValue(
3183 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
3184 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
3185 : : lang::IllegalArgumentException, lang::WrappedTargetException,
3186 : : uno::RuntimeException)
3187 : : {
3188 [ + - ]: 4572 : SolarMutexGuard aGuard;
3189 [ - + ]: 4572 : if (!pDocShell)
3190 [ # # ]: 0 : throw uno::RuntimeException();
3191 : :
3192 : 4572 : ScDocFunc& rFunc = pDocShell->GetDocFunc();
3193 : 4572 : ScDocument* pDoc = pDocShell->GetDocument();
3194 : : SCCOLROW nRowArr[2];
3195 : 4572 : nRowArr[0] = nStartRow;
3196 : 4572 : nRowArr[1] = nEndRow;
3197 [ + - ]: 4572 : String aNameString(aPropertyName);
3198 : :
3199 [ + - ][ + + ]: 4572 : if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) )
3200 : : {
3201 : 4329 : sal_Int32 nNewHeight = 0;
3202 [ + - ][ + + ]: 4329 : if ( pDoc->IsImportingXML() && ( aValue >>= nNewHeight ) )
[ + + ]
3203 : : {
3204 : : // used to set the stored row height for rows with optimal height when loading.
3205 : :
3206 : : // TODO: It's probably cleaner to use a different property name
3207 : : // for this.
3208 [ + - ]: 4321 : pDoc->SetRowHeightOnly( nStartRow, nEndRow, nTab, (sal_uInt16)HMMToTwips(nNewHeight) );
3209 : : }
3210 : : else
3211 : : {
3212 [ + - ]: 8 : sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
3213 [ - + ]: 8 : if (bOpt)
3214 [ # # ]: 4329 : rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, sal_True, sal_True );
3215 : : else
3216 : : {
3217 : : //! manually set old heights again?
3218 : : }
3219 : : }
3220 : : }
3221 [ + - ][ + + ]: 243 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLHGT ) )
3222 : : {
3223 : 173 : sal_Int32 nNewHeight = 0;
3224 [ + - ]: 173 : if ( aValue >>= nNewHeight )
3225 : : {
3226 [ + + ]: 173 : if (pDoc->IsImportingXML())
3227 : : {
3228 : : // TODO: This is a band-aid fix. Eventually we need to
3229 : : // re-work ods' style import to get it to set styles to
3230 : : // ScDocument directly.
3231 [ + - ]: 8 : pDoc->SetRowHeightOnly( nStartRow, nEndRow, nTab, (sal_uInt16)HMMToTwips(nNewHeight) );
3232 [ + - ]: 8 : pDoc->SetManualHeight( nStartRow, nEndRow, nTab, true );
3233 : : }
3234 : : else
3235 : : rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_ORIGINAL,
3236 [ + - ]: 173 : (sal_uInt16)HMMToTwips(nNewHeight), sal_True, sal_True );
3237 : : }
3238 : : }
3239 [ + - ][ + + ]: 70 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
3240 : : {
3241 [ + - ]: 32 : sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
3242 [ - + ]: 32 : ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
3243 [ + - ]: 32 : rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, eMode, 0, sal_True, sal_True );
3244 : : // SC_SIZE_DIRECT with size 0: hide
3245 : : }
3246 [ + - ][ + + ]: 38 : else if ( aNameString.EqualsAscii( SC_UNONAME_VISFLAG ) )
3247 : : {
3248 : : // #i116460# Shortcut to only set the flag, without drawing layer update etc.
3249 : : // Should only be used from import filters.
3250 [ + - ][ + - ]: 6 : pDoc->SetRowHidden(nStartRow, nEndRow, nTab, !ScUnoHelpFunctions::GetBoolFromAny( aValue ));
3251 : : }
3252 [ + - ][ + - ]: 32 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) )
3253 : : {
3254 : : //! undo etc.
3255 [ + - ][ + - ]: 32 : if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
3256 [ + - ]: 32 : pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, true);
3257 : : else
3258 [ # # ]: 0 : pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, false);
3259 : : }
3260 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE) )
[ # # ][ # # ]
[ # # ]
3261 : : {
3262 : : //! single function to set/remove all breaks?
3263 [ # # ]: 0 : sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
3264 [ # # ]: 0 : for (SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
3265 [ # # ]: 0 : if (bSet)
3266 [ # # ]: 0 : rFunc.InsertPageBreak( false, ScAddress(0,nRow,nTab), sal_True, sal_True, sal_True );
3267 : : else
3268 [ # # ]: 0 : rFunc.RemovePageBreak( false, ScAddress(0,nRow,nTab), sal_True, sal_True, sal_True );
3269 : : }
3270 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) )
[ # # ][ # # ]
[ # # ]
3271 : : {
3272 : : // #i57867# Background color is specified for row styles in the file format,
3273 : : // so it has to be supported along with the row properties (import only).
3274 : :
3275 : : // Use ScCellRangeObj to set the property for all cells in the rows
3276 : : // (this means, the "row attribute" must be set before individual cell attributes).
3277 : :
3278 : 0 : ScRange aRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab );
3279 [ # # ][ # # ]: 0 : uno::Reference<beans::XPropertySet> xRangeObj = new ScCellRangeObj( pDocShell, aRange );
3280 [ # # ][ # # ]: 0 : xRangeObj->setPropertyValue( aPropertyName, aValue );
3281 [ + - ][ + - ]: 4572 : }
3282 : 4572 : }
3283 : :
3284 : 0 : uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const rtl::OUString& aPropertyName )
3285 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
3286 : : uno::RuntimeException)
3287 : : {
3288 [ # # ]: 0 : SolarMutexGuard aGuard;
3289 [ # # ]: 0 : if (!pDocShell)
3290 [ # # ]: 0 : throw uno::RuntimeException();
3291 : :
3292 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
3293 [ # # ]: 0 : String aNameString(aPropertyName);
3294 : 0 : uno::Any aAny;
3295 : :
3296 : : //! loop over all rows for current state?
3297 : :
3298 [ # # ][ # # ]: 0 : if ( aNameString.EqualsAscii( SC_UNONAME_CELLHGT ) )
3299 : : {
3300 : : // for hidden row, return original height
3301 [ # # ]: 0 : sal_uInt16 nHeight = pDoc->GetOriginalHeight( nStartRow, nTab );
3302 [ # # ]: 0 : aAny <<= (sal_Int32)TwipsToHMM(nHeight);
3303 : : }
3304 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
3305 : : {
3306 : : SCROW nLastRow;
3307 [ # # ]: 0 : bool bVis = !pDoc->RowHidden(nStartRow, nTab, NULL, &nLastRow);
3308 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
3309 : : }
3310 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) )
3311 : : {
3312 [ # # ]: 0 : bool bVis = pDoc->RowFiltered(nStartRow, nTab);
3313 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
3314 : : }
3315 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) )
3316 : : {
3317 [ # # ]: 0 : sal_Bool bOpt = !(pDoc->GetRowFlags( nStartRow, nTab ) & CR_MANUALSIZE);
3318 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, bOpt );
3319 : : }
3320 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) )
3321 : : {
3322 [ # # ]: 0 : ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab);
3323 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
3324 : : }
3325 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
3326 : : {
3327 [ # # ]: 0 : ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab);
3328 [ # # ]: 0 : ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) );
3329 : : }
3330 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) )
[ # # ][ # # ]
[ # # ]
3331 : : {
3332 : : // Use ScCellRangeObj to get the property from the cell range
3333 : : // (for completeness only, this is not used by the XML filter).
3334 : :
3335 : 0 : ScRange aRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab );
3336 [ # # ][ # # ]: 0 : uno::Reference<beans::XPropertySet> xRangeObj = new ScCellRangeObj( pDocShell, aRange );
3337 [ # # ][ # # ]: 0 : aAny = xRangeObj->getPropertyValue( aPropertyName );
3338 : : }
3339 : :
3340 [ # # ][ # # ]: 0 : return aAny;
3341 : : }
3342 : :
3343 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableRowsObj )
3344 : :
3345 : : //------------------------------------------------------------------------
3346 : :
3347 [ # # ]: 0 : ScSpreadsheetSettingsObj::~ScSpreadsheetSettingsObj()
3348 : : {
3349 [ # # ]: 0 : if (pDocShell)
3350 [ # # ]: 0 : pDocShell->GetDocument()->RemoveUnoObject(*this);
3351 [ # # ]: 0 : }
3352 : :
3353 : 0 : void ScSpreadsheetSettingsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
3354 : : {
3355 : : // Referenz-Update interessiert hier nicht
3356 : :
3357 [ # # # # ]: 0 : if ( rHint.ISA( SfxSimpleHint ) &&
[ # # ]
3358 : 0 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
3359 : : {
3360 : 0 : pDocShell = NULL; // ungueltig geworden
3361 : : }
3362 : 0 : }
3363 : :
3364 : : // XPropertySet
3365 : :
3366 : 0 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettingsObj::getPropertySetInfo()
3367 : : throw(uno::RuntimeException)
3368 : : {
3369 : : //! muss noch
3370 : 0 : return NULL;
3371 : : }
3372 : :
3373 : 0 : void SAL_CALL ScSpreadsheetSettingsObj::setPropertyValue(
3374 : : const rtl::OUString& /* aPropertyName */, const uno::Any& /* aValue */ )
3375 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
3376 : : lang::IllegalArgumentException, lang::WrappedTargetException,
3377 : : uno::RuntimeException)
3378 : : {
3379 : : //! muss noch
3380 : 0 : }
3381 : :
3382 : 0 : uno::Any SAL_CALL ScSpreadsheetSettingsObj::getPropertyValue( const rtl::OUString& /* aPropertyName */ )
3383 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
3384 : : uno::RuntimeException)
3385 : : {
3386 : : //! muss noch
3387 : 0 : return uno::Any();
3388 : : }
3389 : :
3390 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettingsObj )
3391 : :
3392 : : //------------------------------------------------------------------------
3393 : :
3394 : 9 : ScAnnotationsObj::ScAnnotationsObj(ScDocShell* pDocSh, SCTAB nT) :
3395 : : pDocShell( pDocSh ),
3396 [ + - ]: 9 : nTab( nT )
3397 : : {
3398 [ + - ]: 9 : pDocShell->GetDocument()->AddUnoObject(*this);
3399 : 9 : }
3400 : :
3401 [ + - ]: 9 : ScAnnotationsObj::~ScAnnotationsObj()
3402 : : {
3403 [ + + ]: 9 : if (pDocShell)
3404 [ + - ]: 7 : pDocShell->GetDocument()->RemoveUnoObject(*this);
3405 [ - + ]: 18 : }
3406 : :
3407 : 11 : void ScAnnotationsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
3408 : : {
3409 : : //! nTab bei Referenz-Update anpassen!!!
3410 : :
3411 [ + - + + ]: 22 : if ( rHint.ISA( SfxSimpleHint ) &&
[ + + ]
3412 : 11 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
3413 : : {
3414 : 2 : pDocShell = NULL; // ungueltig geworden
3415 : : }
3416 : 11 : }
3417 : :
3418 : 2 : bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ) const
3419 : : {
3420 [ + - ]: 2 : if (pDocShell)
3421 : : {
3422 : 2 : sal_Int32 nFound = 0;
3423 : 2 : ScDocument* pDoc = pDocShell->GetDocument();
3424 : 2 : const ScNotes* pNotes = pDoc->GetNotes(nTab);
3425 [ + - ][ + - ]: 3 : for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
[ + - ][ + + ]
[ + - ]
3426 : : {
3427 [ + + ]: 2 : if (nFound == nIndex)
3428 : : {
3429 [ + - ][ + - ]: 1 : rPos = ScAddress( itr->first.first, itr->first.second, nTab );
3430 : 1 : return true;
3431 : : }
3432 : 1 : ++nFound;
3433 : : }
3434 : : }
3435 : 2 : return false;
3436 : : }
3437 : :
3438 : 1 : ScAnnotationObj* ScAnnotationsObj::GetObjectByIndex_Impl( sal_Int32 nIndex ) const
3439 : : {
3440 [ + - ]: 1 : if (pDocShell)
3441 : : {
3442 : 1 : ScAddress aPos;
3443 [ - + ][ + - ]: 1 : if ( GetAddressByIndex_Impl( nIndex, aPos ) )
3444 [ # # ]: 1 : return new ScAnnotationObj( pDocShell, aPos );
3445 : : }
3446 : 1 : return NULL;
3447 : : }
3448 : :
3449 : : // XSheetAnnotations
3450 : :
3451 : 5 : void SAL_CALL ScAnnotationsObj::insertNew(
3452 : : const table::CellAddress& aPosition, const ::rtl::OUString& rText )
3453 : : throw(uno::RuntimeException)
3454 : : {
3455 [ + - ]: 5 : SolarMutexGuard aGuard;
3456 [ + - ]: 5 : if (pDocShell)
3457 : : {
3458 : : OSL_ENSURE( aPosition.Sheet == nTab, "addAnnotation mit falschem Sheet" );
3459 : 5 : ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
3460 [ + - ][ + - ]: 5 : pDocShell->GetDocFunc().ReplaceNote( aPos, rText, 0, 0, sal_True );
[ + - ]
3461 [ + - ]: 5 : }
3462 : 5 : }
3463 : :
3464 : 1 : void SAL_CALL ScAnnotationsObj::removeByIndex( sal_Int32 nIndex ) throw(uno::RuntimeException)
3465 : : {
3466 [ + - ]: 1 : SolarMutexGuard aGuard;
3467 [ + - ]: 1 : if (pDocShell)
3468 : : {
3469 : 1 : ScAddress aPos;
3470 [ + - ][ + - ]: 1 : if ( GetAddressByIndex_Impl( nIndex, aPos ) )
3471 : : {
3472 [ + - ]: 1 : ScMarkData aMarkData;
3473 [ + - ]: 1 : aMarkData.SelectTable( aPos.Tab(), sal_True );
3474 [ + - ]: 1 : aMarkData.SetMultiMarkArea( ScRange(aPos) );
3475 : :
3476 [ + - ][ + - ]: 1 : pDocShell->GetDocFunc().DeleteContents( aMarkData, IDF_NOTE, sal_True, sal_True );
3477 : : }
3478 [ + - ]: 1 : }
3479 : 1 : }
3480 : :
3481 : : // XEnumerationAccess
3482 : :
3483 : 6 : uno::Reference<container::XEnumeration> SAL_CALL ScAnnotationsObj::createEnumeration()
3484 : : throw(uno::RuntimeException)
3485 : : {
3486 : : //! iterate directly (more efficiently)?
3487 : :
3488 [ + - ]: 6 : SolarMutexGuard aGuard;
3489 [ + - ][ + - ]: 6 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.CellAnnotationsEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
3490 : : }
3491 : :
3492 : : // XIndexAccess
3493 : :
3494 : 10 : sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException)
3495 : : {
3496 [ + - ]: 10 : SolarMutexGuard aGuard;
3497 : 10 : sal_uLong nCount = 0;
3498 [ + - ]: 10 : if (pDocShell)
3499 : : {
3500 : 10 : ScDocument* pDoc = pDocShell->GetDocument();
3501 [ + - ][ + - ]: 10 : nCount = pDoc->GetNotes(nTab)->size();
3502 : : }
3503 [ + - ]: 10 : return nCount;
3504 : : }
3505 : :
3506 : 1 : uno::Any SAL_CALL ScAnnotationsObj::getByIndex( sal_Int32 nIndex )
3507 : : throw(lang::IndexOutOfBoundsException,
3508 : : lang::WrappedTargetException, uno::RuntimeException)
3509 : : {
3510 [ + - ]: 1 : SolarMutexGuard aGuard;
3511 [ + - ][ - + ]: 1 : uno::Reference<sheet::XSheetAnnotation> xAnnotation(GetObjectByIndex_Impl(nIndex));
[ + - ]
3512 [ - + ]: 1 : if (xAnnotation.is())
3513 [ # # ]: 0 : return uno::makeAny(xAnnotation);
3514 : : else
3515 [ + - ][ # # ]: 1 : throw lang::IndexOutOfBoundsException();
3516 : : }
3517 : :
3518 : 0 : uno::Type SAL_CALL ScAnnotationsObj::getElementType() throw(uno::RuntimeException)
3519 : : {
3520 [ # # ]: 0 : SolarMutexGuard aGuard;
3521 [ # # ][ # # ]: 0 : return getCppuType((uno::Reference<sheet::XSheetAnnotation>*)0);
3522 : : }
3523 : :
3524 : 0 : sal_Bool SAL_CALL ScAnnotationsObj::hasElements() throw(uno::RuntimeException)
3525 : : {
3526 [ # # ]: 0 : SolarMutexGuard aGuard;
3527 [ # # ][ # # ]: 0 : return ( getCount() != 0 );
3528 : : }
3529 : :
3530 : : //------------------------------------------------------------------------
3531 : :
3532 : 2 : ScScenariosObj::ScScenariosObj(ScDocShell* pDocSh, SCTAB nT) :
3533 : : pDocShell( pDocSh ),
3534 [ + - ]: 2 : nTab ( nT )
3535 : : {
3536 [ + - ]: 2 : pDocShell->GetDocument()->AddUnoObject(*this);
3537 : 2 : }
3538 : :
3539 [ + - ]: 2 : ScScenariosObj::~ScScenariosObj()
3540 : : {
3541 [ - + ]: 2 : if (pDocShell)
3542 [ # # ]: 0 : pDocShell->GetDocument()->RemoveUnoObject(*this);
3543 [ - + ]: 4 : }
3544 : :
3545 : 3 : void ScScenariosObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
3546 : : {
3547 [ + - ]: 3 : if ( rHint.ISA( ScUpdateRefHint ) )
3548 : : {
3549 : : //! Referenz-Update fuer Tab und Start/Ende
3550 : : }
3551 [ + - + + ]: 6 : else if ( rHint.ISA( SfxSimpleHint ) &&
[ + + ]
3552 : 3 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
3553 : : {
3554 : 2 : pDocShell = NULL; // ungueltig geworden
3555 : : }
3556 : 3 : }
3557 : :
3558 : : // XScenarios
3559 : :
3560 : 0 : sal_Bool ScScenariosObj::GetScenarioIndex_Impl( const rtl::OUString& rName, SCTAB& rIndex )
3561 : : {
3562 : : //! Case-insensitiv ????
3563 : :
3564 [ # # ]: 0 : if ( pDocShell )
3565 : : {
3566 : 0 : rtl::OUString aTabName;
3567 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
3568 [ # # ]: 0 : SCTAB nCount = (SCTAB)getCount();
3569 [ # # ]: 0 : for (SCTAB i=0; i<nCount; i++)
3570 [ # # ][ # # ]: 0 : if (pDoc->GetName( nTab+i+1, aTabName ))
3571 [ # # ]: 0 : if (aTabName.equals(rName))
3572 : : {
3573 : 0 : rIndex = i;
3574 : 0 : return sal_True;
3575 [ # # ]: 0 : }
3576 : : }
3577 : :
3578 : 0 : return false;
3579 : : }
3580 : :
3581 : 2 : ScTableSheetObj* ScScenariosObj::GetObjectByIndex_Impl(sal_Int32 nIndex)
3582 : : {
3583 : 2 : sal_uInt16 nCount = (sal_uInt16)getCount();
3584 [ + - ][ + + ]: 2 : if ( pDocShell && nIndex >= 0 && nIndex < nCount )
[ + - ]
3585 [ + - ]: 1 : return new ScTableSheetObj( pDocShell, nTab+static_cast<SCTAB>(nIndex)+1 );
3586 : :
3587 : 2 : return NULL; // kein Dokument oder falscher Index
3588 : : }
3589 : :
3590 : 0 : ScTableSheetObj* ScScenariosObj::GetObjectByName_Impl(const rtl::OUString& aName)
3591 : : {
3592 : : SCTAB nIndex;
3593 [ # # ][ # # ]: 0 : if ( pDocShell && GetScenarioIndex_Impl( aName, nIndex ) )
[ # # ][ # # ]
3594 [ # # ]: 0 : return new ScTableSheetObj( pDocShell, nTab+nIndex+1 );
3595 : :
3596 : 0 : return NULL; // nicht gefunden
3597 : : }
3598 : :
3599 : 1 : void SAL_CALL ScScenariosObj::addNewByName( const rtl::OUString& aName,
3600 : : const uno::Sequence<table::CellRangeAddress>& aRanges,
3601 : : const rtl::OUString& aComment )
3602 : : throw(uno::RuntimeException)
3603 : : {
3604 [ + - ]: 1 : SolarMutexGuard aGuard;
3605 [ + - ]: 1 : if ( pDocShell )
3606 : : {
3607 [ + - ]: 1 : ScMarkData aMarkData;
3608 [ + - ]: 1 : aMarkData.SelectTable( nTab, sal_True );
3609 : :
3610 : 1 : sal_uInt16 nRangeCount = (sal_uInt16)aRanges.getLength();
3611 [ + - ]: 1 : if (nRangeCount)
3612 : : {
3613 : 1 : const table::CellRangeAddress* pAry = aRanges.getConstArray();
3614 [ + + ]: 2 : for (sal_uInt16 i=0; i<nRangeCount; i++)
3615 : : {
3616 : : OSL_ENSURE( pAry[i].Sheet == nTab, "addScenario mit falscher Tab" );
3617 : 2 : ScRange aRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
3618 : 1 : (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
3619 : :
3620 [ + - ]: 1 : aMarkData.SetMultiMarkArea( aRange );
3621 : : }
3622 : : }
3623 : :
3624 [ + - ]: 1 : String aNameStr(aName);
3625 [ + - ]: 1 : String aCommStr(aComment);
3626 : :
3627 : 1 : Color aColor( COL_LIGHTGRAY ); // Default
3628 : 1 : sal_uInt16 nFlags = SC_SCENARIO_SHOWFRAME | SC_SCENARIO_PRINTFRAME | SC_SCENARIO_TWOWAY | SC_SCENARIO_PROTECT;
3629 : :
3630 [ + - ][ + - ]: 1 : pDocShell->MakeScenario( nTab, aNameStr, aCommStr, aColor, nFlags, aMarkData );
[ + - ][ + - ]
3631 [ + - ]: 1 : }
3632 : 1 : }
3633 : :
3634 : 0 : void SAL_CALL ScScenariosObj::removeByName( const rtl::OUString& aName )
3635 : : throw(uno::RuntimeException)
3636 : : {
3637 [ # # ]: 0 : SolarMutexGuard aGuard;
3638 : : SCTAB nIndex;
3639 [ # # ][ # # ]: 0 : if ( pDocShell && GetScenarioIndex_Impl( aName, nIndex ) )
[ # # ][ # # ]
3640 [ # # ][ # # ]: 0 : pDocShell->GetDocFunc().DeleteTable( nTab+nIndex+1, sal_True, sal_True );
3641 : 0 : }
3642 : :
3643 : : // XEnumerationAccess
3644 : :
3645 : 1 : uno::Reference<container::XEnumeration> SAL_CALL ScScenariosObj::createEnumeration()
3646 : : throw(uno::RuntimeException)
3647 : : {
3648 [ + - ]: 1 : SolarMutexGuard aGuard;
3649 [ + - ][ + - ]: 1 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.ScenariosEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
3650 : : }
3651 : :
3652 : : // XIndexAccess
3653 : :
3654 : 4 : sal_Int32 SAL_CALL ScScenariosObj::getCount() throw(uno::RuntimeException)
3655 : : {
3656 [ + - ]: 4 : SolarMutexGuard aGuard;
3657 : 4 : SCTAB nCount = 0;
3658 [ + - ]: 4 : if ( pDocShell )
3659 : : {
3660 : 4 : ScDocument* pDoc = pDocShell->GetDocument();
3661 [ + - ][ + - ]: 4 : if (!pDoc->IsScenario(nTab))
3662 : : {
3663 [ + - ]: 4 : SCTAB nTabCount = pDoc->GetTableCount();
3664 : 4 : SCTAB nNext = nTab + 1;
3665 [ + + ][ + - ]: 8 : while (nNext < nTabCount && pDoc->IsScenario(nNext))
[ + - ][ + + ]
3666 : : {
3667 : 4 : ++nCount;
3668 : 4 : ++nNext;
3669 : : }
3670 : : }
3671 : : }
3672 [ + - ]: 4 : return nCount;
3673 : : }
3674 : :
3675 : 2 : uno::Any SAL_CALL ScScenariosObj::getByIndex( sal_Int32 nIndex )
3676 : : throw(lang::IndexOutOfBoundsException,
3677 : : lang::WrappedTargetException, uno::RuntimeException)
3678 : : {
3679 [ + - ]: 2 : SolarMutexGuard aGuard;
3680 [ + - ][ + + ]: 2 : uno::Reference<sheet::XScenario> xScen(GetObjectByIndex_Impl(nIndex));
[ + - ]
3681 [ + + ]: 2 : if (xScen.is())
3682 [ + - ]: 2 : return uno::makeAny(xScen);
3683 : : else
3684 [ + - ][ + - ]: 2 : throw lang::IndexOutOfBoundsException();
3685 : : }
3686 : :
3687 : 0 : uno::Type SAL_CALL ScScenariosObj::getElementType() throw(uno::RuntimeException)
3688 : : {
3689 [ # # ]: 0 : SolarMutexGuard aGuard;
3690 [ # # ][ # # ]: 0 : return getCppuType((uno::Reference<sheet::XScenario>*)0);
3691 : : }
3692 : :
3693 : 0 : sal_Bool SAL_CALL ScScenariosObj::hasElements() throw(uno::RuntimeException)
3694 : : {
3695 [ # # ]: 0 : SolarMutexGuard aGuard;
3696 [ # # ][ # # ]: 0 : return ( getCount() != 0 );
3697 : : }
3698 : :
3699 : 0 : uno::Any SAL_CALL ScScenariosObj::getByName( const rtl::OUString& aName )
3700 : : throw(container::NoSuchElementException,
3701 : : lang::WrappedTargetException, uno::RuntimeException)
3702 : : {
3703 [ # # ]: 0 : SolarMutexGuard aGuard;
3704 [ # # ][ # # ]: 0 : uno::Reference<sheet::XScenario> xScen(GetObjectByName_Impl(aName));
[ # # ]
3705 [ # # ]: 0 : if (xScen.is())
3706 [ # # ]: 0 : return uno::makeAny(xScen);
3707 : : else
3708 [ # # ][ # # ]: 0 : throw container::NoSuchElementException();
3709 : : }
3710 : :
3711 : 0 : uno::Sequence<rtl::OUString> SAL_CALL ScScenariosObj::getElementNames()
3712 : : throw(uno::RuntimeException)
3713 : : {
3714 [ # # ]: 0 : SolarMutexGuard aGuard;
3715 [ # # ]: 0 : SCTAB nCount = (SCTAB)getCount();
3716 [ # # ]: 0 : uno::Sequence<rtl::OUString> aSeq(nCount);
3717 : :
3718 [ # # ]: 0 : if ( pDocShell ) // sonst ist auch Count = 0
3719 : : {
3720 : 0 : rtl::OUString aTabName;
3721 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
3722 [ # # ]: 0 : rtl::OUString* pAry = aSeq.getArray();
3723 [ # # ]: 0 : for (SCTAB i=0; i<nCount; i++)
3724 [ # # ][ # # ]: 0 : if (pDoc->GetName( nTab+i+1, aTabName ))
3725 : 0 : pAry[i] = aTabName;
3726 : : }
3727 : :
3728 [ # # ]: 0 : return aSeq;
3729 : : }
3730 : :
3731 : 0 : sal_Bool SAL_CALL ScScenariosObj::hasByName( const rtl::OUString& aName )
3732 : : throw(uno::RuntimeException)
3733 : : {
3734 [ # # ]: 0 : SolarMutexGuard aGuard;
3735 : : SCTAB nIndex;
3736 [ # # ][ # # ]: 0 : return GetScenarioIndex_Impl( aName, nIndex );
3737 : : }
3738 : :
3739 : :
3740 : :
3741 : :
3742 : :
3743 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|