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