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