bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / uno / SwXDocumentSettings.cxx
blob080f3b722cf865dcc9b73e565e6696a13966172d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <osl/mutex.hxx>
22 #include <sfx2/sfxbasecontroller.hxx>
23 #include <SwXDocumentSettings.hxx>
24 #include <comphelper/MasterPropertySetInfo.hxx>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
27 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
28 #include <doc.hxx>
29 #include <docsh.hxx>
30 #include <fldupde.hxx>
31 #include <linkenum.hxx>
32 #include <sfx2/printer.hxx>
33 #include <editsh.hxx>
34 #include <drawdoc.hxx>
35 #include <svl/zforlist.hxx>
36 #include <unotxdoc.hxx>
37 #include <cmdid.h>
38 #include <sfx2/zoomitem.hxx>
39 #include <unomod.hxx>
40 #include <vcl/svapp.hxx>
41 #include <comphelper/servicehelper.hxx>
43 #include "swmodule.hxx"
44 #include "cfgitems.hxx"
45 #include "prtopt.hxx"
48 using namespace comphelper;
49 using namespace ::com::sun::star;
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::beans;
52 using namespace ::com::sun::star::lang;
53 using namespace ::com::sun::star::i18n;
55 enum SwDocumentSettingsPropertyHandles
57 HANDLE_FORBIDDEN_CHARS,
58 HANDLE_LINK_UPDATE_MODE,
59 HANDLE_FIELD_AUTO_UPDATE,
60 HANDLE_CHART_AUTO_UPDATE,
61 HANDLE_ADD_PARA_TABLE_SPACING,
62 HANDLE_ADD_PARA_TABLE_SPACING_AT_START,
63 HANDLE_ALIGN_TAB_STOP_POSITION,
64 HANDLE_PRINTER_NAME,
65 HANDLE_PRINTER_SETUP,
66 HANDLE_IS_KERN_ASIAN_PUNCTUATION,
67 HANDLE_CHARACTER_COMPRESSION_TYPE,
68 HANDLE_APPLY_USER_DATA,
69 HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS,
70 HANDLE_CURRENT_DATABASE_DATA_SOURCE,
71 HANDLE_CURRENT_DATABASE_COMMAND,
72 HANDLE_CURRENT_DATABASE_COMMAND_TYPE,
73 HANDLE_SAVE_VERSION_ON_CLOSE,
74 HANDLE_IS_GRID_VISIBLE,
75 HANDLE_IS_SNAP_TO_GRID,
76 HANDLE_IS_SYNCHRONISE_AXES,
77 HANDLE_HORIZONTAL_GRID_RESOLUTION,
78 HANDLE_HORIZONTAL_GRID_SUBDIVISION,
79 HANDLE_VERTICAL_GRID_RESOLUTION,
80 HANDLE_VERTICAL_GRID_SUBDIVISION,
81 HANDLE_UPDATE_FROM_TEMPLATE,
82 HANDLE_PRINTER_INDEPENDENT_LAYOUT,
83 HANDLE_IS_LABEL_DOC,
84 HANDLE_IS_ADD_FLY_OFFSET,
85 HANDLE_IS_ADD_EXTERNAL_LEADING,
86 HANDLE_OLD_NUMBERING, // #111955#
87 HANDLE_OUTLINELEVEL_YIELDS_NUMBERING,
88 /* Stampit It disable the print cancel button of the shown progress dialog. */
89 HANDLE_ALLOW_PRINTJOB_CANCEL,
90 HANDLE_USE_FORMER_LINE_SPACING,
91 HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS,
92 HANDLE_USE_FORMER_OBJECT_POSITIONING,
93 HANDLE_USE_FORMER_TEXT_WRAPPING,
94 HANDLE_CHANGES_PASSWORD,
95 HANDLE_CONSIDER_WRAP_ON_OBJPOS,
96 HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING,
97 HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK,
98 HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT,
99 HANDLE_TABLE_ROW_KEEP,
100 HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION,
101 HANDLE_LOAD_READONLY,
102 HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE,
103 HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES,
104 HANDLE_UNIX_FORCE_ZERO_EXT_LEADING,
105 HANDLE_USE_OLD_PRINTER_METRICS,
106 HANDLE_PROTECT_FORM,
107 HANDLE_TABS_RELATIVE_TO_INDENT,
108 HANDLE_RSID,
109 HANDLE_RSID_ROOT,
110 // #i89181#
111 HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
112 HANDLE_MODIFYPASSWORDINFO,
113 HANDLE_MATH_BASELINE_ALIGNMENT,
114 HANDLE_INVERT_BORDER_SPACING,
115 HANDLE_COLLAPSE_EMPTY_CELL_PARA,
116 HANDLE_SMALL_CAPS_PERCENTAGE_66,
117 HANDLE_TAB_OVERFLOW,
118 HANDLE_UNBREAKABLE_NUMBERINGS,
119 HANDLE_STYLES_NODEFAULT,
120 HANDLE_FLOATTABLE_NOMARGINS,
121 HANDLE_CLIPPED_PICTURES,
122 HANDLE_BACKGROUND_PARA_OVER_DRAWINGS,
123 HANDLE_EMBED_FONTS,
124 HANDLE_EMBED_SYSTEM_FONTS,
125 HANDLE_TAB_OVER_MARGIN,
128 static MasterPropertySetInfo * lcl_createSettingsInfo()
130 static PropertyInfo aWriterSettingsInfoMap[] =
132 { RTL_CONSTASCII_STRINGPARAM("ForbiddenCharacters"), HANDLE_FORBIDDEN_CHARS, CPPUTYPE_REFFORBCHARS, 0, 0},
133 { RTL_CONSTASCII_STRINGPARAM("LinkUpdateMode"), HANDLE_LINK_UPDATE_MODE, CPPUTYPE_INT16, 0, 0},
134 { RTL_CONSTASCII_STRINGPARAM("FieldAutoUpdate"), HANDLE_FIELD_AUTO_UPDATE, CPPUTYPE_BOOLEAN, 0, 0},
135 { RTL_CONSTASCII_STRINGPARAM("ChartAutoUpdate"), HANDLE_CHART_AUTO_UPDATE, CPPUTYPE_BOOLEAN, 0, 0},
136 { RTL_CONSTASCII_STRINGPARAM("AddParaTableSpacing"), HANDLE_ADD_PARA_TABLE_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
137 { RTL_CONSTASCII_STRINGPARAM("AddParaTableSpacingAtStart"), HANDLE_ADD_PARA_TABLE_SPACING_AT_START, CPPUTYPE_BOOLEAN, 0, 0},
138 { RTL_CONSTASCII_STRINGPARAM("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, CPPUTYPE_BOOLEAN, 0, 0},
139 { RTL_CONSTASCII_STRINGPARAM("PrinterName"), HANDLE_PRINTER_NAME, CPPUTYPE_OUSTRING, 0, 0},
140 { RTL_CONSTASCII_STRINGPARAM("PrinterSetup"), HANDLE_PRINTER_SETUP, CPPUTYPE_SEQINT8, 0, 0},
141 { RTL_CONSTASCII_STRINGPARAM("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, CPPUTYPE_BOOLEAN, 0, 0},
142 { RTL_CONSTASCII_STRINGPARAM("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, CPPUTYPE_INT16, 0, 0},
143 { RTL_CONSTASCII_STRINGPARAM("ApplyUserData"), HANDLE_APPLY_USER_DATA, CPPUTYPE_BOOLEAN, 0, 0},
144 { RTL_CONSTASCII_STRINGPARAM("SaveGlobalDocumentLinks"), HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, CPPUTYPE_BOOLEAN, 0, 0},
145 { RTL_CONSTASCII_STRINGPARAM("CurrentDatabaseDataSource"), HANDLE_CURRENT_DATABASE_DATA_SOURCE, CPPUTYPE_OUSTRING, 0, 0},
146 { RTL_CONSTASCII_STRINGPARAM("CurrentDatabaseCommand"), HANDLE_CURRENT_DATABASE_COMMAND, CPPUTYPE_OUSTRING, 0, 0},
147 { RTL_CONSTASCII_STRINGPARAM("CurrentDatabaseCommandType"), HANDLE_CURRENT_DATABASE_COMMAND_TYPE, CPPUTYPE_INT32, 0, 0},
148 { RTL_CONSTASCII_STRINGPARAM("SaveVersionOnClose"), HANDLE_SAVE_VERSION_ON_CLOSE, CPPUTYPE_BOOLEAN, 0, 0},
149 { RTL_CONSTASCII_STRINGPARAM("UpdateFromTemplate"), HANDLE_UPDATE_FROM_TEMPLATE, CPPUTYPE_BOOLEAN, 0, 0},
151 { RTL_CONSTASCII_STRINGPARAM("PrinterIndependentLayout"), HANDLE_PRINTER_INDEPENDENT_LAYOUT, CPPUTYPE_INT16, 0, 0},
152 { RTL_CONSTASCII_STRINGPARAM("IsLabelDocument"), HANDLE_IS_LABEL_DOC, CPPUTYPE_BOOLEAN, 0, 0},
153 { RTL_CONSTASCII_STRINGPARAM("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, CPPUTYPE_BOOLEAN, 0, 0},
154 { RTL_CONSTASCII_STRINGPARAM("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, CPPUTYPE_BOOLEAN, 0, 0},
155 { RTL_CONSTASCII_STRINGPARAM("UseOldNumbering"), HANDLE_OLD_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0}, // #111955#
156 { RTL_CONSTASCII_STRINGPARAM("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0},
157 /* Stampit It disable the print cancel button of the shown progress dialog. */
158 { RTL_CONSTASCII_STRINGPARAM("AllowPrintJobCancel"), HANDLE_ALLOW_PRINTJOB_CANCEL, CPPUTYPE_BOOLEAN, 0, 0},
159 { RTL_CONSTASCII_STRINGPARAM("UseFormerLineSpacing"), HANDLE_USE_FORMER_LINE_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
160 { RTL_CONSTASCII_STRINGPARAM("AddParaSpacingToTableCells"), HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, CPPUTYPE_BOOLEAN, 0, 0},
161 { RTL_CONSTASCII_STRINGPARAM("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, CPPUTYPE_BOOLEAN, 0, 0},
162 { RTL_CONSTASCII_STRINGPARAM("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, CPPUTYPE_BOOLEAN, 0, 0},
163 { RTL_CONSTASCII_STRINGPARAM("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, CPPUTYPE_SEQINT8, 0, 0},
164 { RTL_CONSTASCII_STRINGPARAM("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, CPPUTYPE_BOOLEAN, 0, 0},
165 { RTL_CONSTASCII_STRINGPARAM("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0},
166 { RTL_CONSTASCII_STRINGPARAM("DoNotJustifyLinesWithManualBreak"), HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, CPPUTYPE_BOOLEAN, 0, 0},
167 { RTL_CONSTASCII_STRINGPARAM("DoNotResetParaAttrsForNumFont"), HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, CPPUTYPE_BOOLEAN, 0, 0},
168 { RTL_CONSTASCII_STRINGPARAM("TableRowKeep"), HANDLE_TABLE_ROW_KEEP, CPPUTYPE_BOOLEAN, 0, 0},
169 { RTL_CONSTASCII_STRINGPARAM("IgnoreTabsAndBlanksForLineCalculation"), HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, CPPUTYPE_BOOLEAN, 0, 0},
170 { RTL_CONSTASCII_STRINGPARAM("LoadReadonly"), HANDLE_LOAD_READONLY, CPPUTYPE_BOOLEAN, 0, 0},
171 { RTL_CONSTASCII_STRINGPARAM("DoNotCaptureDrawObjsOnPage"), HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, CPPUTYPE_BOOLEAN, 0, 0},
172 { RTL_CONSTASCII_STRINGPARAM("ClipAsCharacterAnchoredWriterFlyFrames"), HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, CPPUTYPE_BOOLEAN, 0, 0},
173 { RTL_CONSTASCII_STRINGPARAM("UnxForceZeroExtLeading"), HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, CPPUTYPE_BOOLEAN, 0, 0},
174 { RTL_CONSTASCII_STRINGPARAM("UseOldPrinterMetrics"), HANDLE_USE_OLD_PRINTER_METRICS, CPPUTYPE_BOOLEAN, 0, 0},
175 { RTL_CONSTASCII_STRINGPARAM("TabsRelativeToIndent"), HANDLE_TABS_RELATIVE_TO_INDENT, CPPUTYPE_BOOLEAN, 0, 0},
176 { RTL_CONSTASCII_STRINGPARAM("Rsid"), HANDLE_RSID, CPPUTYPE_INT32, 0, 0},
177 { RTL_CONSTASCII_STRINGPARAM("RsidRoot"), HANDLE_RSID_ROOT, CPPUTYPE_INT32, 0, 0},
178 { RTL_CONSTASCII_STRINGPARAM("ProtectForm"), HANDLE_PROTECT_FORM, CPPUTYPE_BOOLEAN, 0, 0},
179 // #i89181#
180 { RTL_CONSTASCII_STRINGPARAM("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, CPPUTYPE_BOOLEAN, 0, 0},
181 { RTL_CONSTASCII_STRINGPARAM("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, CPPUTYPE_PROPERTYVALUE, 0, 0},
182 { RTL_CONSTASCII_STRINGPARAM("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, CPPUTYPE_BOOLEAN, 0, 0},
183 { RTL_CONSTASCII_STRINGPARAM("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
184 { RTL_CONSTASCII_STRINGPARAM("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, CPPUTYPE_BOOLEAN, 0, 0},
185 { RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, CPPUTYPE_BOOLEAN, 0, 0},
186 { RTL_CONSTASCII_STRINGPARAM("TabOverflow"), HANDLE_TAB_OVERFLOW, CPPUTYPE_BOOLEAN, 0, 0},
187 { RTL_CONSTASCII_STRINGPARAM("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, CPPUTYPE_BOOLEAN, 0, 0},
188 { RTL_CONSTASCII_STRINGPARAM("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, CPPUTYPE_BOOLEAN, 0, 0},
189 { RTL_CONSTASCII_STRINGPARAM("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, CPPUTYPE_BOOLEAN, 0, 0},
190 { RTL_CONSTASCII_STRINGPARAM("ClippedPictures"), HANDLE_CLIPPED_PICTURES, CPPUTYPE_BOOLEAN, 0, 0},
191 { RTL_CONSTASCII_STRINGPARAM("BackgroundParaOverDrawings"), HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, CPPUTYPE_BOOLEAN, 0, 0},
192 { RTL_CONSTASCII_STRINGPARAM("EmbedFonts"), HANDLE_EMBED_FONTS, CPPUTYPE_BOOLEAN, 0, 0},
193 { RTL_CONSTASCII_STRINGPARAM("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, CPPUTYPE_BOOLEAN, 0, 0},
194 { RTL_CONSTASCII_STRINGPARAM("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, CPPUTYPE_BOOLEAN, 0, 0},
196 * As OS said, we don't have a view when we need to set this, so I have to
197 * find another solution before adding them to this property set - MTG
198 { RTL_CONSTASCII_STRINGPARAM("IsGridVisible"), HANDLE_IS_GRID_VISIBLE, CPPUTYPE_BOOLEAN, 0, 0},
199 { RTL_CONSTASCII_STRINGPARAM("IsSnapToGrid"), HANDLE_IS_SNAP_TO_GRID, CPPUTYPE_BOOLEAN, 0, 0},
200 { RTL_CONSTASCII_STRINGPARAM("IsSynchroniseAxes"), HANDLE_IS_SYNCHRONISE_AXES, CPPUTYPE_BOOLEAN, 0, 0},
201 { RTL_CONSTASCII_STRINGPARAM("HorizontalGridResolution"), HANDLE_HORIZONTAL_GRID_RESOLUTION, CPPUTYPE_INT32, 0, 0},
202 { RTL_CONSTASCII_STRINGPARAM("HorizontalGridSubdivision"), HANDLE_HORIZONTAL_GRID_SUBDIVISION, CPPUTYPE_INT16, 0, 0},
203 { RTL_CONSTASCII_STRINGPARAM("VerticalGridResolution"), HANDLE_VERTICAL_GRID_RESOLUTION, CPPUTYPE_INT32, 0, 0},
204 { RTL_CONSTASCII_STRINGPARAM("VerticalGridSubdivision"), HANDLE_VERTICAL_GRID_SUBDIVISION, CPPUTYPE_INT16, 0, 0},
206 { RTL_CONSTASCII_STRINGPARAM("ShowParagraphEnd"), HANDLE_SHOW_PARAGRAPH_END, CPPUTYPE_BOOLEAN, 0, 0},
207 { RTL_CONSTASCII_STRINGPARAM("ShowOptionalHyphens"), HANDLE_SHOW_OPTIONAL_HYPHENS, CPPUTYPE_BOOLEAN, 0, 0},
208 { RTL_CONSTASCII_STRINGPARAM("ShowSpaces"), HANDLE_SHOW_SPACES, CPPUTYPE_BOOLEAN, 0, 0},
209 { RTL_CONSTASCII_STRINGPARAM("ShowTabs"), HANDLE_SHOW_TABS, CPPUTYPE_BOOLEAN, 0, 0},
210 { RTL_CONSTASCII_STRINGPARAM("ShowBreaks"), HANDLE_SHOW_BREAKS, CPPUTYPE_BOOLEAN, 0, 0},
211 { RTL_CONSTASCII_STRINGPARAM("ShowHiddenText"), HANDLE_SHOW_HIDDEN_TEXT, CPPUTYPE_BOOLEAN, 0, 0},
212 { RTL_CONSTASCII_STRINGPARAM("ShowHiddenParagraphs"), HANDLE_SHOW_HIDDEN_PARAGRAPHS, CPPUTYPE_BOOLEAN, 0, 0},
214 { RTL_CONSTASCII_STRINGPARAM("ShowTextLimitGuide"), HANDLE_SHOW_TEXT_LIMIT_GUIDE, CPPUTYPE_BOOLEAN, 0, 0},
215 { RTL_CONSTASCII_STRINGPARAM("ShowTableLimitGuide"), HANDLE_SHOW_TABLE_LIMIT_GUIDE, CPPUTYPE_BOOLEAN, 0, 0},
216 { RTL_CONSTASCII_STRINGPARAM("ShowSectionLimitGuide"), HANDLE_SHOW_SECTION_LIMIT_GUIDE, CPPUTYPE_BOOLEAN, 0, 0},
217 { RTL_CONSTASCII_STRINGPARAM("ShowGuidesWhileMoving"), HANDLE_SHOW_GUIDES_WHILE_MOVING, CPPUTYPE_BOOLEAN, 0, 0},
219 { NULL, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
221 return new MasterPropertySetInfo ( aWriterSettingsInfoMap );
224 SwXDocumentSettings::SwXDocumentSettings ( SwXTextDocument * pModel )
225 : MasterPropertySet ( lcl_createSettingsInfo (),
226 &Application::GetSolarMutex () )
227 , mxModel ( pModel )
228 , mpModel ( pModel )
229 , mpDocSh ( NULL )
230 , mpDoc ( NULL )
231 , mpPrinter( NULL )
233 registerSlave ( new SwXPrintSettings ( PRINT_SETTINGS_DOCUMENT, mpModel->GetDocShell()->GetDoc() ) );
236 SwXDocumentSettings::~SwXDocumentSettings()
237 throw()
241 Any SAL_CALL SwXDocumentSettings::queryInterface( const Type& rType )
242 throw(RuntimeException)
244 return ::cppu::queryInterface ( rType,
245 // OWeakObject interfaces
246 dynamic_cast< XInterface* > ( dynamic_cast< OWeakObject* >(this) ),
247 dynamic_cast< XWeak* > ( this ),
248 // my own interfaces
249 dynamic_cast< XPropertySet* > ( this ),
250 dynamic_cast< XPropertyState* > ( this ),
251 dynamic_cast< XMultiPropertySet* > ( this ),
252 dynamic_cast< XServiceInfo* > ( this ),
253 dynamic_cast< XTypeProvider* > ( this ) );
255 void SwXDocumentSettings::acquire ()
256 throw ()
258 OWeakObject::acquire();
260 void SwXDocumentSettings::release ()
261 throw ()
263 OWeakObject::release();
266 uno::Sequence< uno::Type > SAL_CALL SwXDocumentSettings::getTypes( )
267 throw (RuntimeException)
269 SolarMutexGuard aGuard;
271 uno::Sequence< uno::Type > aBaseTypes( 5 );
272 uno::Type* pBaseTypes = aBaseTypes.getArray();
274 // from MasterPropertySet
275 pBaseTypes[0] = ::getCppuType((Reference< XPropertySet >*)0);
276 pBaseTypes[1] = ::getCppuType((Reference< XPropertyState >*)0);
277 pBaseTypes[2] = ::getCppuType((Reference< XMultiPropertySet >*)0);
279 pBaseTypes[3] = ::getCppuType((Reference< XServiceInfo >*)0);
280 pBaseTypes[4] = ::getCppuType((Reference< XTypeProvider >*)0);
282 return aBaseTypes;
285 namespace
287 class theSwXDocumentSettingsImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXDocumentSettingsImplementationId > {};
290 uno::Sequence< sal_Int8 > SAL_CALL SwXDocumentSettings::getImplementationId( )
291 throw (RuntimeException)
293 return theSwXDocumentSettingsImplementationId::get().getSeq();
296 void SwXDocumentSettings::_preSetValues ()
297 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
299 mpDocSh = mpModel->GetDocShell();
300 mpDoc = mpDocSh->GetDoc();
302 if( NULL == mpDoc || NULL == mpDocSh )
303 throw UnknownPropertyException();
307 void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
308 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
310 if (rInfo.mnAttributes & PropertyAttribute::READONLY)
311 throw PropertyVetoException ( OUString( "Property is read-only: " ) + OUString::createFromAscii(rInfo.mpName), static_cast < cppu::OWeakObject * > ( 0 ) );
313 switch( rInfo.mnHandle )
315 case HANDLE_FORBIDDEN_CHARS:
316 break;
317 case HANDLE_LINK_UPDATE_MODE:
319 sal_Int16 nMode = 0;
320 rValue >>= nMode;
321 switch (nMode)
323 case NEVER:
324 case MANUAL:
325 case AUTOMATIC:
326 case GLOBALSETTING:
327 break;
328 default:
329 throw IllegalArgumentException();
331 mpDoc->setLinkUpdateMode(nMode);
333 break;
334 case HANDLE_FIELD_AUTO_UPDATE:
336 sal_Bool bUpdateField = *(sal_Bool*)rValue.getValue();
337 SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
338 mpDoc->setFieldUpdateFlags( bUpdateField ?
339 nFlag == AUTOUPD_FIELD_AND_CHARTS ?
340 AUTOUPD_FIELD_AND_CHARTS :
341 AUTOUPD_FIELD_ONLY :
342 AUTOUPD_OFF );
344 break;
345 case HANDLE_CHART_AUTO_UPDATE:
347 sal_Bool bUpdateChart = *(sal_Bool*)rValue.getValue();
348 SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
349 mpDoc->setFieldUpdateFlags( (nFlag == AUTOUPD_FIELD_ONLY || nFlag == AUTOUPD_FIELD_AND_CHARTS ) ?
350 bUpdateChart ?
351 AUTOUPD_FIELD_AND_CHARTS :
352 AUTOUPD_FIELD_ONLY :
353 AUTOUPD_OFF );
355 break;
356 case HANDLE_ADD_PARA_TABLE_SPACING:
358 sal_Bool bParaSpace = sal_False;
359 rValue >>= bParaSpace;
360 mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX, bParaSpace );
362 break;
363 case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
365 sal_Bool bParaSpacePage = sal_False;
366 rValue >>= bParaSpacePage;
367 mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, bParaSpacePage );
369 break;
370 case HANDLE_ALIGN_TAB_STOP_POSITION:
372 sal_Bool bAlignTab = *(sal_Bool*)rValue.getValue();
373 mpDoc->set(IDocumentSettingAccess::TAB_COMPAT, bAlignTab);
375 break;
376 case HANDLE_PRINTER_NAME:
378 //the printer must be created
379 OUString sPrinterName;
380 if( rValue >>= sPrinterName )
382 if( !mpPrinter && !sPrinterName.isEmpty() && mpDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
384 SfxPrinter* pPrinter = mpDoc->getPrinter( true );
385 if ( OUString ( pPrinter->GetName()) != sPrinterName )
387 SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
388 if( pNewPrinter->IsKnown() )
390 // set printer only once; in _postSetValues
391 mpPrinter = pNewPrinter;
393 else
395 delete pNewPrinter;
400 else
401 throw IllegalArgumentException();
403 break;
404 case HANDLE_PRINTER_SETUP:
406 Sequence < sal_Int8 > aSequence;
407 if ( rValue >>= aSequence )
409 sal_uInt32 nSize = aSequence.getLength();
410 if( nSize > 0 )
412 SvMemoryStream aStream (aSequence.getArray(), nSize,
413 STREAM_READ );
414 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
415 static sal_uInt16 const nRange[] =
417 FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
418 SID_HTML_MODE, SID_HTML_MODE,
419 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
420 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
423 SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
424 SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
426 // set printer only once; in _postSetValues
427 delete mpPrinter;
428 mpPrinter = pPrinter;
431 else
432 throw IllegalArgumentException();
434 break;
435 case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
437 sal_Bool bIsKern = *(sal_Bool*)(rValue).getValue();
438 mpDoc->set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION, bIsKern);
439 SwEditShell* pEditSh = mpDoc->GetEditShell();
440 if(pEditSh)
441 pEditSh->ChgHyphenation();
443 break;
444 case HANDLE_CHARACTER_COMPRESSION_TYPE:
446 sal_Int16 nMode = 0;
447 rValue >>= nMode;
448 switch (nMode)
450 case CHARCOMPRESS_NONE:
451 case CHARCOMPRESS_PUNCTUATION:
452 case CHARCOMPRESS_PUNCTUATION_KANA:
453 break;
454 default:
455 throw IllegalArgumentException();
457 mpDoc->setCharacterCompressionType(static_cast < SwCharCompressType > (nMode) );
459 break;
460 case HANDLE_APPLY_USER_DATA:
462 mpDocSh->SetUseUserData( *(sal_Bool*)rValue.getValue() );
464 break;
465 case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
467 sal_Bool bSaveGlobal = *(sal_Bool*)rValue.getValue();
468 mpDoc->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bSaveGlobal );
470 break;
471 case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
473 SwDBData aData = mpDoc->GetDBData();
474 if ( rValue >>= aData.sDataSource )
475 mpDoc->ChgDBData( aData );
477 break;
478 case HANDLE_CURRENT_DATABASE_COMMAND:
480 SwDBData aData = mpDoc->GetDBData();
482 if ( rValue >>= aData.sCommand )
483 mpDoc->ChgDBData( aData );
485 SAL_WARN_IF( aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty(), "sw.uno",
486 "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" );
488 break;
489 case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
491 SwDBData aData = mpDoc->GetDBData();
492 if ( rValue >>= aData.nCommandType )
493 mpDoc->ChgDBData( aData );
494 SAL_WARN_IF( aData.nCommandType && aData.sDataSource.isEmpty(), "sw.uno",
495 "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" );
496 SAL_WARN_IF( aData.nCommandType && aData.sCommand.isEmpty(), "sw.uno",
497 "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" );
499 break;
500 case HANDLE_SAVE_VERSION_ON_CLOSE:
502 mpDocSh->SetSaveVersionOnClose( *(sal_Bool*)rValue.getValue() );
504 break;
505 case HANDLE_UPDATE_FROM_TEMPLATE:
507 mpDocSh->SetQueryLoadTemplate( *(sal_Bool*)rValue.getValue() );
509 break;
510 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
512 sal_Int16 nTmp = 0;
513 rValue >>= nTmp;
515 bool bUseVirDev = true;
516 bool bHiResVirDev = true;
517 if( nTmp == document::PrinterIndependentLayout::DISABLED )
518 bUseVirDev = false;
519 else if ( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
520 bHiResVirDev = false;
521 else if ( nTmp != document::PrinterIndependentLayout::HIGH_RESOLUTION )
522 throw IllegalArgumentException();
524 mpDoc->setReferenceDeviceType( bUseVirDev, bHiResVirDev );
526 break;
527 case HANDLE_IS_LABEL_DOC :
529 sal_Bool bSet = sal_False;
530 if(!(rValue >>= bSet))
531 throw IllegalArgumentException();
532 mpDoc->set(IDocumentSettingAccess::LABEL_DOCUMENT, bSet);
534 break;
535 case HANDLE_IS_ADD_FLY_OFFSET:
537 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
538 mpDoc->set(IDocumentSettingAccess::ADD_FLY_OFFSETS, bTmp);
540 break;
541 case HANDLE_IS_ADD_EXTERNAL_LEADING:
543 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
544 mpDoc->set(IDocumentSettingAccess::ADD_EXT_LEADING, bTmp);
546 break;
547 case HANDLE_OLD_NUMBERING: // #111955#
549 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
550 mpDoc->set(IDocumentSettingAccess::OLD_NUMBERING, bTmp);
552 case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING:
554 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
555 mpDoc->set(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE, bTmp);
557 break;
558 case HANDLE_ALLOW_PRINTJOB_CANCEL:
560 sal_Bool bState = sal_False;
561 if (!(rValue >>= bState))
562 throw IllegalArgumentException();
563 mpDocSh->Stamp_SetPrintCancelState(bState);
565 break;
566 case HANDLE_USE_FORMER_LINE_SPACING:
568 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
569 mpDoc->set(IDocumentSettingAccess::OLD_LINE_SPACING, bTmp);
571 break;
572 case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
574 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
575 mpDoc->set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, bTmp);
577 break;
578 case HANDLE_USE_FORMER_OBJECT_POSITIONING:
580 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
581 mpDoc->set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, bTmp);
583 break;
584 case HANDLE_USE_FORMER_TEXT_WRAPPING:
586 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
587 mpDoc->set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, bTmp);
589 break;
590 case HANDLE_CHANGES_PASSWORD:
592 Sequence <sal_Int8> aNew;
593 if(rValue >>= aNew)
595 mpDoc->SetRedlinePassword(aNew);
596 if(aNew.getLength())
598 sal_uInt16 eMode = mpDoc->GetRedlineMode();
599 eMode = eMode|nsRedlineMode_t::REDLINE_ON;
600 mpDoc->SetRedlineMode((RedlineMode_t)( eMode ));
604 break;
605 case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
607 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
608 mpDoc->set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, bTmp );
610 break;
611 case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
613 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
614 mpDoc->set(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, bTmp);
616 break;
617 case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
619 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
620 mpDoc->set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, bTmp);
622 break;
623 case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
625 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
626 mpDoc->set(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, bTmp);
628 break;
629 case HANDLE_TABLE_ROW_KEEP:
631 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
632 mpDoc->set(IDocumentSettingAccess::TABLE_ROW_KEEP, bTmp);
634 break;
635 case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
637 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
638 mpDoc->set(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, bTmp);
640 break;
641 case HANDLE_LOAD_READONLY:
643 mpDocSh->SetLoadReadonly( *(sal_Bool*)rValue.getValue() );
645 break;
646 case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
648 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
649 mpDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, bTmp);
651 break;
652 case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
654 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
655 mpDoc->set(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME, bTmp);
657 break;
658 case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
660 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
661 mpDoc->set(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING, bTmp);
663 break;
664 case HANDLE_USE_OLD_PRINTER_METRICS:
665 // ignore - this is a dead property
666 break;
667 case HANDLE_TABS_RELATIVE_TO_INDENT:
669 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
670 mpDoc->set(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT, bTmp);
672 break;
673 case HANDLE_RSID:
675 sal_uInt32 nTmp = 0;
676 rValue >>= nTmp;
677 mpDoc->setRsid( nTmp );
679 break;
680 case HANDLE_RSID_ROOT:
682 sal_uInt32 nTmp = 0;
683 rValue >>= nTmp;
684 mpDoc->setRsidRoot( nTmp );
686 break;
687 case HANDLE_PROTECT_FORM:
689 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
690 mpDoc->set(IDocumentSettingAccess::PROTECT_FORM, bTmp);
692 break;
693 // #i89181#
694 case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
696 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
697 mpDoc->set(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, bTmp);
699 break;
700 case HANDLE_MODIFYPASSWORDINFO:
702 uno::Sequence< beans::PropertyValue > aInfo;
703 if ( !( rValue >>= aInfo ) )
704 throw lang::IllegalArgumentException(
705 OUString( "Value of type Sequence<PropertyValue> expected!" ),
706 uno::Reference< uno::XInterface >(),
707 2 );
709 if ( !mpDocSh->SetModifyPasswordInfo( aInfo ) )
710 throw beans::PropertyVetoException(
711 OUString( "The hash is not allowed to be changed now!" ),
712 uno::Reference< uno::XInterface >() );
714 break;
715 case HANDLE_MATH_BASELINE_ALIGNMENT:
717 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
718 mpDoc->set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT, bTmp );
720 break;
721 case HANDLE_INVERT_BORDER_SPACING:
723 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
724 mpDoc->set(IDocumentSettingAccess::INVERT_BORDER_SPACING, bTmp);
726 break;
727 case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
729 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
730 mpDoc->set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, bTmp);
732 break;
733 case HANDLE_SMALL_CAPS_PERCENTAGE_66:
735 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
736 mpDoc->set(IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66, bTmp);
738 break;
739 case HANDLE_TAB_OVERFLOW:
741 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
742 mpDoc->set(IDocumentSettingAccess::TAB_OVERFLOW, bTmp);
744 break;
745 case HANDLE_UNBREAKABLE_NUMBERINGS:
747 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
748 mpDoc->set(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS, bTmp);
750 break;
751 case HANDLE_STYLES_NODEFAULT:
753 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
754 mpDoc->set(IDocumentSettingAccess::STYLES_NODEFAULT, bTmp);
756 break;
757 case HANDLE_FLOATTABLE_NOMARGINS:
759 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
760 mpDoc->set(IDocumentSettingAccess::FLOATTABLE_NOMARGINS, bTmp);
762 break;
763 case HANDLE_CLIPPED_PICTURES:
765 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
766 mpDoc->set(IDocumentSettingAccess::CLIPPED_PICTURES, bTmp);
768 break;
769 case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS:
771 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
772 mpDoc->set(IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS, bTmp);
774 break;
775 case HANDLE_EMBED_FONTS:
777 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
778 mpDoc->set(IDocumentSettingAccess::EMBED_FONTS, bTmp);
780 case HANDLE_EMBED_SYSTEM_FONTS:
782 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
783 mpDoc->set(IDocumentSettingAccess::EMBED_SYSTEM_FONTS, bTmp);
785 break;
786 case HANDLE_TAB_OVER_MARGIN:
788 sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
789 mpDoc->set(IDocumentSettingAccess::TAB_OVER_MARGIN, bTmp);
791 break;
792 default:
793 throw UnknownPropertyException();
797 void SwXDocumentSettings::_postSetValues ()
798 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
800 // set printer only once, namely here!
801 if( mpPrinter != NULL )
803 // #i86352# the printer is also used as container for options by sfx
804 // when setting a printer it should have decent default options
805 SfxItemSet aOptions( mpPrinter->GetOptions() );
806 SwPrintData aPrtData( mpDoc->getPrintData() );
807 SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData);
808 aOptions.Put(aAddPrinterItem);
809 mpPrinter->SetOptions( aOptions );
811 mpDoc->setPrinter( mpPrinter, true, true );
814 mpPrinter = 0;
815 mpDocSh = 0;
816 mpDoc = 0;
819 void SwXDocumentSettings::_preGetValues ()
820 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
822 mpDocSh = mpModel->GetDocShell();
823 mpDoc = mpDocSh->GetDoc();
824 if( NULL == mpDoc || NULL == mpDocSh )
825 throw UnknownPropertyException();
828 void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
829 throw(beans::UnknownPropertyException, lang::WrappedTargetException )
831 switch( rInfo.mnHandle )
833 case HANDLE_FORBIDDEN_CHARS:
835 Reference<XForbiddenCharacters> xRet(*mpModel->GetPropertyHelper(), UNO_QUERY);
836 rValue <<= xRet;
838 break;
839 case HANDLE_LINK_UPDATE_MODE:
841 rValue <<= static_cast < sal_Int16 > ( mpDoc->getLinkUpdateMode(true) );
843 break;
844 case HANDLE_FIELD_AUTO_UPDATE:
846 SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
847 sal_Bool bFieldUpd = (nFlags == AUTOUPD_FIELD_ONLY || nFlags == AUTOUPD_FIELD_AND_CHARTS );
848 rValue.setValue(&bFieldUpd, ::getBooleanCppuType());
850 break;
851 case HANDLE_CHART_AUTO_UPDATE:
853 SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
854 sal_Bool bChartUpd = nFlags == AUTOUPD_FIELD_AND_CHARTS;
855 rValue.setValue(&bChartUpd, ::getBooleanCppuType());
857 break;
858 case HANDLE_ADD_PARA_TABLE_SPACING:
860 sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX);
861 rValue.setValue(&bParaSpace, ::getBooleanCppuType());
863 break;
864 case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
866 sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES);
867 rValue.setValue(&bParaSpace, ::getBooleanCppuType());
869 break;
870 case HANDLE_ALIGN_TAB_STOP_POSITION:
872 sal_Bool bAlignTab = mpDoc->get(IDocumentSettingAccess::TAB_COMPAT);
873 rValue.setValue(&bAlignTab, ::getBooleanCppuType());
875 break;
876 case HANDLE_PRINTER_NAME:
878 SfxPrinter *pPrinter = mpDoc->getPrinter( sal_False );
879 rValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString();
881 break;
882 case HANDLE_PRINTER_SETUP:
884 SfxPrinter *pPrinter = mpDoc->getPrinter( sal_False );
885 if (pPrinter)
887 SvMemoryStream aStream;
888 pPrinter->Store( aStream );
889 aStream.Seek ( STREAM_SEEK_TO_END );
890 sal_uInt32 nSize = aStream.Tell();
891 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
892 Sequence < sal_Int8 > aSequence( nSize );
893 aStream.Read ( aSequence.getArray(), nSize );
894 rValue <<= aSequence;
896 else
898 Sequence < sal_Int8 > aSequence ( 0 );
899 rValue <<= aSequence;
902 break;
903 case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
905 sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION);
906 rValue.setValue(&bParaSpace, ::getBooleanCppuType());
908 break;
909 case HANDLE_APPLY_USER_DATA:
911 rValue <<= mpDocSh->IsUseUserData();
913 break;
914 case HANDLE_CHARACTER_COMPRESSION_TYPE:
916 rValue <<= static_cast < sal_Int16 > (mpDoc->getCharacterCompressionType());
918 break;
919 case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
921 sal_Bool bSaveGlobal = mpDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS);
922 rValue.setValue(&bSaveGlobal, ::getBooleanCppuType());
924 break;
925 case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
927 const SwDBData& rData = mpDoc->GetDBDesc();
928 rValue <<= rData.sDataSource;
930 break;
931 case HANDLE_CURRENT_DATABASE_COMMAND:
933 const SwDBData& rData = mpDoc->GetDBDesc();
934 rValue <<= rData.sCommand;
936 break;
937 case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
939 const SwDBData& rData = mpDoc->GetDBDesc();
940 rValue <<= rData.nCommandType;
942 break;
943 case HANDLE_SAVE_VERSION_ON_CLOSE:
945 rValue <<= mpDocSh->IsSaveVersionOnClose();
947 break;
948 case HANDLE_UPDATE_FROM_TEMPLATE:
950 rValue <<= mpDocSh->IsQueryLoadTemplate();
952 break;
953 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
955 // returns short (see css.document.PrinterIndependentLayout)
956 sal_Int16 nVirDevType = mpDoc->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ?
957 ( mpDoc->get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) ?
958 document::PrinterIndependentLayout::HIGH_RESOLUTION :
959 document::PrinterIndependentLayout::LOW_RESOLUTION ) :
960 document::PrinterIndependentLayout::DISABLED;
961 rValue <<= nVirDevType;
963 break;
964 case HANDLE_IS_LABEL_DOC:
966 sal_Bool bLabel = mpDoc->get(IDocumentSettingAccess::LABEL_DOCUMENT);
967 rValue <<= bLabel;
969 break;
970 case HANDLE_IS_ADD_FLY_OFFSET:
972 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_FLY_OFFSETS);
973 rValue.setValue( &bTmp, ::getBooleanCppuType() );
975 break;
976 case HANDLE_IS_ADD_EXTERNAL_LEADING:
978 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_EXT_LEADING);
979 rValue.setValue( &bTmp, ::getBooleanCppuType() );
981 break;
982 case HANDLE_OLD_NUMBERING: // #111955#
984 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_NUMBERING);
985 rValue.setValue( &bTmp, ::getBooleanCppuType() );
987 break;
988 case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING: // #111955#
990 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE);
991 rValue.setValue( &bTmp, ::getBooleanCppuType() );
993 break;
994 case HANDLE_ALLOW_PRINTJOB_CANCEL:
996 sal_Bool bPrintCancelState = mpDocSh->Stamp_GetPrintCancelState();
997 rValue.setValue(&bPrintCancelState, ::getBooleanCppuType());
999 break;
1000 case HANDLE_USE_FORMER_LINE_SPACING:
1002 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_LINE_SPACING);
1003 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1005 break;
1006 case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
1008 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS);
1009 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1011 break;
1012 case HANDLE_USE_FORMER_OBJECT_POSITIONING:
1014 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS);
1015 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1017 break;
1018 case HANDLE_USE_FORMER_TEXT_WRAPPING:
1020 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING);
1021 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1023 break;
1024 case HANDLE_CHANGES_PASSWORD:
1026 rValue <<= mpDoc->GetRedlinePassword();
1028 break;
1029 case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
1031 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION);
1032 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1034 break;
1035 case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
1037 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING);
1038 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1040 break;
1041 case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
1043 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK);
1044 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1046 break;
1047 case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
1049 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT);
1050 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1052 break;
1053 case HANDLE_TABLE_ROW_KEEP :
1055 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABLE_ROW_KEEP);
1056 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1058 break;
1059 case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
1061 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION);
1062 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1064 break;
1065 case HANDLE_LOAD_READONLY:
1067 rValue <<= mpDocSh->IsLoadReadonly();
1069 break;
1070 case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
1072 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE);
1073 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1075 break;
1076 case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
1078 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME);
1079 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1081 break;
1082 case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
1084 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING);
1085 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1087 break;
1088 case HANDLE_USE_OLD_PRINTER_METRICS:
1090 sal_Bool bTmp = sal_False;
1091 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1093 break;
1094 case HANDLE_TABS_RELATIVE_TO_INDENT:
1096 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
1097 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1099 break;
1100 case HANDLE_RSID:
1102 rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsid() );
1104 break;
1105 case HANDLE_RSID_ROOT:
1107 rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsidRoot() );
1109 break;
1110 case HANDLE_PROTECT_FORM:
1112 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::PROTECT_FORM);
1113 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1115 break;
1116 // #i89181#
1117 case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
1119 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST);
1120 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1122 break;
1123 case HANDLE_MODIFYPASSWORDINFO:
1125 rValue <<= mpDocSh->GetModifyPasswordInfo();
1127 break;
1128 case HANDLE_MATH_BASELINE_ALIGNMENT:
1130 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
1131 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1133 break;
1134 case HANDLE_INVERT_BORDER_SPACING:
1136 sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::INVERT_BORDER_SPACING);
1137 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1139 break;
1140 case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
1142 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA );
1143 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1145 break;
1146 case HANDLE_SMALL_CAPS_PERCENTAGE_66:
1148 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66 );
1149 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1151 break;
1152 case HANDLE_TAB_OVERFLOW:
1154 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVERFLOW );
1155 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1157 break;
1158 case HANDLE_UNBREAKABLE_NUMBERINGS:
1160 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS );
1161 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1163 break;
1164 case HANDLE_STYLES_NODEFAULT:
1166 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::STYLES_NODEFAULT );
1167 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1169 break;
1170 case HANDLE_FLOATTABLE_NOMARGINS:
1172 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::FLOATTABLE_NOMARGINS );
1173 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1175 break;
1176 case HANDLE_CLIPPED_PICTURES:
1178 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::CLIPPED_PICTURES );
1179 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1181 break;
1182 case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS:
1184 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS );
1185 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1187 break;
1188 case HANDLE_EMBED_FONTS:
1190 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_FONTS );
1191 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1193 break;
1194 case HANDLE_EMBED_SYSTEM_FONTS:
1196 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS );
1197 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1199 break;
1200 case HANDLE_TAB_OVER_MARGIN:
1202 sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVER_MARGIN );
1203 rValue.setValue( &bTmp, ::getBooleanCppuType() );
1205 break;
1206 default:
1207 throw UnknownPropertyException();
1211 void SwXDocumentSettings::_postGetValues ()
1212 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
1214 mpDocSh = 0;
1215 mpDoc = 0;
1218 // XServiceInfo
1219 OUString SAL_CALL SwXDocumentSettings::getImplementationName( )
1220 throw(RuntimeException)
1222 return OUString("com.sun.star.comp.Writer.DocumentSettings");
1225 sal_Bool SAL_CALL SwXDocumentSettings::supportsService( const OUString& ServiceName )
1226 throw(RuntimeException)
1228 const Sequence< OUString > aSeq( getSupportedServiceNames() );
1229 sal_Int32 nCount = aSeq.getLength();
1230 const OUString* pServices = aSeq.getConstArray();
1231 while( nCount-- )
1233 if( *pServices++ == ServiceName )
1234 return sal_True;
1236 return sal_True;
1239 Sequence< OUString > SAL_CALL SwXDocumentSettings::getSupportedServiceNames( )
1240 throw(RuntimeException)
1242 Sequence< OUString > aSeq( 3 );
1243 aSeq[0] = OUString("com.sun.star.document.Settings");
1244 aSeq[1] = OUString("com.sun.star.text.DocumentSettings");
1245 aSeq[2] = OUString("com.sun.star.text.PrintSettings");
1246 return aSeq;
1250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */