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