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 <osl/mutex.hxx>
21 : #include <sfx2/sfxbasecontroller.hxx>
22 : #include <SwXDocumentSettings.hxx>
23 : #include <comphelper/MasterPropertySetInfo.hxx>
24 : #include <cppuhelper/supportsservice.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>
42 :
43 : #include "swmodule.hxx"
44 : #include "cfgitems.hxx"
45 : #include "prtopt.hxx"
46 :
47 : using namespace comphelper;
48 : using namespace ::com::sun::star;
49 : using namespace ::com::sun::star::uno;
50 : using namespace ::com::sun::star::beans;
51 : using namespace ::com::sun::star::lang;
52 : using namespace ::com::sun::star::i18n;
53 :
54 : enum SwDocumentSettingsPropertyHandles
55 : {
56 : HANDLE_FORBIDDEN_CHARS,
57 : HANDLE_LINK_UPDATE_MODE,
58 : HANDLE_FIELD_AUTO_UPDATE,
59 : HANDLE_CHART_AUTO_UPDATE,
60 : HANDLE_ADD_PARA_TABLE_SPACING,
61 : HANDLE_ADD_PARA_TABLE_SPACING_AT_START,
62 : HANDLE_ALIGN_TAB_STOP_POSITION,
63 : HANDLE_PRINTER_NAME,
64 : HANDLE_PRINTER_SETUP,
65 : HANDLE_IS_KERN_ASIAN_PUNCTUATION,
66 : HANDLE_CHARACTER_COMPRESSION_TYPE,
67 : HANDLE_APPLY_USER_DATA,
68 : HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS,
69 : HANDLE_CURRENT_DATABASE_DATA_SOURCE,
70 : HANDLE_CURRENT_DATABASE_COMMAND,
71 : HANDLE_CURRENT_DATABASE_COMMAND_TYPE,
72 : HANDLE_SAVE_VERSION_ON_CLOSE,
73 : HANDLE_IS_GRID_VISIBLE,
74 : HANDLE_IS_SNAP_TO_GRID,
75 : HANDLE_IS_SYNCHRONISE_AXES,
76 : HANDLE_HORIZONTAL_GRID_RESOLUTION,
77 : HANDLE_HORIZONTAL_GRID_SUBDIVISION,
78 : HANDLE_VERTICAL_GRID_RESOLUTION,
79 : HANDLE_VERTICAL_GRID_SUBDIVISION,
80 : HANDLE_UPDATE_FROM_TEMPLATE,
81 : HANDLE_PRINTER_INDEPENDENT_LAYOUT,
82 : HANDLE_IS_LABEL_DOC,
83 : HANDLE_IS_ADD_FLY_OFFSET,
84 : HANDLE_IS_ADD_EXTERNAL_LEADING,
85 : HANDLE_OLD_NUMBERING, // #111955#
86 : HANDLE_OUTLINELEVEL_YIELDS_NUMBERING,
87 : /* Stampit It disable the print cancel button of the shown progress dialog. */
88 : HANDLE_ALLOW_PRINTJOB_CANCEL,
89 : HANDLE_USE_FORMER_LINE_SPACING,
90 : HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS,
91 : HANDLE_USE_FORMER_OBJECT_POSITIONING,
92 : HANDLE_USE_FORMER_TEXT_WRAPPING,
93 : HANDLE_CHANGES_PASSWORD,
94 : HANDLE_CONSIDER_WRAP_ON_OBJPOS,
95 : HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING,
96 : HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK,
97 : HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT,
98 : HANDLE_TABLE_ROW_KEEP,
99 : HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION,
100 : HANDLE_LOAD_READONLY,
101 : HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE,
102 : HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES,
103 : HANDLE_UNIX_FORCE_ZERO_EXT_LEADING,
104 : HANDLE_USE_OLD_PRINTER_METRICS,
105 : HANDLE_PROTECT_FORM,
106 : HANDLE_TABS_RELATIVE_TO_INDENT,
107 : HANDLE_RSID,
108 : HANDLE_RSID_ROOT,
109 : // #i89181#
110 : HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
111 : HANDLE_MODIFYPASSWORDINFO,
112 : HANDLE_MATH_BASELINE_ALIGNMENT,
113 : HANDLE_INVERT_BORDER_SPACING,
114 : HANDLE_COLLAPSE_EMPTY_CELL_PARA,
115 : HANDLE_SMALL_CAPS_PERCENTAGE_66,
116 : HANDLE_TAB_OVERFLOW,
117 : HANDLE_UNBREAKABLE_NUMBERINGS,
118 : HANDLE_STYLES_NODEFAULT,
119 : HANDLE_FLOATTABLE_NOMARGINS,
120 : HANDLE_CLIPPED_PICTURES,
121 : HANDLE_BACKGROUND_PARA_OVER_DRAWINGS,
122 : HANDLE_EMBED_FONTS,
123 : HANDLE_EMBED_SYSTEM_FONTS,
124 : HANDLE_TAB_OVER_MARGIN,
125 : HANDLE_SURROUND_TEXT_WRAP_SMALL
126 : };
127 :
128 0 : static MasterPropertySetInfo * lcl_createSettingsInfo()
129 : {
130 : static PropertyInfo const aWriterSettingsInfoMap[] =
131 : {
132 0 : { OUString("ForbiddenCharacters"), HANDLE_FORBIDDEN_CHARS, cppu::UnoType<css::i18n::XForbiddenCharacters>::get(), 0, 0},
133 0 : { OUString("LinkUpdateMode"), HANDLE_LINK_UPDATE_MODE, cppu::UnoType<sal_Int16>::get(), 0, 0},
134 0 : { OUString("FieldAutoUpdate"), HANDLE_FIELD_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0, 0},
135 0 : { OUString("ChartAutoUpdate"), HANDLE_CHART_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0, 0},
136 0 : { OUString("AddParaTableSpacing"), HANDLE_ADD_PARA_TABLE_SPACING, cppu::UnoType<bool>::get(), 0, 0},
137 0 : { OUString("AddParaTableSpacingAtStart"), HANDLE_ADD_PARA_TABLE_SPACING_AT_START, cppu::UnoType<bool>::get(), 0, 0},
138 0 : { OUString("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, cppu::UnoType<bool>::get(), 0, 0},
139 0 : { OUString("PrinterName"), HANDLE_PRINTER_NAME, cppu::UnoType<OUString>::get(), 0, 0},
140 0 : { OUString("PrinterSetup"), HANDLE_PRINTER_SETUP, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0, 0},
141 0 : { OUString("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, cppu::UnoType<bool>::get(), 0, 0},
142 0 : { OUString("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, cppu::UnoType<sal_Int16>::get(), 0, 0},
143 0 : { OUString("ApplyUserData"), HANDLE_APPLY_USER_DATA, cppu::UnoType<bool>::get(), 0, 0},
144 0 : { OUString("SaveGlobalDocumentLinks"), HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, cppu::UnoType<bool>::get(), 0, 0},
145 0 : { OUString("CurrentDatabaseDataSource"), HANDLE_CURRENT_DATABASE_DATA_SOURCE, cppu::UnoType<OUString>::get(), 0, 0},
146 0 : { OUString("CurrentDatabaseCommand"), HANDLE_CURRENT_DATABASE_COMMAND, cppu::UnoType<OUString>::get(), 0, 0},
147 0 : { OUString("CurrentDatabaseCommandType"), HANDLE_CURRENT_DATABASE_COMMAND_TYPE, cppu::UnoType<sal_Int32>::get(), 0, 0},
148 0 : { OUString("SaveVersionOnClose"), HANDLE_SAVE_VERSION_ON_CLOSE, cppu::UnoType<bool>::get(), 0, 0},
149 0 : { OUString("UpdateFromTemplate"), HANDLE_UPDATE_FROM_TEMPLATE, cppu::UnoType<bool>::get(), 0, 0},
150 :
151 0 : { OUString("PrinterIndependentLayout"), HANDLE_PRINTER_INDEPENDENT_LAYOUT, cppu::UnoType<sal_Int16>::get(), 0, 0},
152 0 : { OUString("IsLabelDocument"), HANDLE_IS_LABEL_DOC, cppu::UnoType<bool>::get(), 0, 0},
153 0 : { OUString("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, cppu::UnoType<bool>::get(), 0, 0},
154 0 : { OUString("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, cppu::UnoType<bool>::get(), 0, 0},
155 0 : { OUString("UseOldNumbering"), HANDLE_OLD_NUMBERING, cppu::UnoType<bool>::get(), 0, 0}, // #111955#
156 0 : { OUString("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, cppu::UnoType<bool>::get(), 0, 0},
157 : /* Stampit It disable the print cancel button of the shown progress dialog. */
158 0 : { OUString("AllowPrintJobCancel"), HANDLE_ALLOW_PRINTJOB_CANCEL, cppu::UnoType<bool>::get(), 0, 0},
159 0 : { OUString("UseFormerLineSpacing"), HANDLE_USE_FORMER_LINE_SPACING, cppu::UnoType<bool>::get(), 0, 0},
160 0 : { OUString("AddParaSpacingToTableCells"), HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, cppu::UnoType<bool>::get(), 0, 0},
161 0 : { OUString("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, cppu::UnoType<bool>::get(), 0, 0},
162 0 : { OUString("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, cppu::UnoType<bool>::get(), 0, 0},
163 0 : { OUString("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0, 0},
164 0 : { OUString("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, cppu::UnoType<bool>::get(), 0, 0},
165 0 : { OUString("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, cppu::UnoType<bool>::get(), 0, 0},
166 0 : { OUString("DoNotJustifyLinesWithManualBreak"), HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, cppu::UnoType<bool>::get(), 0, 0},
167 0 : { OUString("DoNotResetParaAttrsForNumFont"), HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, cppu::UnoType<bool>::get(), 0, 0},
168 0 : { OUString("TableRowKeep"), HANDLE_TABLE_ROW_KEEP, cppu::UnoType<bool>::get(), 0, 0},
169 0 : { OUString("IgnoreTabsAndBlanksForLineCalculation"), HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, cppu::UnoType<bool>::get(), 0, 0},
170 0 : { OUString("LoadReadonly"), HANDLE_LOAD_READONLY, cppu::UnoType<bool>::get(), 0, 0},
171 0 : { OUString("DoNotCaptureDrawObjsOnPage"), HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, cppu::UnoType<bool>::get(), 0, 0},
172 0 : { OUString("ClipAsCharacterAnchoredWriterFlyFrames"), HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, cppu::UnoType<bool>::get(), 0, 0},
173 0 : { OUString("UnxForceZeroExtLeading"), HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, cppu::UnoType<bool>::get(), 0, 0},
174 0 : { OUString("UseOldPrinterMetrics"), HANDLE_USE_OLD_PRINTER_METRICS, cppu::UnoType<bool>::get(), 0, 0},
175 0 : { OUString("TabsRelativeToIndent"), HANDLE_TABS_RELATIVE_TO_INDENT, cppu::UnoType<bool>::get(), 0, 0},
176 0 : { OUString("Rsid"), HANDLE_RSID, cppu::UnoType<sal_Int32>::get(), 0, 0},
177 0 : { OUString("RsidRoot"), HANDLE_RSID_ROOT, cppu::UnoType<sal_Int32>::get(), 0, 0},
178 0 : { OUString("ProtectForm"), HANDLE_PROTECT_FORM, cppu::UnoType<bool>::get(), 0, 0},
179 : // #i89181#
180 0 : { OUString("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, cppu::UnoType<bool>::get(), 0, 0},
181 0 : { OUString("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), 0, 0},
182 0 : { OUString("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, cppu::UnoType<bool>::get(), 0, 0},
183 0 : { OUString("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, cppu::UnoType<bool>::get(), 0, 0},
184 0 : { OUString("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, cppu::UnoType<bool>::get(), 0, 0},
185 0 : { OUString("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, cppu::UnoType<bool>::get(), 0, 0},
186 0 : { OUString("TabOverflow"), HANDLE_TAB_OVERFLOW, cppu::UnoType<bool>::get(), 0, 0},
187 0 : { OUString("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, cppu::UnoType<bool>::get(), 0, 0},
188 0 : { OUString("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, cppu::UnoType<bool>::get(), 0, 0},
189 0 : { OUString("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, cppu::UnoType<bool>::get(), 0, 0},
190 0 : { OUString("ClippedPictures"), HANDLE_CLIPPED_PICTURES, cppu::UnoType<bool>::get(), 0, 0},
191 0 : { OUString("BackgroundParaOverDrawings"), HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, cppu::UnoType<bool>::get(), 0, 0},
192 0 : { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType<bool>::get(), 0, 0},
193 0 : { OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType<bool>::get(), 0, 0},
194 0 : { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0, 0},
195 0 : { OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 0, 0},
196 : /*
197 : * As OS said, we don't have a view when we need to set this, so I have to
198 : * find another solution before adding them to this property set - MTG
199 : { OUString("IsGridVisible"), HANDLE_IS_GRID_VISIBLE, cppu::UnoType<bool>::get(), 0, 0},
200 : { OUString("IsSnapToGrid"), HANDLE_IS_SNAP_TO_GRID, cppu::UnoType<bool>::get(), 0, 0},
201 : { OUString("IsSynchroniseAxes"), HANDLE_IS_SYNCHRONISE_AXES, cppu::UnoType<bool>::get(), 0, 0},
202 : { OUString("HorizontalGridResolution"), HANDLE_HORIZONTAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0},
203 : { OUString("HorizontalGridSubdivision"), HANDLE_HORIZONTAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0},
204 : { OUString("VerticalGridResolution"), HANDLE_VERTICAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0},
205 : { OUString("VerticalGridSubdivision"), HANDLE_VERTICAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0},
206 :
207 : { OUString("ShowParagraphEnd"), HANDLE_SHOW_PARAGRAPH_END, cppu::UnoType<bool>::get(), 0, 0},
208 : { OUString("ShowOptionalHyphens"), HANDLE_SHOW_OPTIONAL_HYPHENS, cppu::UnoType<bool>::get(), 0, 0},
209 : { OUString("ShowSpaces"), HANDLE_SHOW_SPACES, cppu::UnoType<bool>::get(), 0, 0},
210 : { OUString("ShowTabs"), HANDLE_SHOW_TABS, cppu::UnoType<bool>::get(), 0, 0},
211 : { OUString("ShowBreaks"), HANDLE_SHOW_BREAKS, cppu::UnoType<bool>::get(), 0, 0},
212 : { OUString("ShowHiddenText"), HANDLE_SHOW_HIDDEN_TEXT, cppu::UnoType<bool>::get(), 0, 0},
213 : { OUString("ShowHiddenParagraphs"), HANDLE_SHOW_HIDDEN_PARAGRAPHS, cppu::UnoType<bool>::get(), 0, 0},
214 :
215 : { OUString("ShowTextLimitGuide"), HANDLE_SHOW_TEXT_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
216 : { OUString("ShowTableLimitGuide"), HANDLE_SHOW_TABLE_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
217 : { OUString("ShowSectionLimitGuide"), HANDLE_SHOW_SECTION_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
218 : { OUString("ShowGuidesWhileMoving"), HANDLE_SHOW_GUIDES_WHILE_MOVING, cppu::UnoType<bool>::get(), 0, 0},
219 : */
220 : { OUString(), 0, css::uno::Type(), 0, 0 }
221 0 : };
222 0 : return new MasterPropertySetInfo ( aWriterSettingsInfoMap );
223 : }
224 :
225 0 : SwXDocumentSettings::SwXDocumentSettings ( SwXTextDocument * pModel )
226 : : MasterPropertySet ( lcl_createSettingsInfo (),
227 0 : &Application::GetSolarMutex () )
228 : , mxModel ( pModel )
229 : , mpModel ( pModel )
230 : , mpDocSh ( NULL )
231 : , mpDoc ( NULL )
232 0 : , mpPrinter( NULL )
233 : {
234 0 : registerSlave ( new SwXPrintSettings ( PRINT_SETTINGS_DOCUMENT, mpModel->GetDocShell()->GetDoc() ) );
235 0 : }
236 :
237 0 : SwXDocumentSettings::~SwXDocumentSettings()
238 0 : throw()
239 : {
240 0 : }
241 :
242 0 : Any SAL_CALL SwXDocumentSettings::queryInterface( const Type& rType )
243 : throw(RuntimeException, std::exception)
244 : {
245 : return ::cppu::queryInterface ( rType,
246 : // OWeakObject interfaces
247 : dynamic_cast< XInterface* > ( dynamic_cast< OWeakObject* >(this) ),
248 : dynamic_cast< XWeak* > ( this ),
249 : // my own interfaces
250 : dynamic_cast< XPropertySet* > ( this ),
251 : dynamic_cast< XPropertyState* > ( this ),
252 : dynamic_cast< XMultiPropertySet* > ( this ),
253 : dynamic_cast< XServiceInfo* > ( this ),
254 0 : dynamic_cast< XTypeProvider* > ( this ) );
255 : }
256 0 : void SwXDocumentSettings::acquire ()
257 : throw ()
258 : {
259 0 : OWeakObject::acquire();
260 0 : }
261 0 : void SwXDocumentSettings::release ()
262 : throw ()
263 : {
264 0 : OWeakObject::release();
265 0 : }
266 :
267 0 : uno::Sequence< uno::Type > SAL_CALL SwXDocumentSettings::getTypes( )
268 : throw (RuntimeException, std::exception)
269 : {
270 0 : SolarMutexGuard aGuard;
271 :
272 0 : uno::Sequence< uno::Type > aBaseTypes( 5 );
273 0 : uno::Type* pBaseTypes = aBaseTypes.getArray();
274 :
275 : // from MasterPropertySet
276 0 : pBaseTypes[0] = ::getCppuType((Reference< XPropertySet >*)0);
277 0 : pBaseTypes[1] = ::getCppuType((Reference< XPropertyState >*)0);
278 0 : pBaseTypes[2] = ::getCppuType((Reference< XMultiPropertySet >*)0);
279 :
280 0 : pBaseTypes[3] = ::getCppuType((Reference< XServiceInfo >*)0);
281 0 : pBaseTypes[4] = ::getCppuType((Reference< XTypeProvider >*)0);
282 :
283 0 : return aBaseTypes;
284 : }
285 :
286 0 : uno::Sequence< sal_Int8 > SAL_CALL SwXDocumentSettings::getImplementationId( )
287 : throw (RuntimeException, std::exception)
288 : {
289 0 : return css::uno::Sequence<sal_Int8>();
290 : }
291 :
292 0 : void SwXDocumentSettings::_preSetValues ()
293 : throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
294 : {
295 0 : mpDocSh = mpModel->GetDocShell();
296 0 : if (NULL == mpDocSh)
297 0 : throw UnknownPropertyException();
298 :
299 0 : mpDoc = mpDocSh->GetDoc();
300 0 : if (NULL == mpDoc)
301 0 : throw UnknownPropertyException();
302 0 : }
303 :
304 0 : void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
305 : throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
306 : {
307 0 : if (rInfo.mnAttributes & PropertyAttribute::READONLY)
308 0 : throw PropertyVetoException ("Property is read-only: " + rInfo.maName, static_cast < cppu::OWeakObject * > ( 0 ) );
309 :
310 0 : switch( rInfo.mnHandle )
311 : {
312 : case HANDLE_FORBIDDEN_CHARS:
313 0 : break;
314 : case HANDLE_LINK_UPDATE_MODE:
315 : {
316 0 : sal_Int16 nMode = 0;
317 0 : rValue >>= nMode;
318 0 : switch (nMode)
319 : {
320 : case NEVER:
321 : case MANUAL:
322 : case AUTOMATIC:
323 : case GLOBALSETTING:
324 0 : break;
325 : default:
326 0 : throw IllegalArgumentException();
327 : }
328 0 : mpDoc->setLinkUpdateMode(nMode);
329 : }
330 0 : break;
331 : case HANDLE_FIELD_AUTO_UPDATE:
332 : {
333 0 : sal_Bool bUpdateField = *(sal_Bool*)rValue.getValue();
334 0 : SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
335 : mpDoc->setFieldUpdateFlags( bUpdateField ?
336 : nFlag == AUTOUPD_FIELD_AND_CHARTS ?
337 : AUTOUPD_FIELD_AND_CHARTS :
338 : AUTOUPD_FIELD_ONLY :
339 0 : AUTOUPD_OFF );
340 : }
341 0 : break;
342 : case HANDLE_CHART_AUTO_UPDATE:
343 : {
344 0 : sal_Bool bUpdateChart = *(sal_Bool*)rValue.getValue();
345 0 : SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
346 0 : mpDoc->setFieldUpdateFlags( (nFlag == AUTOUPD_FIELD_ONLY || nFlag == AUTOUPD_FIELD_AND_CHARTS ) ?
347 : bUpdateChart ?
348 : AUTOUPD_FIELD_AND_CHARTS :
349 : AUTOUPD_FIELD_ONLY :
350 0 : AUTOUPD_OFF );
351 : }
352 0 : break;
353 : case HANDLE_ADD_PARA_TABLE_SPACING:
354 : {
355 0 : sal_Bool bParaSpace = sal_False;
356 0 : rValue >>= bParaSpace;
357 0 : mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX, bParaSpace );
358 : }
359 0 : break;
360 : case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
361 : {
362 0 : sal_Bool bParaSpacePage = sal_False;
363 0 : rValue >>= bParaSpacePage;
364 0 : mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, bParaSpacePage );
365 : }
366 0 : break;
367 : case HANDLE_ALIGN_TAB_STOP_POSITION:
368 : {
369 0 : sal_Bool bAlignTab = *(sal_Bool*)rValue.getValue();
370 0 : mpDoc->set(IDocumentSettingAccess::TAB_COMPAT, bAlignTab);
371 : }
372 0 : break;
373 : case HANDLE_PRINTER_NAME:
374 : {
375 : //the printer must be created
376 0 : OUString sPrinterName;
377 0 : if( rValue >>= sPrinterName )
378 : {
379 0 : if( !mpPrinter && !sPrinterName.isEmpty() && mpDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
380 : {
381 0 : SfxPrinter* pPrinter = mpDoc->getPrinter( true );
382 0 : if ( OUString ( pPrinter->GetName()) != sPrinterName )
383 : {
384 0 : SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
385 0 : if( pNewPrinter->IsKnown() )
386 : {
387 : // set printer only once; in _postSetValues
388 0 : mpPrinter = pNewPrinter;
389 : }
390 : else
391 : {
392 0 : delete pNewPrinter;
393 : }
394 : }
395 : }
396 : }
397 : else
398 0 : throw IllegalArgumentException();
399 : }
400 0 : break;
401 : case HANDLE_PRINTER_SETUP:
402 : {
403 0 : Sequence < sal_Int8 > aSequence;
404 0 : if ( rValue >>= aSequence )
405 : {
406 0 : sal_uInt32 nSize = aSequence.getLength();
407 0 : if( nSize > 0 )
408 : {
409 0 : SvMemoryStream aStream (aSequence.getArray(), nSize,
410 0 : STREAM_READ );
411 0 : aStream.Seek ( STREAM_SEEK_TO_BEGIN );
412 : static sal_uInt16 const nRange[] =
413 : {
414 : FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
415 : SID_HTML_MODE, SID_HTML_MODE,
416 : SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
417 : SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
418 : 0
419 : };
420 0 : SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
421 0 : SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
422 :
423 : // set printer only once; in _postSetValues
424 0 : delete mpPrinter;
425 0 : mpPrinter = pPrinter;
426 : }
427 : }
428 : else
429 0 : throw IllegalArgumentException();
430 : }
431 0 : break;
432 : case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
433 : {
434 0 : sal_Bool bIsKern = *(sal_Bool*)(rValue).getValue();
435 0 : mpDoc->set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION, bIsKern);
436 0 : SwEditShell* pEditSh = mpDoc->GetEditShell();
437 0 : if(pEditSh)
438 0 : pEditSh->ChgHyphenation();
439 : }
440 0 : break;
441 : case HANDLE_CHARACTER_COMPRESSION_TYPE:
442 : {
443 0 : sal_Int16 nMode = 0;
444 0 : rValue >>= nMode;
445 0 : switch (nMode)
446 : {
447 : case CHARCOMPRESS_NONE:
448 : case CHARCOMPRESS_PUNCTUATION:
449 : case CHARCOMPRESS_PUNCTUATION_KANA:
450 0 : break;
451 : default:
452 0 : throw IllegalArgumentException();
453 : }
454 0 : mpDoc->setCharacterCompressionType(static_cast < SwCharCompressType > (nMode) );
455 : }
456 0 : break;
457 : case HANDLE_APPLY_USER_DATA:
458 : {
459 0 : mpDocSh->SetUseUserData( *(sal_Bool*)rValue.getValue() );
460 : }
461 0 : break;
462 : case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
463 : {
464 0 : sal_Bool bSaveGlobal = *(sal_Bool*)rValue.getValue();
465 0 : mpDoc->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bSaveGlobal );
466 : }
467 0 : break;
468 : case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
469 : {
470 0 : SwDBData aData = mpDoc->GetDBData();
471 0 : if ( rValue >>= aData.sDataSource )
472 0 : mpDoc->ChgDBData( aData );
473 : }
474 0 : break;
475 : case HANDLE_CURRENT_DATABASE_COMMAND:
476 : {
477 0 : SwDBData aData = mpDoc->GetDBData();
478 :
479 0 : if ( rValue >>= aData.sCommand )
480 0 : mpDoc->ChgDBData( aData );
481 :
482 : SAL_WARN_IF( aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty(), "sw.uno",
483 0 : "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" );
484 : }
485 0 : break;
486 : case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
487 : {
488 0 : SwDBData aData = mpDoc->GetDBData();
489 0 : if ( rValue >>= aData.nCommandType )
490 0 : mpDoc->ChgDBData( aData );
491 : SAL_WARN_IF( aData.nCommandType && aData.sDataSource.isEmpty(), "sw.uno",
492 : "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" );
493 : SAL_WARN_IF( aData.nCommandType && aData.sCommand.isEmpty(), "sw.uno",
494 0 : "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" );
495 : }
496 0 : break;
497 : case HANDLE_SAVE_VERSION_ON_CLOSE:
498 : {
499 0 : mpDocSh->SetSaveVersionOnClose( *(sal_Bool*)rValue.getValue() );
500 : }
501 0 : break;
502 : case HANDLE_UPDATE_FROM_TEMPLATE:
503 : {
504 0 : mpDocSh->SetQueryLoadTemplate( *(sal_Bool*)rValue.getValue() );
505 : }
506 0 : break;
507 : case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
508 : {
509 0 : sal_Int16 nTmp = 0;
510 0 : rValue >>= nTmp;
511 :
512 0 : bool bUseVirDev = true;
513 0 : bool bHiResVirDev = true;
514 0 : if( nTmp == document::PrinterIndependentLayout::DISABLED )
515 0 : bUseVirDev = false;
516 0 : else if ( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
517 0 : bHiResVirDev = false;
518 0 : else if ( nTmp != document::PrinterIndependentLayout::HIGH_RESOLUTION )
519 0 : throw IllegalArgumentException();
520 :
521 0 : mpDoc->setReferenceDeviceType( bUseVirDev, bHiResVirDev );
522 : }
523 0 : break;
524 : case HANDLE_IS_LABEL_DOC :
525 : {
526 0 : sal_Bool bSet = sal_False;
527 0 : if(!(rValue >>= bSet))
528 0 : throw IllegalArgumentException();
529 0 : mpDoc->set(IDocumentSettingAccess::LABEL_DOCUMENT, bSet);
530 : }
531 0 : break;
532 : case HANDLE_IS_ADD_FLY_OFFSET:
533 : {
534 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
535 0 : mpDoc->set(IDocumentSettingAccess::ADD_FLY_OFFSETS, bTmp);
536 : }
537 0 : break;
538 : case HANDLE_IS_ADD_EXTERNAL_LEADING:
539 : {
540 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
541 0 : mpDoc->set(IDocumentSettingAccess::ADD_EXT_LEADING, bTmp);
542 : }
543 0 : break;
544 : case HANDLE_OLD_NUMBERING: // #111955#
545 : {
546 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
547 0 : mpDoc->set(IDocumentSettingAccess::OLD_NUMBERING, bTmp);
548 : }
549 0 : break;
550 : case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING:
551 : {
552 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
553 0 : mpDoc->set(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE, bTmp);
554 : }
555 0 : break;
556 : case HANDLE_ALLOW_PRINTJOB_CANCEL:
557 : {
558 0 : sal_Bool bState = sal_False;
559 0 : if (!(rValue >>= bState))
560 0 : throw IllegalArgumentException();
561 0 : mpDocSh->Stamp_SetPrintCancelState(bState);
562 : }
563 0 : break;
564 : case HANDLE_USE_FORMER_LINE_SPACING:
565 : {
566 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
567 0 : mpDoc->set(IDocumentSettingAccess::OLD_LINE_SPACING, bTmp);
568 : }
569 0 : break;
570 : case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
571 : {
572 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
573 0 : mpDoc->set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, bTmp);
574 : }
575 0 : break;
576 : case HANDLE_USE_FORMER_OBJECT_POSITIONING:
577 : {
578 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
579 0 : mpDoc->set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, bTmp);
580 : }
581 0 : break;
582 : case HANDLE_USE_FORMER_TEXT_WRAPPING:
583 : {
584 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
585 0 : mpDoc->set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, bTmp);
586 : }
587 0 : break;
588 : case HANDLE_CHANGES_PASSWORD:
589 : {
590 0 : Sequence <sal_Int8> aNew;
591 0 : if(rValue >>= aNew)
592 : {
593 0 : mpDoc->SetRedlinePassword(aNew);
594 0 : if(aNew.getLength())
595 : {
596 0 : sal_uInt16 eMode = mpDoc->GetRedlineMode();
597 0 : eMode = eMode|nsRedlineMode_t::REDLINE_ON;
598 0 : mpDoc->SetRedlineMode((RedlineMode_t)( eMode ));
599 : }
600 0 : }
601 : }
602 0 : break;
603 : case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
604 : {
605 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
606 0 : mpDoc->set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, bTmp );
607 : }
608 0 : break;
609 : case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
610 : {
611 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
612 0 : mpDoc->set(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, bTmp);
613 : }
614 0 : break;
615 : case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
616 : {
617 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
618 0 : mpDoc->set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, bTmp);
619 : }
620 0 : break;
621 : case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
622 : {
623 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
624 0 : mpDoc->set(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, bTmp);
625 : }
626 0 : break;
627 : case HANDLE_TABLE_ROW_KEEP:
628 : {
629 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
630 0 : mpDoc->set(IDocumentSettingAccess::TABLE_ROW_KEEP, bTmp);
631 : }
632 0 : break;
633 : case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
634 : {
635 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
636 0 : mpDoc->set(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, bTmp);
637 : }
638 0 : break;
639 : case HANDLE_LOAD_READONLY:
640 : {
641 0 : mpDocSh->SetLoadReadonly( *(sal_Bool*)rValue.getValue() );
642 : }
643 0 : break;
644 : case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
645 : {
646 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
647 0 : mpDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, bTmp);
648 : }
649 0 : break;
650 : case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
651 : {
652 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
653 0 : mpDoc->set(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME, bTmp);
654 : }
655 0 : break;
656 : case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
657 : {
658 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
659 0 : mpDoc->set(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING, bTmp);
660 : }
661 0 : break;
662 : case HANDLE_USE_OLD_PRINTER_METRICS:
663 : // ignore - this is a dead property
664 0 : break;
665 : case HANDLE_TABS_RELATIVE_TO_INDENT:
666 : {
667 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
668 0 : mpDoc->set(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT, bTmp);
669 : }
670 0 : break;
671 : case HANDLE_RSID:
672 : {
673 0 : sal_uInt32 nTmp = 0;
674 0 : rValue >>= nTmp;
675 0 : mpDoc->setRsid( nTmp );
676 : }
677 0 : break;
678 : case HANDLE_RSID_ROOT:
679 : {
680 0 : sal_uInt32 nTmp = 0;
681 0 : rValue >>= nTmp;
682 0 : mpDoc->setRsidRoot( nTmp );
683 : }
684 0 : break;
685 : case HANDLE_PROTECT_FORM:
686 : {
687 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
688 0 : mpDoc->set(IDocumentSettingAccess::PROTECT_FORM, bTmp);
689 : }
690 0 : break;
691 : // #i89181#
692 : case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
693 : {
694 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
695 0 : mpDoc->set(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, bTmp);
696 : }
697 0 : break;
698 : case HANDLE_MODIFYPASSWORDINFO:
699 : {
700 0 : uno::Sequence< beans::PropertyValue > aInfo;
701 0 : if ( !( rValue >>= aInfo ) )
702 : throw lang::IllegalArgumentException(
703 : OUString( "Value of type Sequence<PropertyValue> expected!" ),
704 : uno::Reference< uno::XInterface >(),
705 0 : 2 );
706 :
707 0 : if ( !mpDocSh->SetModifyPasswordInfo( aInfo ) )
708 : throw beans::PropertyVetoException(
709 : OUString( "The hash is not allowed to be changed now!" ),
710 0 : uno::Reference< uno::XInterface >() );
711 : }
712 0 : break;
713 : case HANDLE_MATH_BASELINE_ALIGNMENT:
714 : {
715 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
716 0 : mpDoc->set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT, bTmp );
717 : }
718 0 : break;
719 : case HANDLE_INVERT_BORDER_SPACING:
720 : {
721 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
722 0 : mpDoc->set(IDocumentSettingAccess::INVERT_BORDER_SPACING, bTmp);
723 : }
724 0 : break;
725 : case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
726 : {
727 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
728 0 : mpDoc->set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, bTmp);
729 : }
730 0 : break;
731 : case HANDLE_SMALL_CAPS_PERCENTAGE_66:
732 : {
733 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
734 0 : mpDoc->set(IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66, bTmp);
735 : }
736 0 : break;
737 : case HANDLE_TAB_OVERFLOW:
738 : {
739 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
740 0 : mpDoc->set(IDocumentSettingAccess::TAB_OVERFLOW, bTmp);
741 : }
742 0 : break;
743 : case HANDLE_UNBREAKABLE_NUMBERINGS:
744 : {
745 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
746 0 : mpDoc->set(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS, bTmp);
747 : }
748 0 : break;
749 : case HANDLE_STYLES_NODEFAULT:
750 : {
751 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
752 0 : mpDoc->set(IDocumentSettingAccess::STYLES_NODEFAULT, bTmp);
753 : }
754 0 : break;
755 : case HANDLE_FLOATTABLE_NOMARGINS:
756 : {
757 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
758 0 : mpDoc->set(IDocumentSettingAccess::FLOATTABLE_NOMARGINS, bTmp);
759 : }
760 0 : break;
761 : case HANDLE_CLIPPED_PICTURES:
762 : {
763 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
764 0 : mpDoc->set(IDocumentSettingAccess::CLIPPED_PICTURES, bTmp);
765 : }
766 0 : break;
767 : case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS:
768 : {
769 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
770 0 : mpDoc->set(IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS, bTmp);
771 : }
772 0 : break;
773 : case HANDLE_EMBED_FONTS:
774 : {
775 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
776 0 : mpDoc->set(IDocumentSettingAccess::EMBED_FONTS, bTmp);
777 : }
778 : case HANDLE_EMBED_SYSTEM_FONTS:
779 : {
780 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
781 0 : mpDoc->set(IDocumentSettingAccess::EMBED_SYSTEM_FONTS, bTmp);
782 : }
783 0 : break;
784 : case HANDLE_TAB_OVER_MARGIN:
785 : {
786 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
787 0 : mpDoc->set(IDocumentSettingAccess::TAB_OVER_MARGIN, bTmp);
788 : }
789 0 : break;
790 : case HANDLE_SURROUND_TEXT_WRAP_SMALL:
791 : {
792 0 : sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
793 0 : mpDoc->set(IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL, bTmp);
794 : }
795 0 : break;
796 : default:
797 0 : throw UnknownPropertyException();
798 : }
799 0 : }
800 :
801 0 : void SwXDocumentSettings::_postSetValues ()
802 : throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
803 : {
804 : // set printer only once, namely here!
805 0 : if( mpPrinter != NULL )
806 : {
807 : // #i86352# the printer is also used as container for options by sfx
808 : // when setting a printer it should have decent default options
809 0 : SfxItemSet aOptions( mpPrinter->GetOptions() );
810 0 : SwPrintData aPrtData( mpDoc->getPrintData() );
811 0 : SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData);
812 0 : aOptions.Put(aAddPrinterItem);
813 0 : mpPrinter->SetOptions( aOptions );
814 :
815 0 : mpDoc->setPrinter( mpPrinter, true, true );
816 : }
817 :
818 0 : mpPrinter = 0;
819 0 : mpDocSh = 0;
820 0 : mpDoc = 0;
821 0 : }
822 :
823 0 : void SwXDocumentSettings::_preGetValues ()
824 : throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
825 : {
826 0 : mpDocSh = mpModel->GetDocShell();
827 0 : if (NULL == mpDocSh)
828 0 : throw UnknownPropertyException();
829 0 : mpDoc = mpDocSh->GetDoc();
830 0 : if (NULL == mpDoc)
831 0 : throw UnknownPropertyException();
832 0 : }
833 :
834 0 : void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
835 : throw(beans::UnknownPropertyException, lang::WrappedTargetException )
836 : {
837 0 : switch( rInfo.mnHandle )
838 : {
839 : case HANDLE_FORBIDDEN_CHARS:
840 : {
841 0 : Reference<XForbiddenCharacters> xRet(*mpModel->GetPropertyHelper(), UNO_QUERY);
842 0 : rValue <<= xRet;
843 : }
844 0 : break;
845 : case HANDLE_LINK_UPDATE_MODE:
846 : {
847 0 : rValue <<= static_cast < sal_Int16 > ( mpDoc->getLinkUpdateMode(true) );
848 : }
849 0 : break;
850 : case HANDLE_FIELD_AUTO_UPDATE:
851 : {
852 0 : SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
853 0 : sal_Bool bFieldUpd = (nFlags == AUTOUPD_FIELD_ONLY || nFlags == AUTOUPD_FIELD_AND_CHARTS );
854 0 : rValue.setValue(&bFieldUpd, ::getBooleanCppuType());
855 : }
856 0 : break;
857 : case HANDLE_CHART_AUTO_UPDATE:
858 : {
859 0 : SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
860 0 : sal_Bool bChartUpd = nFlags == AUTOUPD_FIELD_AND_CHARTS;
861 0 : rValue.setValue(&bChartUpd, ::getBooleanCppuType());
862 : }
863 0 : break;
864 : case HANDLE_ADD_PARA_TABLE_SPACING:
865 : {
866 0 : sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX);
867 0 : rValue.setValue(&bParaSpace, ::getBooleanCppuType());
868 : }
869 0 : break;
870 : case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
871 : {
872 0 : sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES);
873 0 : rValue.setValue(&bParaSpace, ::getBooleanCppuType());
874 : }
875 0 : break;
876 : case HANDLE_ALIGN_TAB_STOP_POSITION:
877 : {
878 0 : sal_Bool bAlignTab = mpDoc->get(IDocumentSettingAccess::TAB_COMPAT);
879 0 : rValue.setValue(&bAlignTab, ::getBooleanCppuType());
880 : }
881 0 : break;
882 : case HANDLE_PRINTER_NAME:
883 : {
884 0 : SfxPrinter *pPrinter = mpDoc->getPrinter( false );
885 0 : rValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString();
886 : }
887 0 : break;
888 : case HANDLE_PRINTER_SETUP:
889 : {
890 0 : SfxPrinter *pPrinter = mpDoc->getPrinter( false );
891 0 : if (pPrinter)
892 : {
893 0 : SvMemoryStream aStream;
894 0 : pPrinter->Store( aStream );
895 0 : aStream.Seek ( STREAM_SEEK_TO_END );
896 0 : sal_uInt32 nSize = aStream.Tell();
897 0 : aStream.Seek ( STREAM_SEEK_TO_BEGIN );
898 0 : Sequence < sal_Int8 > aSequence( nSize );
899 0 : aStream.Read ( aSequence.getArray(), nSize );
900 0 : rValue <<= aSequence;
901 : }
902 : else
903 : {
904 0 : Sequence < sal_Int8 > aSequence ( 0 );
905 0 : rValue <<= aSequence;
906 : }
907 : }
908 0 : break;
909 : case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
910 : {
911 0 : sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION);
912 0 : rValue.setValue(&bParaSpace, ::getBooleanCppuType());
913 : }
914 0 : break;
915 : case HANDLE_APPLY_USER_DATA:
916 : {
917 0 : rValue <<= mpDocSh->IsUseUserData();
918 : }
919 0 : break;
920 : case HANDLE_CHARACTER_COMPRESSION_TYPE:
921 : {
922 0 : rValue <<= static_cast < sal_Int16 > (mpDoc->getCharacterCompressionType());
923 : }
924 0 : break;
925 : case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
926 : {
927 0 : sal_Bool bSaveGlobal = mpDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS);
928 0 : rValue.setValue(&bSaveGlobal, ::getBooleanCppuType());
929 : }
930 0 : break;
931 : case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
932 : {
933 0 : const SwDBData& rData = mpDoc->GetDBDesc();
934 0 : rValue <<= rData.sDataSource;
935 : }
936 0 : break;
937 : case HANDLE_CURRENT_DATABASE_COMMAND:
938 : {
939 0 : const SwDBData& rData = mpDoc->GetDBDesc();
940 0 : rValue <<= rData.sCommand;
941 : }
942 0 : break;
943 : case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
944 : {
945 0 : const SwDBData& rData = mpDoc->GetDBDesc();
946 0 : rValue <<= rData.nCommandType;
947 : }
948 0 : break;
949 : case HANDLE_SAVE_VERSION_ON_CLOSE:
950 : {
951 0 : rValue <<= mpDocSh->IsSaveVersionOnClose();
952 : }
953 0 : break;
954 : case HANDLE_UPDATE_FROM_TEMPLATE:
955 : {
956 0 : rValue <<= mpDocSh->IsQueryLoadTemplate();
957 : }
958 0 : break;
959 : case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
960 : {
961 : // returns short (see css.document.PrinterIndependentLayout)
962 0 : sal_Int16 nVirDevType = mpDoc->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ?
963 0 : ( mpDoc->get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) ?
964 : document::PrinterIndependentLayout::HIGH_RESOLUTION :
965 : document::PrinterIndependentLayout::LOW_RESOLUTION ) :
966 0 : document::PrinterIndependentLayout::DISABLED;
967 0 : rValue <<= nVirDevType;
968 : }
969 0 : break;
970 : case HANDLE_IS_LABEL_DOC:
971 : {
972 0 : sal_Bool bLabel = mpDoc->get(IDocumentSettingAccess::LABEL_DOCUMENT);
973 0 : rValue <<= bLabel;
974 : }
975 0 : break;
976 : case HANDLE_IS_ADD_FLY_OFFSET:
977 : {
978 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_FLY_OFFSETS);
979 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
980 : }
981 0 : break;
982 : case HANDLE_IS_ADD_EXTERNAL_LEADING:
983 : {
984 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_EXT_LEADING);
985 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
986 : }
987 0 : break;
988 : case HANDLE_OLD_NUMBERING: // #111955#
989 : {
990 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_NUMBERING);
991 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
992 : }
993 0 : break;
994 : case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING: // #111955#
995 : {
996 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE);
997 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
998 : }
999 0 : break;
1000 : case HANDLE_ALLOW_PRINTJOB_CANCEL:
1001 : {
1002 0 : sal_Bool bPrintCancelState = mpDocSh->Stamp_GetPrintCancelState();
1003 0 : rValue.setValue(&bPrintCancelState, ::getBooleanCppuType());
1004 : }
1005 0 : break;
1006 : case HANDLE_USE_FORMER_LINE_SPACING:
1007 : {
1008 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_LINE_SPACING);
1009 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1010 : }
1011 0 : break;
1012 : case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
1013 : {
1014 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS);
1015 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1016 : }
1017 0 : break;
1018 : case HANDLE_USE_FORMER_OBJECT_POSITIONING:
1019 : {
1020 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS);
1021 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1022 : }
1023 0 : break;
1024 : case HANDLE_USE_FORMER_TEXT_WRAPPING:
1025 : {
1026 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING);
1027 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1028 : }
1029 0 : break;
1030 : case HANDLE_CHANGES_PASSWORD:
1031 : {
1032 0 : rValue <<= mpDoc->GetRedlinePassword();
1033 : }
1034 0 : break;
1035 : case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
1036 : {
1037 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION);
1038 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1039 : }
1040 0 : break;
1041 : case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
1042 : {
1043 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING);
1044 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1045 : }
1046 0 : break;
1047 : case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
1048 : {
1049 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK);
1050 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1051 : }
1052 0 : break;
1053 : case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
1054 : {
1055 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT);
1056 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1057 : }
1058 0 : break;
1059 : case HANDLE_TABLE_ROW_KEEP :
1060 : {
1061 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABLE_ROW_KEEP);
1062 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1063 : }
1064 0 : break;
1065 : case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
1066 : {
1067 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION);
1068 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1069 : }
1070 0 : break;
1071 : case HANDLE_LOAD_READONLY:
1072 : {
1073 0 : rValue <<= mpDocSh->IsLoadReadonly();
1074 : }
1075 0 : break;
1076 : case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
1077 : {
1078 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE);
1079 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1080 : }
1081 0 : break;
1082 : case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
1083 : {
1084 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME);
1085 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1086 : }
1087 0 : break;
1088 : case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
1089 : {
1090 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING);
1091 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1092 : }
1093 0 : break;
1094 : case HANDLE_USE_OLD_PRINTER_METRICS:
1095 : {
1096 0 : sal_Bool bTmp = sal_False;
1097 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1098 : }
1099 0 : break;
1100 : case HANDLE_TABS_RELATIVE_TO_INDENT:
1101 : {
1102 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
1103 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1104 : }
1105 0 : break;
1106 : case HANDLE_RSID:
1107 : {
1108 0 : rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsid() );
1109 : }
1110 0 : break;
1111 : case HANDLE_RSID_ROOT:
1112 : {
1113 0 : rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsidRoot() );
1114 : }
1115 0 : break;
1116 : case HANDLE_PROTECT_FORM:
1117 : {
1118 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::PROTECT_FORM);
1119 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1120 : }
1121 0 : break;
1122 : // #i89181#
1123 : case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
1124 : {
1125 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST);
1126 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1127 : }
1128 0 : break;
1129 : case HANDLE_MODIFYPASSWORDINFO:
1130 : {
1131 0 : rValue <<= mpDocSh->GetModifyPasswordInfo();
1132 : }
1133 0 : break;
1134 : case HANDLE_MATH_BASELINE_ALIGNMENT:
1135 : {
1136 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
1137 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1138 : }
1139 0 : break;
1140 : case HANDLE_INVERT_BORDER_SPACING:
1141 : {
1142 0 : sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::INVERT_BORDER_SPACING);
1143 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1144 : }
1145 0 : break;
1146 : case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
1147 : {
1148 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA );
1149 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1150 : }
1151 0 : break;
1152 : case HANDLE_SMALL_CAPS_PERCENTAGE_66:
1153 : {
1154 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66 );
1155 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1156 : }
1157 0 : break;
1158 : case HANDLE_TAB_OVERFLOW:
1159 : {
1160 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVERFLOW );
1161 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1162 : }
1163 0 : break;
1164 : case HANDLE_UNBREAKABLE_NUMBERINGS:
1165 : {
1166 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS );
1167 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1168 : }
1169 0 : break;
1170 : case HANDLE_STYLES_NODEFAULT:
1171 : {
1172 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::STYLES_NODEFAULT );
1173 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1174 : }
1175 0 : break;
1176 : case HANDLE_FLOATTABLE_NOMARGINS:
1177 : {
1178 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::FLOATTABLE_NOMARGINS );
1179 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1180 : }
1181 0 : break;
1182 : case HANDLE_CLIPPED_PICTURES:
1183 : {
1184 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::CLIPPED_PICTURES );
1185 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1186 : }
1187 0 : break;
1188 : case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS:
1189 : {
1190 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS );
1191 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1192 : }
1193 0 : break;
1194 : case HANDLE_EMBED_FONTS:
1195 : {
1196 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_FONTS );
1197 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1198 : }
1199 0 : break;
1200 : case HANDLE_EMBED_SYSTEM_FONTS:
1201 : {
1202 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS );
1203 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1204 : }
1205 0 : break;
1206 : case HANDLE_TAB_OVER_MARGIN:
1207 : {
1208 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVER_MARGIN );
1209 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1210 : }
1211 0 : break;
1212 : case HANDLE_SURROUND_TEXT_WRAP_SMALL:
1213 : {
1214 0 : sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL );
1215 0 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
1216 : }
1217 0 : break;
1218 : default:
1219 0 : throw UnknownPropertyException();
1220 : }
1221 0 : }
1222 :
1223 0 : void SwXDocumentSettings::_postGetValues ()
1224 : throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
1225 : {
1226 0 : mpDocSh = 0;
1227 0 : mpDoc = 0;
1228 0 : }
1229 :
1230 : // XServiceInfo
1231 0 : OUString SAL_CALL SwXDocumentSettings::getImplementationName( )
1232 : throw(RuntimeException, std::exception)
1233 : {
1234 0 : return OUString("com.sun.star.comp.Writer.DocumentSettings");
1235 : }
1236 :
1237 0 : sal_Bool SAL_CALL SwXDocumentSettings::supportsService( const OUString& ServiceName )
1238 : throw(RuntimeException, std::exception)
1239 : {
1240 0 : return cppu::supportsService(this, ServiceName);
1241 : }
1242 :
1243 0 : Sequence< OUString > SAL_CALL SwXDocumentSettings::getSupportedServiceNames( )
1244 : throw(RuntimeException, std::exception)
1245 : {
1246 0 : Sequence< OUString > aSeq( 3 );
1247 0 : aSeq[0] = "com.sun.star.document.Settings";
1248 0 : aSeq[1] = "com.sun.star.text.DocumentSettings";
1249 0 : aSeq[2] = "com.sun.star.text.PrintSettings";
1250 0 : return aSeq;
1251 : }
1252 :
1253 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|