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 : : #include "confuno.hxx"
30 : : #include "unonames.hxx"
31 : : #include "scdll.hxx"
32 : : #include "docsh.hxx"
33 : : #include "miscuno.hxx"
34 : : #include "forbiuno.hxx"
35 : : #include "viewopti.hxx"
36 : : #include "docpool.hxx"
37 : : #include "sc.hrc"
38 : :
39 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
40 : : #include <sfx2/printer.hxx>
41 : : #include <xmloff/xmluconv.hxx>
42 : : #include <rtl/ustrbuf.hxx>
43 : : #include <vcl/svapp.hxx>
44 : :
45 : : using namespace com::sun::star;
46 : :
47 : : #define SCCOMPSCPREADSHEETSETTINGS_SERVICE "com.sun.star.comp.SpreadsheetSettings"
48 : : #define SCDOCUMENTSETTINGS_SERVICE "com.sun.star.document.Settings"
49 : : #define SCSAVEVERSION "SaveVersionOnClose"
50 : :
51 : :
52 : 104 : const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap()
53 : : {
54 : : static SfxItemPropertyMapEntry aConfigPropertyMap_Impl[] =
55 : : {
56 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_SHOWZERO), 0, &getBooleanCppuType(), 0, 0},
57 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_SHOWNOTES), 0, &getBooleanCppuType(), 0, 0},
58 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_SHOWGRID), 0, &getBooleanCppuType(), 0, 0},
59 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR), 0, &getCppuType((sal_Int32*)0), 0, 0},
60 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR), 0, &getBooleanCppuType(), 0, 0},
61 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_LINKUPD), 0, &getCppuType((sal_Int16*)0), 0, 0},
62 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0},
63 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0},
64 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0},
65 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_SNAPTORASTER), 0, &getBooleanCppuType(), 0, 0},
66 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_RASTERVIS), 0, &getBooleanCppuType(), 0, 0},
67 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_RASTERRESX), 0, &getCppuType((sal_Int32*)0), 0, 0},
68 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_RASTERRESY), 0, &getCppuType((sal_Int32*)0), 0, 0},
69 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_RASTERSUBX), 0, &getCppuType((sal_Int32*)0), 0, 0},
70 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_RASTERSUBY), 0, &getCppuType((sal_Int32*)0), 0, 0},
71 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_RASTERSYNC), 0, &getBooleanCppuType(), 0, 0},
72 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_AUTOCALC), 0, &getBooleanCppuType(), 0, 0},
73 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_PRINTERNAME), 0, &getCppuType((rtl::OUString*)0), 0, 0},
74 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_PRINTERSETUP), 0, &getCppuType((uno::Sequence<sal_Int8>*)0), 0, 0},
75 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_APPLYDOCINF), 0, &getBooleanCppuType(), 0, 0},
76 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_FORBIDDEN), 0, &getCppuType((uno::Reference<i18n::XForbiddenCharacters>*)0), beans::PropertyAttribute::READONLY, 0},
77 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_CHARCOMP), 0, &getCppuType((sal_Int16*)0), 0, 0},
78 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_ASIANKERN), 0, &getBooleanCppuType(), 0, 0},
79 [ + - ]: 27 : {MAP_CHAR_LEN(SCSAVEVERSION), 0, &getBooleanCppuType(), 0, 0},
80 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_UPDTEMPL), 0, &getBooleanCppuType(), 0, 0},
81 : : /*Stampit enable/disable print cancel */
82 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_ALLOWPRINTJOBCANCEL), 0, &getBooleanCppuType(), 0, 0},
83 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_LOADREADONLY), 0, &getBooleanCppuType(), 0, 0},
84 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_SHAREDOC), 0, &getBooleanCppuType(), 0, 0},
85 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNO_MODIFYPASSWORDINFO), 0, &getCppuType((uno::Sequence< beans::PropertyValue >*)0), 0, 0},
86 : : {0,0,0,0,0,0}
87 [ + + ][ + - ]: 131 : };
[ # # ]
88 : 104 : return aConfigPropertyMap_Impl;
89 : : }
90 : :
91 : : //------------------------------------------------------------------------
92 : :
93 : 104 : ScDocumentConfiguration::ScDocumentConfiguration(ScDocShell* pDocSh)
94 : : : pDocShell(pDocSh) ,
95 [ + - ][ + - ]: 104 : aPropSet ( lcl_GetConfigPropertyMap() )
[ + - ]
96 : : {
97 [ + - ]: 104 : pDocShell->GetDocument()->AddUnoObject(*this);
98 : 104 : }
99 : :
100 [ + - ][ + - ]: 104 : ScDocumentConfiguration::~ScDocumentConfiguration()
101 : : {
102 [ + + ]: 104 : if (pDocShell)
103 [ + - ]: 100 : pDocShell->GetDocument()->RemoveUnoObject(*this);
104 [ - + ]: 208 : }
105 : :
106 : 200 : void ScDocumentConfiguration::Notify( SfxBroadcaster&, const SfxHint& rHint )
107 : : {
108 : : // Referenz-Update interessiert hier nicht
109 : :
110 [ + - + + ]: 400 : if ( rHint.ISA( SfxSimpleHint ) &&
[ + + ]
111 : 200 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
112 : : {
113 : 4 : pDocShell = NULL; // ungueltig geworden
114 : : }
115 : 200 : }
116 : :
117 : : // XPropertySet
118 : :
119 : 131 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDocumentConfiguration::getPropertySetInfo()
120 : : throw(uno::RuntimeException)
121 : : {
122 [ + - ]: 131 : SolarMutexGuard aGuard;
123 : : static uno::Reference<beans::XPropertySetInfo> aRef(
124 [ + + ][ + - ]: 131 : new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
[ + - ][ + - ]
[ + - ][ # # ]
125 [ + - ]: 131 : return aRef;
126 : : }
127 : :
128 : 2567 : void SAL_CALL ScDocumentConfiguration::setPropertyValue(
129 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
130 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
131 : : lang::IllegalArgumentException, lang::WrappedTargetException,
132 : : uno::RuntimeException)
133 : : {
134 [ + - ]: 2567 : SolarMutexGuard aGuard;
135 : :
136 [ + - ]: 2567 : if(pDocShell)
137 : : {
138 : 2567 : ScDocument* pDoc = pDocShell->GetDocument();
139 [ + - ]: 2567 : if (pDoc)
140 : : {
141 : 2567 : sal_Bool bUpdateHeights = false;
142 : :
143 [ + - ][ + - ]: 2567 : ScViewOptions aViewOpt(pDoc->GetViewOptions());
144 : :
145 : : /*Stampit enable/disable print cancel */
146 [ + + ]: 2567 : if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
147 [ + - ][ + - ]: 90 : pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
148 : : /*Stampit enable/disable print cancel */
149 : :
150 [ + + ]: 2477 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
151 [ + - ]: 96 : aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
152 [ + + ]: 2381 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
153 [ + - ]: 96 : aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
154 [ + + ]: 2285 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
155 [ + - ]: 96 : aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
156 [ + + ]: 2189 : else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
157 : : {
158 : 96 : sal_Int64 nColor = 0;
159 [ + - ]: 96 : if (aValue >>= nColor)
160 : : {
161 [ + - ]: 96 : String aColorName;
162 : 96 : Color aColor(static_cast<sal_uInt32>(nColor));
163 [ + - ][ + - ]: 96 : aViewOpt.SetGridColor(aColor, aColorName);
164 : : }
165 : : }
166 [ + + ]: 2093 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
167 [ + - ]: 96 : aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
168 [ + + ]: 1997 : else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
169 [ + - ]: 95 : pDoc->SetLinkMode( static_cast<ScLkUpdMode> ( ScUnoHelpFunctions::GetInt16FromAny( aValue ) ) );
170 [ + + ]: 1902 : else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
171 [ + - ]: 96 : aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
172 [ + + ]: 1806 : else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
173 [ + - ]: 96 : aViewOpt.SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
174 [ + + ]: 1710 : else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
175 [ + - ]: 96 : aViewOpt.SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
176 [ + + ]: 1614 : else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
177 [ + - ][ + - ]: 95 : pDoc->SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
178 [ + + ]: 1519 : else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
179 : : {
180 : 93 : rtl::OUString sPrinterName;
181 [ + - ]: 93 : if ( aValue >>= sPrinterName )
182 : : {
183 : : // #i75610# if the name is empty, do nothing (don't create any printer)
184 [ + + ][ + + ]: 93 : if ( !sPrinterName.isEmpty() && pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
[ + + ]
185 : : {
186 [ + - ]: 4 : SfxPrinter* pPrinter = pDocShell->GetPrinter();
187 [ + - ]: 4 : if (pPrinter)
188 : : {
189 [ + + ]: 4 : if (pPrinter->GetName() != sPrinterName)
190 : : {
191 [ + - ][ + - ]: 1 : SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
[ + - ][ + - ]
[ + - ]
192 [ - + ]: 1 : if (pNewPrinter->IsKnown())
193 [ # # ]: 0 : pDocShell->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER );
194 : : else
195 [ + - ][ + - ]: 1 : delete pNewPrinter;
196 : : }
197 : : }
198 : : else
199 [ # # ]: 0 : throw uno::RuntimeException();
200 : : }
201 : : }
202 : : else
203 [ # # ]: 93 : throw lang::IllegalArgumentException();
204 : : }
205 [ + + ]: 1426 : else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
206 : : {
207 [ + - ]: 95 : uno::Sequence<sal_Int8> aSequence;
208 [ + - ][ + - ]: 95 : if ( aValue >>= aSequence )
209 : : {
210 : 95 : sal_uInt32 nSize = aSequence.getLength();
211 : : // #i75610# if the sequence is empty, do nothing (don't create any printer)
212 [ + + ]: 95 : if ( nSize != 0 )
213 : : {
214 [ + - ][ + - ]: 12 : SvMemoryStream aStream (aSequence.getArray(), nSize, STREAM_READ );
215 [ + - ]: 12 : aStream.Seek ( STREAM_SEEK_TO_BEGIN );
216 [ + - ]: 12 : SfxItemSet* pSet = new SfxItemSet( *pDoc->GetPool(),
217 : : SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
218 : : SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
219 : : SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET,
220 : : SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
221 [ + - ][ + - ]: 12 : NULL );
222 [ + - ][ + - ]: 12 : pDocShell->SetPrinter( SfxPrinter::Create( aStream, pSet ) );
[ + - ]
223 : : }
224 [ + - ]: 95 : }
225 : : }
226 [ + + ]: 1331 : else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
227 : : {
228 : 95 : sal_Bool bTmp=sal_True;
229 [ + - ]: 95 : if ( aValue >>= bTmp )
230 [ + - ]: 95 : pDocShell->SetUseUserData( bTmp );
231 : : }
232 [ + + ]: 1236 : else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
233 : : {
234 : : // read-only - should not be set
235 : : }
236 [ + + ]: 1233 : else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
237 : : {
238 : : // Int16 contains CharacterCompressionType values
239 [ + - ]: 95 : sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue );
240 [ + - ]: 95 : pDoc->SetAsianCompression( (sal_uInt8) nUno );
241 : 95 : bUpdateHeights = sal_True;
242 : : }
243 [ + + ]: 1138 : else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
244 : : {
245 [ + - ][ + - ]: 95 : pDoc->SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
246 : 95 : bUpdateHeights = sal_True;
247 : : }
248 [ + + ]: 1043 : else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
249 : : {
250 : 95 : sal_Bool bTmp=false;
251 [ + - ]: 95 : if ( aValue >>= bTmp )
252 [ + - ]: 95 : pDocShell->SetSaveVersionOnClose( bTmp );
253 : : }
254 [ + + ]: 948 : else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
255 : : {
256 : 95 : sal_Bool bTmp=sal_True;
257 [ + - ]: 95 : if ( aValue >>= bTmp )
258 [ + - ]: 95 : pDocShell->SetQueryLoadTemplate( bTmp );
259 : : }
260 [ + + ]: 853 : else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
261 : : {
262 : 90 : sal_Bool bTmp=false;
263 [ + - ]: 90 : if ( aValue >>= bTmp )
264 [ + - ]: 90 : pDocShell->SetLoadReadonly( bTmp );
265 : : }
266 [ + + ]: 763 : else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
267 : : {
268 : 89 : sal_Bool bDocShared = false;
269 [ + - ]: 89 : if ( aValue >>= bDocShared )
270 : : {
271 [ + - ]: 89 : pDocShell->SetSharedXMLFlag( bDocShared );
272 : : }
273 : : }
274 [ + + ]: 674 : else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
275 : : {
276 [ + - ]: 2 : uno::Sequence< beans::PropertyValue > aInfo;
277 [ + - ][ - + ]: 2 : if ( !( aValue >>= aInfo ) )
278 : : throw lang::IllegalArgumentException(
279 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type Sequence<PropertyValue> expected!" ) ),
280 : : uno::Reference< uno::XInterface >(),
281 [ # # ][ # # ]: 0 : 2 );
282 : :
283 [ + - ][ - + ]: 2 : if ( !pDocShell->SetModifyPasswordInfo( aInfo ) )
284 : : throw beans::PropertyVetoException(
285 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ),
286 [ # # ][ # # ]: 2 : uno::Reference< uno::XInterface >() );
[ + - ]
287 : : }
288 : : else
289 : : {
290 : 672 : ScGridOptions aGridOpt(aViewOpt.GetGridOptions());
291 [ + + ]: 672 : if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
292 [ + - ]: 96 : aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
293 [ + + ]: 576 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
294 [ + - ]: 96 : aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
295 [ + + ]: 480 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
296 [ + - ]: 96 : aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
297 [ + + ]: 384 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
298 [ + - ]: 96 : aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
299 [ + + ]: 288 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
300 [ + - ]: 96 : aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
301 [ + + ]: 192 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
302 [ + - ]: 96 : aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
303 [ + - ]: 96 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
304 [ + - ]: 96 : aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
305 : : else
306 [ # # ]: 0 : throw beans::UnknownPropertyException();
307 [ + - ][ + - ]: 672 : aViewOpt.SetGridOptions(aGridOpt);
308 : : }
309 [ + - ]: 2567 : pDoc->SetViewOptions(aViewOpt);
310 : :
311 [ + + ][ + + ]: 2567 : if ( bUpdateHeights && !pDoc->IsImportingXML() )
[ + + ]
312 : : {
313 : : // update automatic row heights and repaint
314 [ + - ]: 4 : SCTAB nTabCount = pDoc->GetTableCount();
315 [ + + ]: 8 : for (SCTAB nTab=0; nTab<nTabCount; nTab++)
316 [ + - ][ + + ]: 4 : if ( !pDocShell->AdjustRowHeight( 0, MAXROW, nTab ) )
317 [ + - ][ + - ]: 3 : pDocShell->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PAINT_GRID);
[ + - ]
318 [ + - ]: 4 : pDocShell->SetDocumentModified();
319 [ + - ]: 2567 : }
320 : : }
321 : : else
322 [ # # ]: 0 : throw uno::RuntimeException();
323 : : }
324 : : else
325 [ + - ][ # # ]: 2567 : throw uno::RuntimeException();
326 : 2567 : }
327 : :
328 : 284 : uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const rtl::OUString& aPropertyName )
329 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
330 : : uno::RuntimeException)
331 : : {
332 [ + - ]: 284 : SolarMutexGuard aGuard;
333 : 284 : uno::Any aRet;
334 : :
335 [ + - ]: 284 : if(pDocShell)
336 : : {
337 : 284 : ScDocument* pDoc = pDocShell->GetDocument();
338 [ + - ]: 284 : if (pDoc)
339 : : {
340 [ + - ]: 284 : const ScViewOptions& aViewOpt = pDoc->GetViewOptions();
341 : :
342 : : /*Stampit enable/disable print cancel */
343 [ + + ]: 284 : if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
344 [ + - ][ + - ]: 9 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->Stamp_GetPrintCancelState() );
345 : : /*Stampit enable/disable print cancel */
346 : :
347 [ + + ]: 275 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
348 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NULLVALS ) );
349 [ + + ]: 264 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
350 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NOTES ) );
351 [ + + ]: 253 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
352 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_GRID ) );
353 [ + + ]: 242 : else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
354 : : {
355 [ + - ]: 11 : String aColorName;
356 [ + - ]: 11 : Color aColor = aViewOpt.GetGridColor(&aColorName);
357 [ + - ][ + - ]: 11 : aRet <<= static_cast<sal_Int64>(aColor.GetColor());
358 : : }
359 [ + + ]: 231 : else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
360 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_PAGEBREAKS ) );
361 [ + + ]: 220 : else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
362 [ + - ][ + - ]: 9 : aRet <<= static_cast<sal_Int16> ( pDoc->GetLinkMode() );
363 [ + + ]: 211 : else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
364 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_HEADER ) );
365 [ + + ]: 200 : else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
366 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_TABCONTROLS ) );
367 [ + + ]: 189 : else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
368 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_OUTLINER ) );
369 [ + + ]: 178 : else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
370 [ + - ]: 9 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAutoCalc() );
371 [ + + ]: 169 : else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
372 : : {
373 : : // #i75610# don't create the printer, return empty string if no printer created yet
374 : : // (as in SwXDocumentSettings)
375 [ + - ]: 4 : SfxPrinter* pPrinter = pDoc->GetPrinter( false );
376 [ - + ]: 4 : if (pPrinter)
377 [ # # ]: 0 : aRet <<= rtl::OUString ( pPrinter->GetName());
378 : : else
379 [ + - ]: 4 : aRet <<= rtl::OUString();
380 : : }
381 [ + + ]: 165 : else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
382 : : {
383 : : // #i75610# don't create the printer, return empty sequence if no printer created yet
384 : : // (as in SwXDocumentSettings)
385 [ + - ]: 9 : SfxPrinter* pPrinter = pDoc->GetPrinter( false );
386 [ - + ]: 9 : if (pPrinter)
387 : : {
388 [ # # ]: 0 : SvMemoryStream aStream;
389 [ # # ]: 0 : pPrinter->Store( aStream );
390 [ # # ]: 0 : aStream.Seek ( STREAM_SEEK_TO_END );
391 : 0 : sal_uInt32 nSize = aStream.Tell();
392 [ # # ]: 0 : aStream.Seek ( STREAM_SEEK_TO_BEGIN );
393 [ # # ]: 0 : uno::Sequence < sal_Int8 > aSequence( nSize );
394 [ # # ][ # # ]: 0 : aStream.Read ( aSequence.getArray(), nSize );
395 [ # # ][ # # ]: 0 : aRet <<= aSequence;
[ # # ]
396 : : }
397 : : else
398 [ + - ][ + - ]: 9 : aRet <<= uno::Sequence<sal_Int8>();
[ + - ]
399 : : }
400 [ + + ]: 156 : else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
401 [ + - ][ + - ]: 9 : aRet <<= pDocShell->IsUseUserData();
402 [ + + ]: 147 : else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
403 : : {
404 [ + - ][ + - ]: 7 : aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell ));
[ + - ][ + - ]
405 : : }
406 [ + + ]: 140 : else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
407 [ + - ][ + - ]: 9 : aRet <<= static_cast<sal_Int16> ( pDoc->GetAsianCompression() );
408 [ + + ]: 131 : else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
409 [ + - ][ + - ]: 9 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAsianKerning() );
410 [ + + ]: 122 : else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
411 [ + - ][ + - ]: 9 : aRet <<= pDocShell->IsSaveVersionOnClose();
412 [ + + ]: 113 : else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
413 [ + - ][ + - ]: 9 : aRet <<= pDocShell->IsQueryLoadTemplate();
414 [ + + ]: 104 : else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
415 [ + - ][ + - ]: 9 : aRet <<= pDocShell->IsLoadReadonly();
416 [ + + ]: 95 : else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
417 : : {
418 [ + - ][ + - ]: 9 : ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasSharedXMLFlagSet() );
419 : : }
420 [ + + ]: 86 : else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
421 [ + - ][ + - ]: 9 : aRet <<= pDocShell->GetModifyPasswordInfo();
[ + - ]
422 : : else
423 : : {
424 : 77 : const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions();
425 [ + + ]: 77 : if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
426 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetUseGridSnap() );
427 [ + + ]: 66 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
428 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetGridVisible() );
429 [ + + ]: 55 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
430 [ + - ]: 11 : aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
431 [ + + ]: 44 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
432 [ + - ]: 11 : aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
433 [ + + ]: 33 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
434 [ + - ]: 11 : aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
435 [ + + ]: 22 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
436 [ + - ]: 11 : aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
437 [ + - ]: 11 : else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
438 [ + - ]: 11 : ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetSynchronize() );
439 : : else
440 [ # # ]: 0 : throw beans::UnknownPropertyException();
441 : : }
442 : : }
443 : : else
444 [ # # ]: 0 : throw uno::RuntimeException();
445 : : }
446 : : else
447 [ # # ]: 0 : throw uno::RuntimeException();
448 : :
449 [ + - ]: 284 : return aRet;
450 : : }
451 : :
452 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocumentConfiguration )
453 : :
454 : : // XServiceInfo
455 : :
456 : 1 : rtl::OUString SAL_CALL ScDocumentConfiguration::getImplementationName() throw(uno::RuntimeException)
457 : : {
458 : 1 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ScDocumentConfiguration" ));
459 : : }
460 : :
461 : 1 : sal_Bool SAL_CALL ScDocumentConfiguration::supportsService( const rtl::OUString& rServiceName )
462 : : throw(uno::RuntimeException)
463 : : {
464 [ + - ]: 1 : String aServiceStr( rServiceName );
465 [ + - ]: 1 : return aServiceStr.EqualsAscii( SCCOMPSCPREADSHEETSETTINGS_SERVICE ) ||
466 [ + - ][ + - ]: 1 : aServiceStr.EqualsAscii( SCDOCUMENTSETTINGS_SERVICE );
[ - + ][ + - ]
467 : : }
468 : :
469 : 0 : uno::Sequence<rtl::OUString> SAL_CALL ScDocumentConfiguration::getSupportedServiceNames()
470 : : throw(uno::RuntimeException)
471 : : {
472 : 0 : uno::Sequence<rtl::OUString> aRet(2);
473 [ # # ]: 0 : rtl::OUString* pArray = aRet.getArray();
474 [ # # ]: 0 : pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCCOMPSCPREADSHEETSETTINGS_SERVICE ));
475 [ # # ]: 0 : pArray[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCDOCUMENTSETTINGS_SERVICE ));
476 : 0 : return aRet;
477 : : }
478 : :
479 : : //-------------------------------------------------------------------------
480 : :
481 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|