LibreOffice Module sw (master)  1
SwXDocumentSettings.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_features.h>
21 
22 #include <sal/config.h>
23 #include <sal/log.hxx>
24 
25 #include <utility>
26 
27 #include <o3tl/any.hxx>
29 #include "SwXDocumentSettings.hxx"
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
35 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
36 #include <doc.hxx>
40 #include <docsh.hxx>
41 #include <fldupde.hxx>
42 #include <linkenum.hxx>
43 #include <sfx2/printer.hxx>
44 #include <editsh.hxx>
45 #include <drawdoc.hxx>
46 #include <svl/zforlist.hxx>
47 #include <unotxdoc.hxx>
48 #include <cmdid.h>
49 #include <sfx2/zoomitem.hxx>
50 #include <unomod.hxx>
51 #include <vcl/svapp.hxx>
52 #include <svl/asiancfg.hxx>
53 #include <tools/stream.hxx>
54 
55 #include <swmodule.hxx>
56 #include <cfgitems.hxx>
57 #include <prtopt.hxx>
58 #include <dbmgr.hxx>
59 
60 using namespace comphelper;
61 using namespace ::com::sun::star;
62 using namespace ::com::sun::star::uno;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::lang;
65 using namespace ::com::sun::star::i18n;
66 
68 {
97  /* Stampit It disable the print cancel button of the shown progress dialog. */
146 };
147 
149 {
150  static PropertyInfo const aWriterSettingsInfoMap[] =
151  {
152  { OUString("ForbiddenCharacters"), HANDLE_FORBIDDEN_CHARS, cppu::UnoType<css::i18n::XForbiddenCharacters>::get(), 0},
153  { OUString("LinkUpdateMode"), HANDLE_LINK_UPDATE_MODE, cppu::UnoType<sal_Int16>::get(), 0},
154  { OUString("FieldAutoUpdate"), HANDLE_FIELD_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0},
155  { OUString("ChartAutoUpdate"), HANDLE_CHART_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0},
156  { OUString("AddParaTableSpacing"), HANDLE_ADD_PARA_TABLE_SPACING, cppu::UnoType<bool>::get(), 0},
157  { OUString("AddParaTableSpacingAtStart"), HANDLE_ADD_PARA_TABLE_SPACING_AT_START, cppu::UnoType<bool>::get(), 0},
158  { OUString("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, cppu::UnoType<bool>::get(), 0},
159  { OUString("PrinterName"), HANDLE_PRINTER_NAME, cppu::UnoType<OUString>::get(), 0},
161  { OUString("PrinterPaperFromSetup"), HANDLE_PRINTER_PAPER, cppu::UnoType<bool>::get(), 0},
162  { OUString("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, cppu::UnoType<bool>::get(), 0},
163  { OUString("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, cppu::UnoType<sal_Int16>::get(), 0},
164  { OUString("ApplyUserData"), HANDLE_APPLY_USER_DATA, cppu::UnoType<bool>::get(), 0 },
165  { OUString("SaveThumbnail"), HANDLE_SAVE_THUMBNAIL, cppu::UnoType<bool>::get(), 0 },
166  { OUString("SaveGlobalDocumentLinks"), HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, cppu::UnoType<bool>::get(), 0},
167  { OUString("CurrentDatabaseDataSource"), HANDLE_CURRENT_DATABASE_DATA_SOURCE, cppu::UnoType<OUString>::get(), 0},
168  { OUString("CurrentDatabaseCommand"), HANDLE_CURRENT_DATABASE_COMMAND, cppu::UnoType<OUString>::get(), 0},
169  { OUString("CurrentDatabaseCommandType"), HANDLE_CURRENT_DATABASE_COMMAND_TYPE, cppu::UnoType<sal_Int32>::get(), 0},
170  { OUString("EmbeddedDatabaseName"), HANDLE_EMBEDDED_DATABASE_NAME, cppu::UnoType<OUString>::get(), 0},
171  { OUString("SaveVersionOnClose"), HANDLE_SAVE_VERSION_ON_CLOSE, cppu::UnoType<bool>::get(), 0},
172  { OUString("UpdateFromTemplate"), HANDLE_UPDATE_FROM_TEMPLATE, cppu::UnoType<bool>::get(), 0},
173 
174  { OUString("PrinterIndependentLayout"), HANDLE_PRINTER_INDEPENDENT_LAYOUT, cppu::UnoType<sal_Int16>::get(), 0},
175  { OUString("IsLabelDocument"), HANDLE_IS_LABEL_DOC, cppu::UnoType<bool>::get(), 0},
176  { OUString("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, cppu::UnoType<bool>::get(), 0},
177  { OUString("AddVerticalFrameOffsets"), HANDLE_IS_ADD_VERTICAL_FLY_OFFSET, cppu::UnoType<bool>::get(), 0},
178  { OUString("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, cppu::UnoType<bool>::get(), 0},
179  { OUString("UseOldNumbering"), HANDLE_OLD_NUMBERING, cppu::UnoType<bool>::get(), 0},
180  { OUString("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, cppu::UnoType<bool>::get(), 0},
181  /* Stampit It disable the print cancel button of the shown progress dialog. */
182  { OUString("AllowPrintJobCancel"), HANDLE_ALLOW_PRINTJOB_CANCEL, cppu::UnoType<bool>::get(), 0},
183  { OUString("UseFormerLineSpacing"), HANDLE_USE_FORMER_LINE_SPACING, cppu::UnoType<bool>::get(), 0},
184  { OUString("AddParaSpacingToTableCells"), HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, cppu::UnoType<bool>::get(), 0},
185  { OUString("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, cppu::UnoType<bool>::get(), 0},
186  { OUString("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, cppu::UnoType<bool>::get(), 0},
187  { OUString("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0},
188  { OUString("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, cppu::UnoType<bool>::get(), 0},
189  { OUString("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, cppu::UnoType<bool>::get(), 0},
190  { OUString("DoNotJustifyLinesWithManualBreak"), HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, cppu::UnoType<bool>::get(), 0},
191  { OUString("DoNotResetParaAttrsForNumFont"), HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, cppu::UnoType<bool>::get(), 0},
192  { OUString("TableRowKeep"), HANDLE_TABLE_ROW_KEEP, cppu::UnoType<bool>::get(), 0},
193  { OUString("IgnoreTabsAndBlanksForLineCalculation"), HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, cppu::UnoType<bool>::get(), 0},
194  { OUString("LoadReadonly"), HANDLE_LOAD_READONLY, cppu::UnoType<bool>::get(), 0},
195  { OUString("DoNotCaptureDrawObjsOnPage"), HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, cppu::UnoType<bool>::get(), 0},
196  { OUString("ClipAsCharacterAnchoredWriterFlyFrames"), HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, cppu::UnoType<bool>::get(), 0},
197  { OUString("UnxForceZeroExtLeading"), HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, cppu::UnoType<bool>::get(), 0},
198  { OUString("UseOldPrinterMetrics"), HANDLE_USE_OLD_PRINTER_METRICS, cppu::UnoType<bool>::get(), 0},
199  { OUString("TabsRelativeToIndent"), HANDLE_TABS_RELATIVE_TO_INDENT, cppu::UnoType<bool>::get(), 0},
200  { OUString("Rsid"), HANDLE_RSID, cppu::UnoType<sal_Int32>::get(), 0},
201  { OUString("RsidRoot"), HANDLE_RSID_ROOT, cppu::UnoType<sal_Int32>::get(), 0},
202  { OUString("ProtectForm"), HANDLE_PROTECT_FORM, cppu::UnoType<bool>::get(), 0},
203  { OUString("MsWordCompTrailingBlanks"), HANDLE_MS_WORD_COMP_TRAILING_BLANKS, cppu::UnoType<bool>::get(), 0 },
204  { OUString("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, cppu::UnoType<bool>::get(), 0},
206  { OUString("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, cppu::UnoType<bool>::get(), 0},
207  { OUString("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, cppu::UnoType<bool>::get(), 0},
208  { OUString("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, cppu::UnoType<bool>::get(), 0},
209  { OUString("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, cppu::UnoType<bool>::get(), 0},
210  { OUString("TabOverflow"), HANDLE_TAB_OVERFLOW, cppu::UnoType<bool>::get(), 0},
211  { OUString("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, cppu::UnoType<bool>::get(), 0},
212  { OUString("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, cppu::UnoType<bool>::get(), 0},
213  { OUString("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, cppu::UnoType<bool>::get(), 0},
214  { OUString("ClippedPictures"), HANDLE_CLIPPED_PICTURES, cppu::UnoType<bool>::get(), 0},
215  { OUString("BackgroundParaOverDrawings"), HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, cppu::UnoType<bool>::get(), 0},
216  { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType<bool>::get(), 0},
217  { OUString("EmbedOnlyUsedFonts"), HANDLE_EMBED_USED_FONTS, cppu::UnoType<bool>::get(), 0},
218  { OUString("EmbedLatinScriptFonts"), HANDLE_EMBED_LATIN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0},
219  { OUString("EmbedAsianScriptFonts"), HANDLE_EMBED_ASIAN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0},
220  { OUString("EmbedComplexScriptFonts"), HANDLE_EMBED_COMPLEX_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0},
221  { OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType<bool>::get(), 0},
222  { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0},
223  { OUString("TreatSingleColumnBreakAsPageBreak"), HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, cppu::UnoType<bool>::get(), 0},
224  { OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 0},
225  { OUString("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, cppu::UnoType<bool>::get(), 0},
226  { OUString("PropLineSpacingShrinksFirstLine"), HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, cppu::UnoType<bool>::get(), 0},
227  { OUString("SubtractFlysAnchoredAtFlys"), HANDLE_SUBTRACT_FLYS, cppu::UnoType<bool>::get(), 0},
228  { OUString("DisableOffPagePositioning"), HANDLE_DISABLE_OFF_PAGE_POSITIONING, cppu::UnoType<bool>::get(), 0},
229  { OUString("EmptyDbFieldHidesPara"), HANDLE_EMPTY_DB_FIELD_HIDES_PARA, cppu::UnoType<bool>::get(), 0 },
230 /*
231  * As OS said, we don't have a view when we need to set this, so I have to
232  * find another solution before adding them to this property set - MTG
233  { OUString("IsGridVisible"), HANDLE_IS_GRID_VISIBLE, cppu::UnoType<bool>::get(), 0, 0},
234  { OUString("IsSnapToGrid"), HANDLE_IS_SNAP_TO_GRID, cppu::UnoType<bool>::get(), 0, 0},
235  { OUString("IsSynchroniseAxes"), HANDLE_IS_SYNCHRONISE_AXES, cppu::UnoType<bool>::get(), 0, 0},
236  { OUString("HorizontalGridResolution"), HANDLE_HORIZONTAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0},
237  { OUString("HorizontalGridSubdivision"), HANDLE_HORIZONTAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0},
238  { OUString("VerticalGridResolution"), HANDLE_VERTICAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0},
239  { OUString("VerticalGridSubdivision"), HANDLE_VERTICAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0},
240 
241  { OUString("ShowParagraphEnd"), HANDLE_SHOW_PARAGRAPH_END, cppu::UnoType<bool>::get(), 0, 0},
242  { OUString("ShowOptionalHyphens"), HANDLE_SHOW_OPTIONAL_HYPHENS, cppu::UnoType<bool>::get(), 0, 0},
243  { OUString("ShowSpaces"), HANDLE_SHOW_SPACES, cppu::UnoType<bool>::get(), 0, 0},
244  { OUString("ShowTabs"), HANDLE_SHOW_TABS, cppu::UnoType<bool>::get(), 0, 0},
245  { OUString("ShowBreaks"), HANDLE_SHOW_BREAKS, cppu::UnoType<bool>::get(), 0, 0},
246  { OUString("ShowHiddenText"), HANDLE_SHOW_HIDDEN_TEXT, cppu::UnoType<bool>::get(), 0, 0},
247  { OUString("ShowHiddenParagraphs"), HANDLE_SHOW_HIDDEN_PARAGRAPHS, cppu::UnoType<bool>::get(), 0, 0},
248 
249  { OUString("ShowTextLimitGuide"), HANDLE_SHOW_TEXT_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
250  { OUString("ShowTableLimitGuide"), HANDLE_SHOW_TABLE_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
251  { OUString("ShowSectionLimitGuide"), HANDLE_SHOW_SECTION_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0},
252  { OUString("ShowGuidesWhileMoving"), HANDLE_SHOW_GUIDES_WHILE_MOVING, cppu::UnoType<bool>::get(), 0, 0},
253 */
254  { OUString(), 0, css::uno::Type(), 0}
255  };
256  return new MasterPropertySetInfo ( aWriterSettingsInfoMap );
257 }
258 
261  &Application::GetSolarMutex () )
262 , mpModel ( pModel )
263 , mpDocSh ( nullptr )
264 , mpDoc ( nullptr )
265 , mpPrinter( nullptr )
266 , mbPreferPrinterPapersize( false )
267 {
269 }
270 
272  throw()
273 {
274 }
275 
277 {
278  return ::cppu::queryInterface ( rType,
279  // OWeakObject interfaces
280  dynamic_cast< XInterface* > ( dynamic_cast< OWeakObject* >(this) ),
281  dynamic_cast< XWeak* > ( this ),
282  // my own interfaces
283  dynamic_cast< XPropertySet* > ( this ),
284  dynamic_cast< XPropertyState* > ( this ),
285  dynamic_cast< XMultiPropertySet* > ( this ),
286  dynamic_cast< XServiceInfo* > ( this ),
287  dynamic_cast< XTypeProvider* > ( this ) );
288 }
290  throw ()
291 {
292  OWeakObject::acquire();
293 }
295  throw ()
296 {
297  OWeakObject::release();
298 }
299 
300 uno::Sequence< uno::Type > SAL_CALL SwXDocumentSettings::getTypes( )
301 {
302  static const uno::Sequence< uno::Type > aTypes {
303  // from MasterPropertySet
309  };
310  return aTypes;
311 }
312 
313 uno::Sequence< sal_Int8 > SAL_CALL SwXDocumentSettings::getImplementationId( )
314 {
315  return css::uno::Sequence<sal_Int8>();
316 }
317 
319 {
321  if (nullptr == mpDocSh)
322  throw UnknownPropertyException();
323 
324  mpDoc = mpDocSh->GetDoc();
325  if (nullptr == mpDoc)
326  throw UnknownPropertyException();
327 }
328 
330 {
331  if (rInfo.mnAttributes & PropertyAttribute::READONLY)
332  throw PropertyVetoException ("Property is read-only: " + rInfo.maName, static_cast < cppu::OWeakObject * > ( nullptr ) );
333 
334  switch( rInfo.mnHandle )
335  {
337  break;
339  {
340  sal_Int16 nMode = 0;
341  rValue >>= nMode;
342  switch (nMode)
343  {
344  case NEVER:
345  case MANUAL:
346  case AUTOMATIC:
347  case GLOBALSETTING:
348  break;
349  default:
350  throw IllegalArgumentException();
351  }
353  }
354  break;
356  {
357  bool bUpdateField = *o3tl::doAccess<bool>(rValue);
360  nFlag == AUTOUPD_FIELD_AND_CHARTS ?
363  AUTOUPD_OFF );
364  }
365  break;
367  {
368  bool bUpdateChart = *o3tl::doAccess<bool>(rValue);
371  bUpdateChart ?
374  AUTOUPD_OFF );
375  }
376  break;
378  {
379  bool bParaSpace = false;
380  rValue >>= bParaSpace;
382  }
383  break;
385  {
386  bool bParaSpacePage = false;
387  rValue >>= bParaSpacePage;
389  }
390  break;
392  {
393  bool bAlignTab = *o3tl::doAccess<bool>(rValue);
395  }
396  break;
397  case HANDLE_PRINTER_NAME:
398  {
399  //the printer must be created
400  OUString sPrinterName;
401  if( !(rValue >>= sPrinterName) )
402  throw IllegalArgumentException();
403 
404  if( !mpPrinter && !sPrinterName.isEmpty() && mpDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
405  {
406  SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true );
407  if ( pPrinter->GetName() != sPrinterName )
408  {
409  VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
410  assert (! pNewPrinter->isDisposed() );
411  if( pNewPrinter->IsKnown() )
412  {
413  // set printer only once; in _postSetValues
414  mpPrinter = pNewPrinter;
415  }
416  else
417  {
418  pNewPrinter.disposeAndClear();
419  }
420  }
421  }
422 
423  }
424  break;
426  {
427  Sequence < sal_Int8 > aSequence;
428  if ( !(rValue >>= aSequence) )
429  throw IllegalArgumentException();
430 
431  sal_uInt32 nSize = aSequence.getLength();
432  if( nSize > 0 )
433  {
434  SvMemoryStream aStream (aSequence.getArray(), nSize,
435  StreamMode::READ );
436  aStream.Seek ( STREAM_SEEK_TO_BEGIN );
437  static sal_uInt16 const nRange[] =
438  {
440  SID_HTML_MODE, SID_HTML_MODE,
441  SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
442  SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
443  0
444  };
445  auto pItemSet = std::make_unique<SfxItemSet>( mpDoc->GetAttrPool(), nRange );
446  VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
447  assert (! pPrinter->isDisposed() );
448  // set printer only once; in _postSetValues
450  mpPrinter = pPrinter;
451  }
452 
453  }
454  break;
456  {
457  bool bPreferPrinterPapersize;
458  if(!(rValue >>= bPreferPrinterPapersize))
459  throw IllegalArgumentException();
460  mbPreferPrinterPapersize = bPreferPrinterPapersize;
461  }
462  break;
464  {
465  bool bIsKern = *o3tl::doAccess<bool>(rValue);
467  SwEditShell* pEditSh = mpDoc->GetEditShell();
468  if(pEditSh)
469  pEditSh->ChgHyphenation();
470  }
471  break;
473  {
474  sal_Int16 nMode = 0;
475  rValue >>= nMode;
476  switch (static_cast<CharCompressType>(nMode))
477  {
478  case CharCompressType::NONE:
479  case CharCompressType::PunctuationOnly:
480  case CharCompressType::PunctuationAndKana:
481  break;
482  default:
483  throw IllegalArgumentException();
484  }
485  mpDoc->getIDocumentSettingAccess().setCharacterCompressionType(static_cast<CharCompressType>(nMode));
486  }
487  break;
489  {
490  mpDocSh->SetUseUserData(*o3tl::doAccess<bool>(rValue));
491  }
492  break;
494  {
495  mpDocSh->SetUseThumbnailSave(*o3tl::doAccess<bool>(rValue));
496  }
497  break;
499  {
500  bool bSaveGlobal = *o3tl::doAccess<bool>(rValue);
502  }
503  break;
505  {
507  if ( rValue >>= aData.sDataSource )
508  mpDoc->ChgDBData( aData );
509  }
510  break;
512  {
514 
515  if ( rValue >>= aData.sCommand )
516  mpDoc->ChgDBData( aData );
517 
518  SAL_WARN_IF( aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty(), "sw.uno",
519  "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" );
520  }
521  break;
523  {
525  if ( rValue >>= aData.nCommandType )
526  mpDoc->ChgDBData( aData );
527  SAL_WARN_IF( aData.nCommandType && aData.sDataSource.isEmpty(), "sw.uno",
528  "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" );
529  SAL_WARN_IF( aData.nCommandType && aData.sCommand.isEmpty(), "sw.uno",
530  "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" );
531  }
532  break;
534  {
535 #if HAVE_FEATURE_DBCONNECTIVITY
536  OUString sEmbeddedName;
537  if (rValue >>= sEmbeddedName)
538  mpDoc->GetDBManager()->setEmbeddedName(sEmbeddedName, *mpDocSh);
539 #endif
540  }
541  break;
543  {
544  mpDocSh->SetSaveVersionOnClose( *o3tl::doAccess<bool>(rValue) );
545  }
546  break;
548  {
549  mpDocSh->SetQueryLoadTemplate( *o3tl::doAccess<bool>(rValue) );
550  }
551  break;
553  {
554  sal_Int16 nTmp = 0;
555  rValue >>= nTmp;
556 
557  bool bUseVirDev = true;
558  bool bHiResVirDev = true;
559  if( nTmp == document::PrinterIndependentLayout::DISABLED )
560  bUseVirDev = false;
561  else if ( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
562  bHiResVirDev = false;
563  else if ( nTmp != document::PrinterIndependentLayout::HIGH_RESOLUTION )
564  throw IllegalArgumentException();
565 
566  mpDoc->getIDocumentDeviceAccess().setReferenceDeviceType( bUseVirDev, bHiResVirDev );
567  }
568  break;
569  case HANDLE_IS_LABEL_DOC :
570  {
571  bool bSet = false;
572  if(!(rValue >>= bSet))
573  throw IllegalArgumentException();
575  }
576  break;
578  {
579  bool bTmp = *o3tl::doAccess<bool>(rValue);
581  }
582  break;
584  {
585  bool bTmp = *o3tl::doAccess<bool>(rValue);
587  }
588  break;
590  {
591  bool bTmp = *o3tl::doAccess<bool>(rValue);
593  }
594  break;
596  {
597  bool bTmp = *o3tl::doAccess<bool>(rValue);
599  }
600  break;
602  {
603  // ignore - this is a dead property
604  }
605  break;
607  {
608  bool bState = false;
609  if (!(rValue >>= bState))
610  throw IllegalArgumentException();
612  }
613  break;
615  {
616  bool bTmp = *o3tl::doAccess<bool>(rValue);
618  }
619  break;
621  {
622  bool bTmp = *o3tl::doAccess<bool>(rValue);
624  }
625  break;
627  {
628  bool bTmp = *o3tl::doAccess<bool>(rValue);
630  }
631  break;
633  {
634  bool bTmp = *o3tl::doAccess<bool>(rValue);
636  }
637  break;
639  {
640  Sequence <sal_Int8> aNew;
641  if(rValue >>= aNew)
642  {
644  if(aNew.hasElements())
645  {
647  eMode |= RedlineFlags::On;
649  }
650  }
651  }
652  break;
654  {
655  bool bTmp = *o3tl::doAccess<bool>(rValue);
657  }
658  break;
660  {
661  bool bTmp = *o3tl::doAccess<bool>(rValue);
663  }
664  break;
666  {
667  bool bTmp = *o3tl::doAccess<bool>(rValue);
669  }
670  break;
672  {
673  bool bTmp = *o3tl::doAccess<bool>(rValue);
675  }
676  break;
678  {
679  bool bTmp = *o3tl::doAccess<bool>(rValue);
681  }
682  break;
684  {
685  bool bTmp = *o3tl::doAccess<bool>(rValue);
687  }
688  break;
690  {
691  mpDocSh->SetLoadReadonly( *o3tl::doAccess<bool>(rValue) );
692  }
693  break;
695  {
696  bool bTmp = *o3tl::doAccess<bool>(rValue);
698  }
699  break;
701  {
702  bool bTmp = *o3tl::doAccess<bool>(rValue);
704  }
705  break;
707  {
708  bool bTmp = *o3tl::doAccess<bool>(rValue);
710  }
711  break;
713  // ignore - this is a dead property
714  break;
716  {
717  bool bTmp = *o3tl::doAccess<bool>(rValue);
719  }
720  break;
721  case HANDLE_RSID:
722  {
723  sal_uInt32 nTmp = 0;
724  rValue >>= nTmp;
725  mpDoc->setRsid( nTmp );
726  }
727  break;
728  case HANDLE_RSID_ROOT:
729  {
730  sal_uInt32 nTmp = 0;
731  rValue >>= nTmp;
732  mpDoc->setRsidRoot( nTmp );
733  }
734  break;
735  case HANDLE_PROTECT_FORM:
736  {
737  bool bTmp = *o3tl::doAccess<bool>(rValue);
739  }
740  break;
742  {
743  bool bTmp = *o3tl::doAccess<bool>(rValue);
745  }
746  break;
748  {
749  bool bTmp = *o3tl::doAccess<bool>(rValue);
751  }
752  break;
754  {
755  uno::Sequence< beans::PropertyValue > aInfo;
756  if ( !( rValue >>= aInfo ) )
757  throw lang::IllegalArgumentException(
758  "Value of type Sequence<PropertyValue> expected!",
759  uno::Reference< uno::XInterface >(),
760  2 );
761 
762  if ( !mpDocSh->SetModifyPasswordInfo( aInfo ) )
763  throw beans::PropertyVetoException(
764  "The hash is not allowed to be changed now!",
765  uno::Reference< uno::XInterface >() );
766  }
767  break;
769  {
770  bool bTmp = *o3tl::doAccess<bool>(rValue);
772  }
773  break;
775  {
776  bool bTmp = *o3tl::doAccess<bool>(rValue);
778  }
779  break;
781  {
782  bool bTmp = *o3tl::doAccess<bool>(rValue);
784  }
785  break;
787  {
788  bool bTmp = *o3tl::doAccess<bool>(rValue);
790  }
791  break;
792  case HANDLE_TAB_OVERFLOW:
793  {
794  bool bTmp = *o3tl::doAccess<bool>(rValue);
796  }
797  break;
799  {
800  bool bTmp = *o3tl::doAccess<bool>(rValue);
802  }
803  break;
805  {
806  bool bTmp = *o3tl::doAccess<bool>(rValue);
808  }
809  break;
811  {
812  bool bTmp = *o3tl::doAccess<bool>(rValue);
814  }
815  break;
817  {
818  bool bTmp = *o3tl::doAccess<bool>(rValue);
820  }
821  break;
823  {
824  bool bTmp = *o3tl::doAccess<bool>(rValue);
826  }
827  break;
828  case HANDLE_EMBED_FONTS:
829  {
830  bool bTmp = *o3tl::doAccess<bool>(rValue);
832  }
833  break;
835  {
836  bool bTmp = *o3tl::doAccess<bool>(rValue);
838  }
839  break;
841  {
842  bool bTmp = *o3tl::doAccess<bool>(rValue);
844  }
845  break;
847  {
848  bool bTmp = *o3tl::doAccess<bool>(rValue);
850  }
851  break;
853  {
854  bool bTmp = *o3tl::doAccess<bool>(rValue);
856  }
857  break;
859  {
860  bool bTmp = *o3tl::doAccess<bool>(rValue);
862  }
863  break;
865  {
866  bool bTmp = *o3tl::doAccess<bool>(rValue);
868  }
869  break;
871  {
872  bool bTmp = *o3tl::doAccess<bool>(rValue);
874  }
875  break;
877  {
878  bool bTmp = *o3tl::doAccess<bool>(rValue);
880  }
881  break;
883  {
884  bool bTmp = *o3tl::doAccess<bool>(rValue);
886  }
887  break;
889  {
890  bool bTmp;
891  if (rValue >>= bTmp)
892  {
895  }
896  }
897  break;
899  {
900  bool bTmp;
901  if (rValue >>= bTmp)
902  {
905  }
906  }
907  break;
909  {
910  bool bTmp;
911  if (rValue >>= bTmp)
912  {
915  }
916  }
917  break;
919  {
920  bool bTmp;
921  if (rValue >>= bTmp)
922  {
924  bTmp);
925  }
926  }
927  break;
928  default:
929  throw UnknownPropertyException();
930  }
931 }
932 
934 {
935  // set printer only once, namely here!
936  if( mpPrinter != nullptr )
937  {
938  // #i86352# the printer is also used as container for options by sfx
939  // when setting a printer it should have decent default options
940  SfxItemSet aOptions( mpPrinter->GetOptions() );
942  SwAddPrinterItem aAddPrinterItem (aPrtData);
943  aOptions.Put(aAddPrinterItem);
944  mpPrinter->SetOptions( aOptions );
945  mpPrinter->SetPrinterSettingsPreferred( mbPreferPrinterPapersize );
946 
948  }
949 
950  mpPrinter = nullptr;
951  mpDocSh = nullptr;
952  mpDoc = nullptr;
953 }
954 
956 {
958  if (nullptr == mpDocSh)
959  throw UnknownPropertyException();
960  mpDoc = mpDocSh->GetDoc();
961  if (nullptr == mpDoc)
962  throw UnknownPropertyException();
963 }
964 
966 {
967  switch( rInfo.mnHandle )
968  {
970  {
971  Reference<XForbiddenCharacters> xRet(*mpModel->GetPropertyHelper(), UNO_QUERY);
972  rValue <<= xRet;
973  }
974  break;
976  {
977  rValue <<= static_cast < sal_Int16 > ( mpDoc->getIDocumentSettingAccess().getLinkUpdateMode(true) );
978  }
979  break;
981  {
983  rValue <<= nFlags == AUTOUPD_FIELD_ONLY || nFlags == AUTOUPD_FIELD_AND_CHARTS;
984  }
985  break;
987  {
989  rValue <<= nFlags == AUTOUPD_FIELD_AND_CHARTS;
990  }
991  break;
993  {
995  }
996  break;
998  {
1000  }
1001  break;
1003  {
1005  }
1006  break;
1007  case HANDLE_PRINTER_NAME:
1008  {
1009  SfxPrinter *pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( false );
1010  rValue <<= pPrinter ? pPrinter->GetName() : OUString();
1011  }
1012  break;
1013  case HANDLE_PRINTER_SETUP:
1014  {
1015  SfxPrinter *pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( false );
1016  if (pPrinter)
1017  {
1018  SvMemoryStream aStream;
1019  pPrinter->Store( aStream );
1020  sal_uInt32 nSize = aStream.TellEnd();
1021  aStream.Seek ( STREAM_SEEK_TO_BEGIN );
1022  Sequence < sal_Int8 > aSequence( nSize );
1023  aStream.ReadBytes(aSequence.getArray(), nSize);
1024  rValue <<= aSequence;
1025  }
1026  else
1027  {
1028  Sequence < sal_Int8 > aSequence ( 0 );
1029  rValue <<= aSequence;
1030  }
1031  }
1032  break;
1033  case HANDLE_PRINTER_PAPER:
1034  {
1035  SfxPrinter *pTempPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( false );
1036  rValue <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred();
1037  }
1038  break;
1040  {
1042  }
1043  break;
1045  {
1046  rValue <<= mpDocSh->IsUseUserData();
1047  }
1048  break;
1049  case HANDLE_SAVE_THUMBNAIL:
1050  {
1051  rValue <<= mpDocSh->IsUseThumbnailSave();
1052  }
1053  break;
1055  {
1056  rValue <<= static_cast < sal_Int16 > (mpDoc->getIDocumentSettingAccess().getCharacterCompressionType());
1057  }
1058  break;
1060  {
1062  }
1063  break;
1065  {
1066  const SwDBData& rData = mpDoc->GetDBDesc();
1067  rValue <<= rData.sDataSource;
1068  }
1069  break;
1071  {
1072  const SwDBData& rData = mpDoc->GetDBDesc();
1073  rValue <<= rData.sCommand;
1074  }
1075  break;
1077  {
1078  const SwDBData& rData = mpDoc->GetDBDesc();
1079  rValue <<= rData.nCommandType;
1080  }
1081  break;
1083  {
1084 #if HAVE_FEATURE_DBCONNECTIVITY
1085  rValue <<= mpDoc->GetDBManager()->getEmbeddedName();
1086 #else
1087  rValue = uno::Any();
1088 #endif
1089  }
1090  break;
1092  {
1093  rValue <<= mpDocSh->IsSaveVersionOnClose();
1094  }
1095  break;
1097  {
1098  rValue <<= mpDocSh->IsQueryLoadTemplate();
1099  }
1100  break;
1102  {
1103  // returns short (see css.document.PrinterIndependentLayout)
1106  document::PrinterIndependentLayout::HIGH_RESOLUTION :
1107  document::PrinterIndependentLayout::LOW_RESOLUTION ) :
1108  document::PrinterIndependentLayout::DISABLED;
1109  rValue <<= nVirDevType;
1110  }
1111  break;
1112  case HANDLE_IS_LABEL_DOC:
1113  {
1115  rValue <<= bLabel;
1116  }
1117  break;
1119  {
1121  }
1122  break;
1124  {
1126  }
1127  break;
1129  {
1131  }
1132  break;
1133  case HANDLE_OLD_NUMBERING:
1134  {
1136  }
1137  break;
1139  {
1140  rValue <<= false;
1141  }
1142  break;
1144  {
1145  rValue <<= mpDocSh->Stamp_GetPrintCancelState();
1146  }
1147  break;
1149  {
1151  }
1152  break;
1154  {
1156  }
1157  break;
1159  {
1161  }
1162  break;
1164  {
1166  }
1167  break;
1169  {
1171  }
1172  break;
1174  {
1176  }
1177  break;
1179  {
1181  }
1182  break;
1184  {
1186  }
1187  break;
1189  {
1191  }
1192  break;
1193  case HANDLE_TABLE_ROW_KEEP :
1194  {
1196  }
1197  break;
1199  {
1201  }
1202  break;
1203  case HANDLE_LOAD_READONLY:
1204  {
1205  rValue <<= mpDocSh->IsLoadReadonly();
1206  }
1207  break;
1209  {
1211  }
1212  break;
1214  {
1216  }
1217  break;
1219  {
1221  }
1222  break;
1224  {
1225  rValue <<= false;
1226  }
1227  break;
1229  {
1231  }
1232  break;
1233  case HANDLE_RSID:
1234  {
1235  rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsid() );
1236  }
1237  break;
1238  case HANDLE_RSID_ROOT:
1239  {
1240  rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsidRoot() );
1241  }
1242  break;
1243  case HANDLE_PROTECT_FORM:
1244  {
1246  }
1247  break;
1249  {
1251  }
1252  break;
1254  {
1256  }
1257  break;
1259  {
1260  rValue <<= mpDocSh->GetModifyPasswordInfo();
1261  }
1262  break;
1264  {
1266  }
1267  break;
1269  {
1271  }
1272  break;
1274  {
1276  }
1277  break;
1279  {
1281  }
1282  break;
1283  case HANDLE_TAB_OVERFLOW:
1284  {
1286  }
1287  break;
1289  {
1291  }
1292  break;
1294  {
1296  }
1297  break;
1299  {
1301  }
1302  break;
1304  {
1306  }
1307  break;
1309  {
1311  }
1312  break;
1313  case HANDLE_EMBED_FONTS:
1314  {
1316  }
1317  break;
1319  {
1321  }
1322  break;
1324  {
1326  }
1327  break;
1329  {
1331  }
1332  break;
1334  {
1336  }
1337  break;
1339  {
1341  }
1342  break;
1344  {
1346  }
1347  break;
1349  {
1351  }
1352  break;
1354  {
1356  }
1357  break;
1359  {
1361  }
1362  break;
1364  {
1366  }
1367  break;
1368  case HANDLE_SUBTRACT_FLYS:
1369  {
1371  }
1372  break;
1374  {
1376  }
1377  break;
1379  {
1380  rValue <<= mpDoc->getIDocumentSettingAccess().get(
1382  }
1383  break;
1384  default:
1385  throw UnknownPropertyException();
1386  }
1387 }
1388 
1390 {
1391  mpDocSh = nullptr;
1392  mpDoc = nullptr;
1393 }
1394 
1395 // XServiceInfo
1397 {
1398  return OUString("SwXDocumentSettings");
1399 }
1400 
1401 sal_Bool SAL_CALL SwXDocumentSettings::supportsService( const OUString& ServiceName )
1402 {
1403  return cppu::supportsService(this, ServiceName);
1404 }
1405 
1407 {
1408  Sequence< OUString > aSeq( 3 );
1409  aSeq[0] = "com.sun.star.document.Settings";
1410  aSeq[1] = "com.sun.star.text.DocumentSettings";
1411  aSeq[2] = "com.sun.star.text.PrintSettings";
1412  return aSeq;
1413 }
1414 
1415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Type
virtual void _postSetValues() override
virtual void SAL_CALL release() override
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
void ChgDBData(const SwDBData &rNewData)
Definition: doc.cxx:485
bool IsUseUserData() const
SwFieldUpdateFlags
Definition: fldupde.hxx:22
virtual OUString SAL_CALL getImplementationName() override
virtual const css::uno::Sequence< sal_Int8 > & GetRedlinePassword() const =0
static MasterPropertySetInfo * lcl_createSettingsInfo()
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:270
sal_uInt32 getRsidRoot() const
Definition: doc.cxx:248
OUString sDataSource
Definition: swdbdata.hxx:30
void disposeAndClear()
virtual void setReferenceDeviceType(bool bNewVirtual, bool bNewHiRes)=0
Sets the type of the reference device used for formatting the document.
SwXDocumentPropertyHelper * GetPropertyHelper()
Definition: unotxdoc.cxx:464
virtual void setFieldUpdateFlags(SwFieldUpdateFlags nMode)=0
Set the current field update mode.
sal_uInt64 Seek(sal_uInt64 nPos)
#define FN_PARAM_ADDPRINTER
Definition: cmdid.h:735
virtual sal_uInt64 TellEnd() override
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
virtual void SAL_CALL acquire() override
sal_Int16 const mnAttributes
virtual void setCharacterCompressionType(CharCompressType nType)=0
Set the character compression type for Asian characters.
virtual void _preGetValues() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void setEmbeddedName(const OUString &rEmbeddedName, SwDocShell &rDocShell)
Definition: dbmgr.cxx:3246
sal_uInt32 getRsid() const
Definition: doc.cxx:228
virtual SwFieldUpdateFlags getFieldUpdateFlags(bool bGlobalSettings) const =0
Get the current field update mode.
SwXDocumentSettings(SwXTextDocument *pModel)
RedlineFlags on.
SfxObjectCreateMode GetCreateMode() const
const SwDBData & GetDBDesc()
Definition: docfld.cxx:359
SwDocumentSettingsPropertyHandles
void registerSlave(ChainablePropertySet *pNewSet)
virtual CharCompressType getCharacterCompressionType() const =0
Get the character compression type for Asian characters.
const SfxItemSet & GetOptions() const
void ChgHyphenation()
Definition: viewsh.hxx:211
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:202
SwDBData const & GetDBData()
Definition: docfld.cxx:354
virtual const SwPrintData & getPrintData() const =0
Returns the PrintData.
#define STREAM_SEEK_TO_BEGIN
virtual ~SwXDocumentSettings() override
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:323
bool Stamp_GetPrintCancelState() const
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual sal_uInt16 getLinkUpdateMode(bool bGlobalSettings) const =0
Get the current link update mode.
const css::uno::Sequence< css::beans::PropertyValue > & GetModifyPasswordInfo() const
static VclPtr< SfxPrinter > Create(SvStream &rStream, std::unique_ptr< SfxItemSet > &&pOptions)
virtual void _getSingleValue(const comphelper::PropertyInfo &rInfo, css::uno::Any &rValue) override
void SetSaveVersionOnClose(bool bSet)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
unsigned char sal_Bool
void setRsidRoot(sal_uInt32 nVal)
Definition: doc.cxx:253
SwDocShell * GetDocShell()
Definition: unotxdoc.hxx:464
virtual void _setSingleValue(const comphelper::PropertyInfo &rInfo, const css::uno::Any &rValue) override
css::uno::Type const & get()
void SetUseThumbnailSave(bool _bNew)
SwXTextDocument * mpModel
GUIDCNamePair const aData
void SetUseUserData(bool bNew)
void Store(SvStream &rStream) const
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
virtual void setPrinter(SfxPrinter *pP, bool bDeleteOld, bool bCallPrtDataChanged)=0
Set the printer at the document.
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
std::size_t ReadBytes(void *pData, std::size_t nSize)
void setRsid(sal_uInt32 nVal)
Definition: doc.cxx:233
virtual void _postGetValues() override
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:367
AUTOMATIC
bool IsUseThumbnailSave() const
#define SAL_WARN_IF(condition, area, stream)
bool IsQueryLoadTemplate() const
bool IsSaveVersionOnClose() const
virtual std::unique_ptr< SfxItemSet > Clone(bool bItems=true, SfxItemPool *pToPool=nullptr) const
virtual void SetRedlineFlags(RedlineFlags eMode)=0
Set a new redline mode.
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:208
bool SetModifyPasswordInfo(const css::uno::Sequence< css::beans::PropertyValue > &aInfo)
virtual void setLinkUpdateMode(sal_uInt16 nMode)=0
Set the current link update mode.
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
void SetLoadReadonly(bool _bReadonly)
void SetQueryLoadTemplate(bool b)
bool IsLoadReadonly() const
void Stamp_SetPrintCancelState(bool bState)
virtual void SetRedlinePassword(const css::uno::Sequence< sal_Int8 > &rNewPassword)=0
VclPtr< SfxPrinter > mpPrinter
the printer should be set only once; since there are several printer-related properties, remember the last printer and set it in _postSetValues
OUString sCommand
Definition: swdbdata.hxx:31
sal_Int32 const mnHandle
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
SwDBManager * GetDBManager() const
Definition: doc.hxx:664
void SetOptions(const SfxItemSet &rNewOptions)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1307
virtual void _preSetValues() override
const OUString & getEmbeddedName() const
Definition: dbmgr.cxx:3267