File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 192, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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> | |||
28 | #include "SwXDocumentSettings.hxx" | |||
29 | #include <comphelper/MasterPropertySetInfo.hxx> | |||
30 | #include <cppuhelper/queryinterface.hxx> | |||
31 | #include <cppuhelper/supportsservice.hxx> | |||
32 | #include <com/sun/star/beans/PropertyAttribute.hpp> | |||
33 | #include <com/sun/star/i18n/XForbiddenCharacters.hpp> | |||
34 | #include <com/sun/star/document/PrinterIndependentLayout.hpp> | |||
35 | #include <doc.hxx> | |||
36 | #include <IDocumentSettingAccess.hxx> | |||
37 | #include <IDocumentDeviceAccess.hxx> | |||
38 | #include <IDocumentRedlineAccess.hxx> | |||
39 | #include <docsh.hxx> | |||
40 | #include <fldupde.hxx> | |||
41 | #include <linkenum.hxx> | |||
42 | #include <sfx2/printer.hxx> | |||
43 | #include <editsh.hxx> | |||
44 | #include <unotxdoc.hxx> | |||
45 | #include <cmdid.h> | |||
46 | #include <unomod.hxx> | |||
47 | #include <vcl/svapp.hxx> | |||
48 | #include <svl/asiancfg.hxx> | |||
49 | #include <tools/stream.hxx> | |||
50 | ||||
51 | #include <cfgitems.hxx> | |||
52 | #include <dbmgr.hxx> | |||
53 | ||||
54 | using namespace comphelper; | |||
55 | using namespace ::com::sun::star; | |||
56 | using namespace ::com::sun::star::uno; | |||
57 | using namespace ::com::sun::star::beans; | |||
58 | using namespace ::com::sun::star::lang; | |||
59 | using namespace ::com::sun::star::i18n; | |||
60 | ||||
61 | namespace { | |||
62 | ||||
63 | enum SwDocumentSettingsPropertyHandles | |||
64 | { | |||
65 | HANDLE_FORBIDDEN_CHARS, | |||
66 | HANDLE_LINK_UPDATE_MODE, | |||
67 | HANDLE_FIELD_AUTO_UPDATE, | |||
68 | HANDLE_CHART_AUTO_UPDATE, | |||
69 | HANDLE_ADD_PARA_TABLE_SPACING, | |||
70 | HANDLE_ADD_PARA_TABLE_SPACING_AT_START, | |||
71 | HANDLE_ALIGN_TAB_STOP_POSITION, | |||
72 | HANDLE_PRINTER_NAME, | |||
73 | HANDLE_PRINTER_SETUP, | |||
74 | HANDLE_PRINTER_PAPER, | |||
75 | HANDLE_IS_KERN_ASIAN_PUNCTUATION, | |||
76 | HANDLE_CHARACTER_COMPRESSION_TYPE, | |||
77 | HANDLE_APPLY_USER_DATA, | |||
78 | HANDLE_SAVE_THUMBNAIL, | |||
79 | HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, | |||
80 | HANDLE_CURRENT_DATABASE_DATA_SOURCE, | |||
81 | HANDLE_CURRENT_DATABASE_COMMAND, | |||
82 | HANDLE_CURRENT_DATABASE_COMMAND_TYPE, | |||
83 | HANDLE_EMBEDDED_DATABASE_NAME, | |||
84 | HANDLE_SAVE_VERSION_ON_CLOSE, | |||
85 | HANDLE_UPDATE_FROM_TEMPLATE, | |||
86 | HANDLE_PRINTER_INDEPENDENT_LAYOUT, | |||
87 | HANDLE_IS_LABEL_DOC, | |||
88 | HANDLE_IS_ADD_FLY_OFFSET, | |||
89 | HANDLE_IS_ADD_VERTICAL_FLY_OFFSET, | |||
90 | HANDLE_IS_ADD_EXTERNAL_LEADING, | |||
91 | HANDLE_OLD_NUMBERING, | |||
92 | HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, | |||
93 | /* Stampit It disable the print cancel button of the shown progress dialog. */ | |||
94 | HANDLE_ALLOW_PRINTJOB_CANCEL, | |||
95 | HANDLE_USE_FORMER_LINE_SPACING, | |||
96 | HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, | |||
97 | HANDLE_ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, | |||
98 | HANDLE_USE_FORMER_OBJECT_POSITIONING, | |||
99 | HANDLE_USE_FORMER_TEXT_WRAPPING, | |||
100 | HANDLE_CHANGES_PASSWORD, | |||
101 | HANDLE_CONSIDER_WRAP_ON_OBJPOS, | |||
102 | HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, | |||
103 | HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, | |||
104 | HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, | |||
105 | HANDLE_TABLE_ROW_KEEP, | |||
106 | HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, | |||
107 | HANDLE_LOAD_READONLY, | |||
108 | HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, | |||
109 | HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, | |||
110 | HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, | |||
111 | HANDLE_USE_OLD_PRINTER_METRICS, | |||
112 | HANDLE_PROTECT_FORM, | |||
113 | HANDLE_MS_WORD_COMP_TRAILING_BLANKS, | |||
114 | HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY, | |||
115 | HANDLE_TABS_RELATIVE_TO_INDENT, | |||
116 | HANDLE_RSID, | |||
117 | HANDLE_RSID_ROOT, | |||
118 | HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, | |||
119 | HANDLE_MODIFYPASSWORDINFO, | |||
120 | HANDLE_MATH_BASELINE_ALIGNMENT, | |||
121 | HANDLE_INVERT_BORDER_SPACING, | |||
122 | HANDLE_COLLAPSE_EMPTY_CELL_PARA, | |||
123 | HANDLE_SMALL_CAPS_PERCENTAGE_66, | |||
124 | HANDLE_TAB_OVERFLOW, | |||
125 | HANDLE_UNBREAKABLE_NUMBERINGS, | |||
126 | HANDLE_STYLES_NODEFAULT, | |||
127 | HANDLE_FLOATTABLE_NOMARGINS, | |||
128 | HANDLE_CLIPPED_PICTURES, | |||
129 | HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, | |||
130 | HANDLE_EMBED_FONTS, | |||
131 | HANDLE_EMBED_USED_FONTS, | |||
132 | HANDLE_EMBED_LATIN_SCRIPT_FONTS, | |||
133 | HANDLE_EMBED_ASIAN_SCRIPT_FONTS, | |||
134 | HANDLE_EMBED_COMPLEX_SCRIPT_FONTS, | |||
135 | HANDLE_EMBED_SYSTEM_FONTS, | |||
136 | HANDLE_TAB_OVER_MARGIN, | |||
137 | HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, | |||
138 | HANDLE_SURROUND_TEXT_WRAP_SMALL, | |||
139 | HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, | |||
140 | HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, | |||
141 | HANDLE_SUBTRACT_FLYS, | |||
142 | HANDLE_DISABLE_OFF_PAGE_POSITIONING, | |||
143 | HANDLE_EMPTY_DB_FIELD_HIDES_PARA, | |||
144 | HANDLE_CONTINUOUS_ENDNOTES, | |||
145 | HANDLE_PROTECT_BOOKMARKS, | |||
146 | HANDLE_PROTECT_FIELDS, | |||
147 | HANDLE_HEADER_SPACING_BELOW_LAST_PARA, | |||
148 | HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA, | |||
149 | }; | |||
150 | ||||
151 | } | |||
152 | ||||
153 | static MasterPropertySetInfo * lcl_createSettingsInfo() | |||
154 | { | |||
155 | static PropertyInfo const aWriterSettingsInfoMap[] = | |||
156 | { | |||
157 | { OUString("ForbiddenCharacters"), HANDLE_FORBIDDEN_CHARS, cppu::UnoType<css::i18n::XForbiddenCharacters>::get(), 0}, | |||
158 | { OUString("LinkUpdateMode"), HANDLE_LINK_UPDATE_MODE, cppu::UnoType<sal_Int16>::get(), 0}, | |||
159 | { OUString("FieldAutoUpdate"), HANDLE_FIELD_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0}, | |||
160 | { OUString("ChartAutoUpdate"), HANDLE_CHART_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0}, | |||
161 | { OUString("AddParaTableSpacing"), HANDLE_ADD_PARA_TABLE_SPACING, cppu::UnoType<bool>::get(), 0}, | |||
162 | { OUString("AddParaTableSpacingAtStart"), HANDLE_ADD_PARA_TABLE_SPACING_AT_START, cppu::UnoType<bool>::get(), 0}, | |||
163 | { OUString("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, cppu::UnoType<bool>::get(), 0}, | |||
164 | { OUString("PrinterName"), HANDLE_PRINTER_NAME, cppu::UnoType<OUString>::get(), 0}, | |||
165 | { OUString("PrinterSetup"), HANDLE_PRINTER_SETUP, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0}, | |||
166 | { OUString("PrinterPaperFromSetup"), HANDLE_PRINTER_PAPER, cppu::UnoType<bool>::get(), 0}, | |||
167 | { OUString("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, cppu::UnoType<bool>::get(), 0}, | |||
168 | { OUString("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, cppu::UnoType<sal_Int16>::get(), 0}, | |||
169 | { OUString("ApplyUserData"), HANDLE_APPLY_USER_DATA, cppu::UnoType<bool>::get(), 0 }, | |||
170 | { OUString("SaveThumbnail"), HANDLE_SAVE_THUMBNAIL, cppu::UnoType<bool>::get(), 0 }, | |||
171 | { OUString("SaveGlobalDocumentLinks"), HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, cppu::UnoType<bool>::get(), 0}, | |||
172 | { OUString("CurrentDatabaseDataSource"), HANDLE_CURRENT_DATABASE_DATA_SOURCE, cppu::UnoType<OUString>::get(), 0}, | |||
173 | { OUString("CurrentDatabaseCommand"), HANDLE_CURRENT_DATABASE_COMMAND, cppu::UnoType<OUString>::get(), 0}, | |||
174 | { OUString("CurrentDatabaseCommandType"), HANDLE_CURRENT_DATABASE_COMMAND_TYPE, cppu::UnoType<sal_Int32>::get(), 0}, | |||
175 | { OUString("EmbeddedDatabaseName"), HANDLE_EMBEDDED_DATABASE_NAME, cppu::UnoType<OUString>::get(), 0}, | |||
176 | { OUString("SaveVersionOnClose"), HANDLE_SAVE_VERSION_ON_CLOSE, cppu::UnoType<bool>::get(), 0}, | |||
177 | { OUString("UpdateFromTemplate"), HANDLE_UPDATE_FROM_TEMPLATE, cppu::UnoType<bool>::get(), 0}, | |||
178 | ||||
179 | { OUString("PrinterIndependentLayout"), HANDLE_PRINTER_INDEPENDENT_LAYOUT, cppu::UnoType<sal_Int16>::get(), 0}, | |||
180 | { OUString("IsLabelDocument"), HANDLE_IS_LABEL_DOC, cppu::UnoType<bool>::get(), 0}, | |||
181 | { OUString("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, cppu::UnoType<bool>::get(), 0}, | |||
182 | { OUString("AddVerticalFrameOffsets"), HANDLE_IS_ADD_VERTICAL_FLY_OFFSET, cppu::UnoType<bool>::get(), 0}, | |||
183 | { OUString("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, cppu::UnoType<bool>::get(), 0}, | |||
184 | { OUString("UseOldNumbering"), HANDLE_OLD_NUMBERING, cppu::UnoType<bool>::get(), 0}, | |||
185 | { OUString("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, cppu::UnoType<bool>::get(), 0}, | |||
186 | /* Stampit It disable the print cancel button of the shown progress dialog. */ | |||
187 | { OUString("AllowPrintJobCancel"), HANDLE_ALLOW_PRINTJOB_CANCEL, cppu::UnoType<bool>::get(), 0}, | |||
188 | { OUString("UseFormerLineSpacing"), HANDLE_USE_FORMER_LINE_SPACING, cppu::UnoType<bool>::get(), 0}, | |||
189 | { OUString("AddParaSpacingToTableCells"), HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, cppu::UnoType<bool>::get(), 0}, | |||
190 | { OUString("AddParaLineSpacingToTableCells"), HANDLE_ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, cppu::UnoType<bool>::get(), 0}, | |||
191 | { OUString("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, cppu::UnoType<bool>::get(), 0}, | |||
192 | { OUString("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, cppu::UnoType<bool>::get(), 0}, | |||
193 | { OUString("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0}, | |||
194 | { OUString("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, cppu::UnoType<bool>::get(), 0}, | |||
195 | { OUString("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, cppu::UnoType<bool>::get(), 0}, | |||
196 | { OUString("DoNotJustifyLinesWithManualBreak"), HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, cppu::UnoType<bool>::get(), 0}, | |||
197 | { OUString("DoNotResetParaAttrsForNumFont"), HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, cppu::UnoType<bool>::get(), 0}, | |||
198 | { OUString("TableRowKeep"), HANDLE_TABLE_ROW_KEEP, cppu::UnoType<bool>::get(), 0}, | |||
199 | { OUString("IgnoreTabsAndBlanksForLineCalculation"), HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, cppu::UnoType<bool>::get(), 0}, | |||
200 | { OUString("LoadReadonly"), HANDLE_LOAD_READONLY, cppu::UnoType<bool>::get(), 0}, | |||
201 | { OUString("DoNotCaptureDrawObjsOnPage"), HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, cppu::UnoType<bool>::get(), 0}, | |||
202 | { OUString("ClipAsCharacterAnchoredWriterFlyFrames"), HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, cppu::UnoType<bool>::get(), 0}, | |||
203 | { OUString("UnxForceZeroExtLeading"), HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, cppu::UnoType<bool>::get(), 0}, | |||
204 | { OUString("UseOldPrinterMetrics"), HANDLE_USE_OLD_PRINTER_METRICS, cppu::UnoType<bool>::get(), 0}, | |||
205 | { OUString("TabsRelativeToIndent"), HANDLE_TABS_RELATIVE_TO_INDENT, cppu::UnoType<bool>::get(), 0}, | |||
206 | { OUString("Rsid"), HANDLE_RSID, cppu::UnoType<sal_Int32>::get(), 0}, | |||
207 | { OUString("RsidRoot"), HANDLE_RSID_ROOT, cppu::UnoType<sal_Int32>::get(), 0}, | |||
208 | { OUString("ProtectForm"), HANDLE_PROTECT_FORM, cppu::UnoType<bool>::get(), 0}, | |||
209 | { OUString("MsWordCompTrailingBlanks"), HANDLE_MS_WORD_COMP_TRAILING_BLANKS, cppu::UnoType<bool>::get(), 0 }, | |||
210 | { OUString("MsWordCompMinLineHeightByFly"), HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY, cppu::UnoType<bool>::get(), 0 }, | |||
211 | { OUString("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, cppu::UnoType<bool>::get(), 0}, | |||
212 | { OUString("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), 0}, | |||
213 | { OUString("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, cppu::UnoType<bool>::get(), 0}, | |||
214 | { OUString("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, cppu::UnoType<bool>::get(), 0}, | |||
215 | { OUString("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, cppu::UnoType<bool>::get(), 0}, | |||
216 | { OUString("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, cppu::UnoType<bool>::get(), 0}, | |||
217 | { OUString("TabOverflow"), HANDLE_TAB_OVERFLOW, cppu::UnoType<bool>::get(), 0}, | |||
218 | { OUString("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, cppu::UnoType<bool>::get(), 0}, | |||
219 | { OUString("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, cppu::UnoType<bool>::get(), 0}, | |||
220 | { OUString("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, cppu::UnoType<bool>::get(), 0}, | |||
221 | { OUString("ClippedPictures"), HANDLE_CLIPPED_PICTURES, cppu::UnoType<bool>::get(), 0}, | |||
222 | { OUString("BackgroundParaOverDrawings"), HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, cppu::UnoType<bool>::get(), 0}, | |||
223 | { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType<bool>::get(), 0}, | |||
224 | { OUString("EmbedOnlyUsedFonts"), HANDLE_EMBED_USED_FONTS, cppu::UnoType<bool>::get(), 0}, | |||
225 | { OUString("EmbedLatinScriptFonts"), HANDLE_EMBED_LATIN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0}, | |||
226 | { OUString("EmbedAsianScriptFonts"), HANDLE_EMBED_ASIAN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0}, | |||
227 | { OUString("EmbedComplexScriptFonts"), HANDLE_EMBED_COMPLEX_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0}, | |||
228 | { OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType<bool>::get(), 0}, | |||
229 | { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0}, | |||
230 | { OUString("TreatSingleColumnBreakAsPageBreak"), HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, cppu::UnoType<bool>::get(), 0}, | |||
231 | { OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 0}, | |||
232 | { OUString("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, cppu::UnoType<bool>::get(), 0}, | |||
233 | { OUString("PropLineSpacingShrinksFirstLine"), HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, cppu::UnoType<bool>::get(), 0}, | |||
234 | { OUString("SubtractFlysAnchoredAtFlys"), HANDLE_SUBTRACT_FLYS, cppu::UnoType<bool>::get(), 0}, | |||
235 | { OUString("DisableOffPagePositioning"), HANDLE_DISABLE_OFF_PAGE_POSITIONING, cppu::UnoType<bool>::get(), 0}, | |||
236 | { OUString("EmptyDbFieldHidesPara"), HANDLE_EMPTY_DB_FIELD_HIDES_PARA, cppu::UnoType<bool>::get(), 0 }, | |||
237 | { OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType<bool>::get(), 0 }, | |||
238 | { OUString("ProtectBookmarks"), HANDLE_PROTECT_BOOKMARKS, cppu::UnoType<bool>::get(), 0 }, | |||
239 | { OUString("ProtectFields"), HANDLE_PROTECT_FIELDS, cppu::UnoType<bool>::get(), 0 }, | |||
240 | { OUString("HeaderSpacingBelowLastPara"), HANDLE_HEADER_SPACING_BELOW_LAST_PARA, cppu::UnoType<bool>::get(), 0 }, | |||
241 | { OUString("FrameAutowidthWithMorePara"), HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA, cppu::UnoType<bool>::get(), 0 }, | |||
242 | ||||
243 | /* | |||
244 | * As OS said, we don't have a view when we need to set this, so I have to | |||
245 | * find another solution before adding them to this property set - MTG | |||
246 | { OUString("IsGridVisible"), HANDLE_IS_GRID_VISIBLE, cppu::UnoType<bool>::get(), 0, 0}, | |||
247 | { OUString("IsSnapToGrid"), HANDLE_IS_SNAP_TO_GRID, cppu::UnoType<bool>::get(), 0, 0}, | |||
248 | { OUString("IsSynchroniseAxes"), HANDLE_IS_SYNCHRONISE_AXES, cppu::UnoType<bool>::get(), 0, 0}, | |||
249 | { OUString("HorizontalGridResolution"), HANDLE_HORIZONTAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0}, | |||
250 | { OUString("HorizontalGridSubdivision"), HANDLE_HORIZONTAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0}, | |||
251 | { OUString("VerticalGridResolution"), HANDLE_VERTICAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0}, | |||
252 | { OUString("VerticalGridSubdivision"), HANDLE_VERTICAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0}, | |||
253 | ||||
254 | { OUString("ShowParagraphEnd"), HANDLE_SHOW_PARAGRAPH_END, cppu::UnoType<bool>::get(), 0, 0}, | |||
255 | { OUString("ShowOptionalHyphens"), HANDLE_SHOW_OPTIONAL_HYPHENS, cppu::UnoType<bool>::get(), 0, 0}, | |||
256 | { OUString("ShowSpaces"), HANDLE_SHOW_SPACES, cppu::UnoType<bool>::get(), 0, 0}, | |||
257 | { OUString("ShowTabs"), HANDLE_SHOW_TABS, cppu::UnoType<bool>::get(), 0, 0}, | |||
258 | { OUString("ShowBreaks"), HANDLE_SHOW_BREAKS, cppu::UnoType<bool>::get(), 0, 0}, | |||
259 | { OUString("ShowHiddenText"), HANDLE_SHOW_HIDDEN_TEXT, cppu::UnoType<bool>::get(), 0, 0}, | |||
260 | { OUString("ShowHiddenParagraphs"), HANDLE_SHOW_HIDDEN_PARAGRAPHS, cppu::UnoType<bool>::get(), 0, 0}, | |||
261 | ||||
262 | { OUString("ShowTextLimitGuide"), HANDLE_SHOW_TEXT_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0}, | |||
263 | { OUString("ShowTableLimitGuide"), HANDLE_SHOW_TABLE_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0}, | |||
264 | { OUString("ShowSectionLimitGuide"), HANDLE_SHOW_SECTION_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0}, | |||
265 | { OUString("ShowGuidesWhileMoving"), HANDLE_SHOW_GUIDES_WHILE_MOVING, cppu::UnoType<bool>::get(), 0, 0}, | |||
266 | */ | |||
267 | { OUString(), 0, css::uno::Type(), 0} | |||
268 | }; | |||
269 | return new MasterPropertySetInfo ( aWriterSettingsInfoMap ); | |||
270 | } | |||
271 | ||||
272 | SwXDocumentSettings::SwXDocumentSettings ( SwXTextDocument * pModel ) | |||
273 | : MasterPropertySet ( lcl_createSettingsInfo (), | |||
274 | &Application::GetSolarMutex () ) | |||
275 | , mpModel ( pModel ) | |||
276 | , mpDocSh ( nullptr ) | |||
277 | , mpDoc ( nullptr ) | |||
278 | , mpPrinter( nullptr ) | |||
279 | , mbPreferPrinterPapersize( false ) | |||
280 | { | |||
281 | registerSlave ( new SwXPrintSettings ( SwXPrintSettingsType::Document, mpModel->GetDocShell()->GetDoc() ) ); | |||
282 | } | |||
283 | ||||
284 | SwXDocumentSettings::~SwXDocumentSettings() | |||
285 | throw() | |||
286 | { | |||
287 | } | |||
288 | ||||
289 | Any SAL_CALL SwXDocumentSettings::queryInterface( const Type& rType ) | |||
290 | { | |||
291 | return ::cppu::queryInterface(rType, | |||
292 | // OWeakObject interfaces | |||
293 | &dynamic_cast<XInterface&>(dynamic_cast<OWeakObject&>(*this)), | |||
294 | &dynamic_cast<XWeak&>(*this), | |||
295 | // my own interfaces | |||
296 | &dynamic_cast<XPropertySet&>(*this), | |||
297 | &dynamic_cast<XPropertyState&>(*this), | |||
298 | &dynamic_cast<XMultiPropertySet&>(*this), | |||
299 | &dynamic_cast<XServiceInfo&>(*this), | |||
300 | &dynamic_cast<XTypeProvider&>(*this)); | |||
301 | } | |||
302 | void SwXDocumentSettings::acquire () | |||
303 | throw () | |||
304 | { | |||
305 | OWeakObject::acquire(); | |||
306 | } | |||
307 | void SwXDocumentSettings::release () | |||
308 | throw () | |||
309 | { | |||
310 | OWeakObject::release(); | |||
311 | } | |||
312 | ||||
313 | uno::Sequence< uno::Type > SAL_CALL SwXDocumentSettings::getTypes( ) | |||
314 | { | |||
315 | static const uno::Sequence< uno::Type > aTypes { | |||
316 | // from MasterPropertySet | |||
317 | cppu::UnoType<XPropertySet>::get(), | |||
318 | cppu::UnoType<XPropertyState>::get(), | |||
319 | cppu::UnoType<XMultiPropertySet>::get(), | |||
320 | cppu::UnoType<XServiceInfo>::get(), | |||
321 | cppu::UnoType<XTypeProvider>::get(), | |||
322 | }; | |||
323 | return aTypes; | |||
324 | } | |||
325 | ||||
326 | uno::Sequence< sal_Int8 > SAL_CALL SwXDocumentSettings::getImplementationId( ) | |||
327 | { | |||
328 | return css::uno::Sequence<sal_Int8>(); | |||
329 | } | |||
330 | ||||
331 | void SwXDocumentSettings::_preSetValues () | |||
332 | { | |||
333 | mpDocSh = mpModel->GetDocShell(); | |||
334 | if (nullptr == mpDocSh) | |||
335 | throw UnknownPropertyException(); | |||
336 | ||||
337 | mpDoc = mpDocSh->GetDoc(); | |||
338 | if (nullptr == mpDoc) | |||
339 | throw UnknownPropertyException(); | |||
340 | } | |||
341 | ||||
342 | void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue ) | |||
343 | { | |||
344 | if (rInfo.mnAttributes & PropertyAttribute::READONLY) | |||
| ||||
345 | throw PropertyVetoException ("Property is read-only: " + rInfo.maName, static_cast < cppu::OWeakObject * > ( nullptr ) ); | |||
346 | ||||
347 | switch( rInfo.mnHandle ) | |||
348 | { | |||
349 | case HANDLE_FORBIDDEN_CHARS: | |||
350 | break; | |||
351 | case HANDLE_LINK_UPDATE_MODE: | |||
352 | { | |||
353 | sal_Int16 nMode = 0; | |||
354 | rValue >>= nMode; | |||
355 | switch (nMode) | |||
356 | { | |||
357 | case NEVER: | |||
358 | case MANUAL: | |||
359 | case AUTOMATIC: | |||
360 | case GLOBALSETTING: | |||
361 | break; | |||
362 | default: | |||
363 | throw IllegalArgumentException(); | |||
364 | } | |||
365 | mpDoc->getIDocumentSettingAccess().setLinkUpdateMode(nMode); | |||
366 | } | |||
367 | break; | |||
368 | case HANDLE_FIELD_AUTO_UPDATE: | |||
369 | { | |||
370 | bool bUpdateField = *o3tl::doAccess<bool>(rValue); | |||
371 | SwFieldUpdateFlags nFlag = mpDoc->getIDocumentSettingAccess().getFieldUpdateFlags(true); | |||
372 | mpDoc->getIDocumentSettingAccess().setFieldUpdateFlags( bUpdateField ? | |||
373 | nFlag == AUTOUPD_FIELD_AND_CHARTS ? | |||
374 | AUTOUPD_FIELD_AND_CHARTS : | |||
375 | AUTOUPD_FIELD_ONLY : | |||
376 | AUTOUPD_OFF ); | |||
377 | } | |||
378 | break; | |||
379 | case HANDLE_CHART_AUTO_UPDATE: | |||
380 | { | |||
381 | bool bUpdateChart = *o3tl::doAccess<bool>(rValue); | |||
382 | SwFieldUpdateFlags nFlag = mpDoc->getIDocumentSettingAccess().getFieldUpdateFlags(true); | |||
383 | mpDoc->getIDocumentSettingAccess().setFieldUpdateFlags( (nFlag == AUTOUPD_FIELD_ONLY || nFlag == AUTOUPD_FIELD_AND_CHARTS ) ? | |||
384 | bUpdateChart ? | |||
385 | AUTOUPD_FIELD_AND_CHARTS : | |||
386 | AUTOUPD_FIELD_ONLY : | |||
387 | AUTOUPD_OFF ); | |||
388 | } | |||
389 | break; | |||
390 | case HANDLE_ADD_PARA_TABLE_SPACING: | |||
391 | { | |||
392 | bool bParaSpace = false; | |||
393 | rValue >>= bParaSpace; | |||
394 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PARA_SPACE_MAX, bParaSpace ); | |||
395 | } | |||
396 | break; | |||
397 | case HANDLE_ADD_PARA_TABLE_SPACING_AT_START: | |||
398 | { | |||
399 | bool bParaSpacePage = false; | |||
400 | rValue >>= bParaSpacePage; | |||
401 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PARA_SPACE_MAX_AT_PAGES, bParaSpacePage ); | |||
402 | } | |||
403 | break; | |||
404 | case HANDLE_ALIGN_TAB_STOP_POSITION: | |||
405 | { | |||
406 | bool bAlignTab = *o3tl::doAccess<bool>(rValue); | |||
407 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TAB_COMPAT, bAlignTab); | |||
408 | } | |||
409 | break; | |||
410 | case HANDLE_PRINTER_NAME: | |||
411 | { | |||
412 | //the printer must be created | |||
413 | OUString sPrinterName; | |||
414 | if( !(rValue >>= sPrinterName) ) | |||
415 | throw IllegalArgumentException(); | |||
416 | ||||
417 | if( !mpPrinter && !sPrinterName.isEmpty() && mpDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) | |||
418 | { | |||
419 | SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true ); | |||
420 | if ( pPrinter->GetName() != sPrinterName ) | |||
421 | { | |||
422 | VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName ); | |||
423 | assert (! pNewPrinter->isDisposed() )(static_cast <bool> (! pNewPrinter->isDisposed()) ? void (0) : __assert_fail ("! pNewPrinter->isDisposed()", "/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" , 423, __extension__ __PRETTY_FUNCTION__)); | |||
424 | if( pNewPrinter->IsKnown() ) | |||
425 | { | |||
426 | // set printer only once; in _postSetValues | |||
427 | mpPrinter = pNewPrinter; | |||
428 | } | |||
429 | else | |||
430 | { | |||
431 | pNewPrinter.disposeAndClear(); | |||
432 | } | |||
433 | } | |||
434 | } | |||
435 | ||||
436 | } | |||
437 | break; | |||
438 | case HANDLE_PRINTER_SETUP: | |||
439 | { | |||
440 | Sequence < sal_Int8 > aSequence; | |||
441 | if ( !(rValue >>= aSequence) ) | |||
442 | throw IllegalArgumentException(); | |||
443 | ||||
444 | sal_uInt32 nSize = aSequence.getLength(); | |||
445 | if( nSize > 0 ) | |||
446 | { | |||
447 | SvMemoryStream aStream (aSequence.getArray(), nSize, | |||
448 | StreamMode::READ ); | |||
449 | aStream.Seek ( STREAM_SEEK_TO_BEGIN0L ); | |||
450 | static sal_uInt16 const nRange[] = | |||
451 | { | |||
452 | FN_PARAM_ADDPRINTER((20000 + 1100)+18), FN_PARAM_ADDPRINTER((20000 + 1100)+18), | |||
453 | SID_HTML_MODE(10000 + 414), SID_HTML_MODE(10000 + 414), | |||
454 | SID_PRINTER_NOTFOUND_WARN(5000 + 320), SID_PRINTER_NOTFOUND_WARN(5000 + 320), | |||
455 | SID_PRINTER_CHANGESTODOC(5000 + 324), SID_PRINTER_CHANGESTODOC(5000 + 324), | |||
456 | 0 | |||
457 | }; | |||
458 | auto pItemSet = std::make_unique<SfxItemSet>( mpDoc->GetAttrPool(), nRange ); | |||
459 | VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) ); | |||
460 | assert (! pPrinter->isDisposed() )(static_cast <bool> (! pPrinter->isDisposed()) ? void (0) : __assert_fail ("! pPrinter->isDisposed()", "/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" , 460, __extension__ __PRETTY_FUNCTION__)); | |||
461 | // set printer only once; in _postSetValues | |||
462 | mpPrinter.disposeAndClear(); | |||
463 | mpPrinter = pPrinter; | |||
464 | } | |||
465 | ||||
466 | } | |||
467 | break; | |||
468 | case HANDLE_PRINTER_PAPER: | |||
469 | { | |||
470 | bool bPreferPrinterPapersize = {}; // spurious -Werror=maybe-uninitialized | |||
471 | if(!(rValue >>= bPreferPrinterPapersize)) | |||
472 | throw IllegalArgumentException(); | |||
473 | mbPreferPrinterPapersize = bPreferPrinterPapersize; | |||
474 | } | |||
475 | break; | |||
476 | case HANDLE_IS_KERN_ASIAN_PUNCTUATION: | |||
477 | { | |||
478 | bool bIsKern = *o3tl::doAccess<bool>(rValue); | |||
479 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::KERN_ASIAN_PUNCTUATION, bIsKern); | |||
480 | SwEditShell* pEditSh = mpDoc->GetEditShell(); | |||
481 | if(pEditSh) | |||
482 | pEditSh->ChgHyphenation(); | |||
483 | } | |||
484 | break; | |||
485 | case HANDLE_CHARACTER_COMPRESSION_TYPE: | |||
486 | { | |||
487 | sal_Int16 nMode = 0; | |||
488 | rValue >>= nMode; | |||
489 | switch (static_cast<CharCompressType>(nMode)) | |||
490 | { | |||
491 | case CharCompressType::NONE: | |||
492 | case CharCompressType::PunctuationOnly: | |||
493 | case CharCompressType::PunctuationAndKana: | |||
494 | break; | |||
495 | default: | |||
496 | throw IllegalArgumentException(); | |||
497 | } | |||
498 | mpDoc->getIDocumentSettingAccess().setCharacterCompressionType(static_cast<CharCompressType>(nMode)); | |||
499 | } | |||
500 | break; | |||
501 | case HANDLE_APPLY_USER_DATA: | |||
502 | { | |||
503 | mpDocSh->SetUseUserData(*o3tl::doAccess<bool>(rValue)); | |||
504 | } | |||
505 | break; | |||
506 | case HANDLE_SAVE_THUMBNAIL: | |||
507 | { | |||
508 | mpDocSh->SetUseThumbnailSave(*o3tl::doAccess<bool>(rValue)); | |||
509 | } | |||
510 | break; | |||
511 | case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS: | |||
512 | { | |||
513 | bool bSaveGlobal = *o3tl::doAccess<bool>(rValue); | |||
514 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::GLOBAL_DOCUMENT_SAVE_LINKS, bSaveGlobal ); | |||
515 | } | |||
516 | break; | |||
517 | case HANDLE_CURRENT_DATABASE_DATA_SOURCE: | |||
518 | { | |||
519 | SwDBData aData = mpDoc->GetDBData(); | |||
520 | if ( rValue >>= aData.sDataSource ) | |||
521 | mpDoc->ChgDBData( aData ); | |||
522 | } | |||
523 | break; | |||
524 | case HANDLE_CURRENT_DATABASE_COMMAND: | |||
525 | { | |||
526 | SwDBData aData = mpDoc->GetDBData(); | |||
527 | ||||
528 | if ( rValue >>= aData.sCommand ) | |||
529 | mpDoc->ChgDBData( aData ); | |||
530 | ||||
531 | SAL_WARN_IF( aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty(), "sw.uno",do { if (true && (aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty())) { switch (sal_detail_log_report( ::SAL_DETAIL_LOG_LEVEL_WARN, "sw.uno")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
532 | "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" )do { if (true && (aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty())) { switch (sal_detail_log_report( ::SAL_DETAIL_LOG_LEVEL_WARN, "sw.uno")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "532" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
533 | } | |||
534 | break; | |||
535 | case HANDLE_CURRENT_DATABASE_COMMAND_TYPE: | |||
536 | { | |||
537 | SwDBData aData = mpDoc->GetDBData(); | |||
538 | if ( rValue >>= aData.nCommandType ) | |||
539 | mpDoc->ChgDBData( aData ); | |||
540 | SAL_WARN_IF( aData.nCommandType && aData.sDataSource.isEmpty(), "sw.uno",do { if (true && (aData.nCommandType && aData .sDataSource.isEmpty())) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sw.uno")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
541 | "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" )do { if (true && (aData.nCommandType && aData .sDataSource.isEmpty())) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sw.uno")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "541" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
542 | SAL_WARN_IF( aData.nCommandType && aData.sCommand.isEmpty(), "sw.uno",do { if (true && (aData.nCommandType && aData .sCommand.isEmpty())) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sw.uno")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
543 | "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" )do { if (true && (aData.nCommandType && aData .sCommand.isEmpty())) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sw.uno")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.uno" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uno/SwXDocumentSettings.cxx" ":" "543" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
544 | } | |||
545 | break; | |||
546 | case HANDLE_EMBEDDED_DATABASE_NAME: | |||
547 | { | |||
548 | #if HAVE_FEATURE_DBCONNECTIVITY1 | |||
549 | OUString sEmbeddedName; | |||
550 | if (rValue >>= sEmbeddedName) | |||
551 | mpDoc->GetDBManager()->setEmbeddedName(sEmbeddedName, *mpDocSh); | |||
552 | #endif | |||
553 | } | |||
554 | break; | |||
555 | case HANDLE_SAVE_VERSION_ON_CLOSE: | |||
556 | { | |||
557 | mpDocSh->SetSaveVersionOnClose( *o3tl::doAccess<bool>(rValue) ); | |||
558 | } | |||
559 | break; | |||
560 | case HANDLE_UPDATE_FROM_TEMPLATE: | |||
561 | { | |||
562 | mpDocSh->SetQueryLoadTemplate( *o3tl::doAccess<bool>(rValue) ); | |||
563 | } | |||
564 | break; | |||
565 | case HANDLE_PRINTER_INDEPENDENT_LAYOUT: | |||
566 | { | |||
567 | sal_Int16 nTmp = 0; | |||
568 | rValue >>= nTmp; | |||
569 | ||||
570 | bool bUseVirDev = true; | |||
571 | bool bHiResVirDev = true; | |||
572 | if( nTmp == document::PrinterIndependentLayout::DISABLED ) | |||
573 | bUseVirDev = false; | |||
574 | else if ( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION ) | |||
575 | bHiResVirDev = false; | |||
576 | else if ( nTmp != document::PrinterIndependentLayout::HIGH_RESOLUTION ) | |||
577 | throw IllegalArgumentException(); | |||
578 | ||||
579 | mpDoc->getIDocumentDeviceAccess().setReferenceDeviceType( bUseVirDev, bHiResVirDev ); | |||
580 | } | |||
581 | break; | |||
582 | case HANDLE_IS_LABEL_DOC : | |||
583 | { | |||
584 | bool bSet = false; | |||
585 | if(!(rValue >>= bSet)) | |||
586 | throw IllegalArgumentException(); | |||
587 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::LABEL_DOCUMENT, bSet); | |||
588 | } | |||
589 | break; | |||
590 | case HANDLE_IS_ADD_FLY_OFFSET: | |||
591 | { | |||
592 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
593 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::ADD_FLY_OFFSETS, bTmp); | |||
594 | } | |||
595 | break; | |||
596 | case HANDLE_IS_ADD_VERTICAL_FLY_OFFSET: | |||
597 | { | |||
598 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
599 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS, bTmp); | |||
600 | } | |||
601 | break; | |||
602 | case HANDLE_IS_ADD_EXTERNAL_LEADING: | |||
603 | { | |||
604 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
605 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::ADD_EXT_LEADING, bTmp); | |||
606 | } | |||
607 | break; | |||
608 | case HANDLE_OLD_NUMBERING: | |||
609 | { | |||
610 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
611 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::OLD_NUMBERING, bTmp); | |||
612 | } | |||
613 | break; | |||
614 | case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING: | |||
615 | { | |||
616 | // ignore - this is a dead property | |||
617 | } | |||
618 | break; | |||
619 | case HANDLE_ALLOW_PRINTJOB_CANCEL: | |||
620 | { | |||
621 | bool bState = false; | |||
622 | if (!(rValue >>= bState)) | |||
623 | throw IllegalArgumentException(); | |||
624 | mpDocSh->Stamp_SetPrintCancelState(bState); | |||
625 | } | |||
626 | break; | |||
627 | case HANDLE_USE_FORMER_LINE_SPACING: | |||
628 | { | |||
629 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
630 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::OLD_LINE_SPACING, bTmp); | |||
631 | } | |||
632 | break; | |||
633 | case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS: | |||
634 | { | |||
635 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
636 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS, bTmp); | |||
637 | } | |||
638 | break; | |||
639 | case HANDLE_ADD_PARA_LINE_SPACING_TO_TABLE_CELLS: | |||
640 | { | |||
641 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
642 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, bTmp); | |||
643 | } | |||
644 | break; | |||
645 | case HANDLE_USE_FORMER_OBJECT_POSITIONING: | |||
646 | { | |||
647 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
648 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::USE_FORMER_OBJECT_POS, bTmp); | |||
649 | } | |||
650 | break; | |||
651 | case HANDLE_USE_FORMER_TEXT_WRAPPING: | |||
652 | { | |||
653 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
654 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::USE_FORMER_TEXT_WRAPPING, bTmp); | |||
655 | } | |||
656 | break; | |||
657 | case HANDLE_CHANGES_PASSWORD: | |||
658 | { | |||
659 | Sequence <sal_Int8> aNew; | |||
660 | if(rValue >>= aNew) | |||
661 | { | |||
662 | mpDoc->getIDocumentRedlineAccess().SetRedlinePassword(aNew); | |||
663 | if(aNew.hasElements()) | |||
664 | { | |||
665 | RedlineFlags eMode = mpDoc->getIDocumentRedlineAccess().GetRedlineFlags(); | |||
666 | eMode |= RedlineFlags::On; | |||
667 | mpDoc->getIDocumentRedlineAccess().SetRedlineFlags( eMode ); | |||
668 | } | |||
669 | } | |||
670 | } | |||
671 | break; | |||
672 | case HANDLE_CONSIDER_WRAP_ON_OBJPOS: | |||
673 | { | |||
674 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
675 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION, bTmp ); | |||
676 | } | |||
677 | break; | |||
678 | case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: | |||
679 | { | |||
680 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
681 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, bTmp); | |||
682 | } | |||
683 | break; | |||
684 | case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: | |||
685 | { | |||
686 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
687 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, bTmp); | |||
688 | } | |||
689 | break; | |||
690 | case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: | |||
691 | { | |||
692 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
693 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, bTmp); | |||
694 | } | |||
695 | break; | |||
696 | case HANDLE_TABLE_ROW_KEEP: | |||
697 | { | |||
698 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
699 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TABLE_ROW_KEEP, bTmp); | |||
700 | } | |||
701 | break; | |||
702 | case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: | |||
703 | { | |||
704 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
705 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, bTmp); | |||
706 | } | |||
707 | break; | |||
708 | case HANDLE_LOAD_READONLY: | |||
709 | { | |||
710 | mpDocSh->SetLoadReadonly( *o3tl::doAccess<bool>(rValue) ); | |||
711 | } | |||
712 | break; | |||
713 | case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: | |||
714 | { | |||
715 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
716 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, bTmp); | |||
717 | } | |||
718 | break; | |||
719 | case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES: | |||
720 | { | |||
721 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
722 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME, bTmp); | |||
723 | } | |||
724 | break; | |||
725 | case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING: | |||
726 | { | |||
727 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
728 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::UNIX_FORCE_ZERO_EXT_LEADING, bTmp); | |||
729 | } | |||
730 | break; | |||
731 | case HANDLE_USE_OLD_PRINTER_METRICS: | |||
732 | // ignore - this is a dead property | |||
733 | break; | |||
734 | case HANDLE_TABS_RELATIVE_TO_INDENT: | |||
735 | { | |||
736 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
737 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TABS_RELATIVE_TO_INDENT, bTmp); | |||
738 | } | |||
739 | break; | |||
740 | case HANDLE_RSID: | |||
741 | { | |||
742 | sal_uInt32 nTmp = 0; | |||
743 | rValue >>= nTmp; | |||
744 | mpDoc->setRsid( nTmp ); | |||
745 | } | |||
746 | break; | |||
747 | case HANDLE_RSID_ROOT: | |||
748 | { | |||
749 | sal_uInt32 nTmp = 0; | |||
750 | rValue >>= nTmp; | |||
751 | mpDoc->setRsidRoot( nTmp ); | |||
752 | } | |||
753 | break; | |||
754 | case HANDLE_PROTECT_FORM: | |||
755 | { | |||
756 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
757 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_FORM, bTmp); | |||
758 | } | |||
759 | break; | |||
760 | case HANDLE_MS_WORD_COMP_TRAILING_BLANKS: | |||
761 | { | |||
762 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
763 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, bTmp); | |||
764 | } | |||
765 | break; | |||
766 | case HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY: | |||
767 | { | |||
768 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
769 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY, bTmp); | |||
770 | } | |||
771 | break; | |||
772 | case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: | |||
773 | { | |||
774 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
775 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, bTmp); | |||
776 | } | |||
777 | break; | |||
778 | case HANDLE_MODIFYPASSWORDINFO: | |||
779 | { | |||
780 | uno::Sequence< beans::PropertyValue > aInfo; | |||
781 | if ( !( rValue >>= aInfo ) ) | |||
782 | throw lang::IllegalArgumentException( | |||
783 | "Value of type Sequence<PropertyValue> expected!", | |||
784 | uno::Reference< uno::XInterface >(), | |||
785 | 2 ); | |||
786 | ||||
787 | if ( !mpDocSh->SetModifyPasswordInfo( aInfo ) ) | |||
788 | throw beans::PropertyVetoException( | |||
789 | "The hash is not allowed to be changed now!", | |||
790 | uno::Reference< uno::XInterface >() ); | |||
791 | } | |||
792 | break; | |||
793 | case HANDLE_MATH_BASELINE_ALIGNMENT: | |||
794 | { | |||
795 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
796 | mpDoc->getIDocumentSettingAccess().set( DocumentSettingId::MATH_BASELINE_ALIGNMENT, bTmp ); | |||
797 | } | |||
798 | break; | |||
799 | case HANDLE_INVERT_BORDER_SPACING: | |||
800 | { | |||
801 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
802 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::INVERT_BORDER_SPACING, bTmp); | |||
803 | } | |||
804 | break; | |||
805 | case HANDLE_COLLAPSE_EMPTY_CELL_PARA: | |||
806 | { | |||
807 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
808 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::COLLAPSE_EMPTY_CELL_PARA, bTmp); | |||
809 | } | |||
810 | break; | |||
811 | case HANDLE_SMALL_CAPS_PERCENTAGE_66: | |||
812 | { | |||
813 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
814 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::SMALL_CAPS_PERCENTAGE_66, bTmp); | |||
815 | } | |||
816 | break; | |||
817 | case HANDLE_TAB_OVERFLOW: | |||
818 | { | |||
819 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
820 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TAB_OVERFLOW, bTmp); | |||
821 | } | |||
822 | break; | |||
823 | case HANDLE_UNBREAKABLE_NUMBERINGS: | |||
824 | { | |||
825 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
826 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::UNBREAKABLE_NUMBERINGS, bTmp); | |||
827 | } | |||
828 | break; | |||
829 | case HANDLE_STYLES_NODEFAULT: | |||
830 | { | |||
831 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
832 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::STYLES_NODEFAULT, bTmp); | |||
833 | } | |||
834 | break; | |||
835 | case HANDLE_FLOATTABLE_NOMARGINS: | |||
836 | { | |||
837 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
838 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::FLOATTABLE_NOMARGINS, bTmp); | |||
839 | } | |||
840 | break; | |||
841 | case HANDLE_CLIPPED_PICTURES: | |||
842 | { | |||
843 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
844 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::CLIPPED_PICTURES, bTmp); | |||
845 | } | |||
846 | break; | |||
847 | case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS: | |||
848 | { | |||
849 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
850 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::BACKGROUND_PARA_OVER_DRAWINGS, bTmp); | |||
851 | } | |||
852 | break; | |||
853 | case HANDLE_EMBED_FONTS: | |||
854 | { | |||
855 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
856 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_FONTS, bTmp); | |||
857 | } | |||
858 | break; | |||
859 | case HANDLE_EMBED_USED_FONTS: | |||
860 | { | |||
861 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
862 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_USED_FONTS, bTmp); | |||
863 | } | |||
864 | break; | |||
865 | case HANDLE_EMBED_LATIN_SCRIPT_FONTS: | |||
866 | { | |||
867 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
868 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS, bTmp); | |||
869 | } | |||
870 | break; | |||
871 | case HANDLE_EMBED_ASIAN_SCRIPT_FONTS: | |||
872 | { | |||
873 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
874 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS, bTmp); | |||
875 | } | |||
876 | break; | |||
877 | case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS: | |||
878 | { | |||
879 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
880 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS, bTmp); | |||
881 | } | |||
882 | break; | |||
883 | case HANDLE_EMBED_SYSTEM_FONTS: | |||
884 | { | |||
885 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
886 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_SYSTEM_FONTS, bTmp); | |||
887 | } | |||
888 | break; | |||
889 | case HANDLE_TAB_OVER_MARGIN: | |||
890 | { | |||
891 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
892 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TAB_OVER_MARGIN, bTmp); | |||
893 | } | |||
894 | break; | |||
895 | case HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK: | |||
896 | { | |||
897 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
898 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, bTmp); | |||
899 | } | |||
900 | break; | |||
901 | case HANDLE_SURROUND_TEXT_WRAP_SMALL: | |||
902 | { | |||
903 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
904 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::SURROUND_TEXT_WRAP_SMALL, bTmp); | |||
905 | } | |||
906 | break; | |||
907 | case HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: | |||
908 | { | |||
909 | bool bTmp = *o3tl::doAccess<bool>(rValue); | |||
910 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, bTmp); | |||
911 | } | |||
912 | break; | |||
913 | case HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE: | |||
914 | { | |||
915 | bool bTmp; | |||
916 | if (rValue >>= bTmp) | |||
917 | { | |||
918 | mpDoc->getIDocumentSettingAccess().set( | |||
919 | DocumentSettingId::PROP_LINE_SPACING_SHRINKS_FIRST_LINE, bTmp); | |||
920 | } | |||
921 | } | |||
922 | break; | |||
923 | case HANDLE_SUBTRACT_FLYS: | |||
924 | { | |||
925 | bool bTmp; | |||
926 | if (rValue >>= bTmp) | |||
927 | { | |||
928 | mpDoc->getIDocumentSettingAccess().set( | |||
929 | DocumentSettingId::SUBTRACT_FLYS, bTmp); | |||
930 | } | |||
931 | } | |||
932 | break; | |||
933 | case HANDLE_DISABLE_OFF_PAGE_POSITIONING: | |||
934 | { | |||
935 | bool bTmp; | |||
936 | if (rValue >>= bTmp) | |||
937 | { | |||
938 | mpDoc->getIDocumentSettingAccess().set( | |||
939 | DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING, bTmp); | |||
940 | } | |||
941 | } | |||
942 | break; | |||
943 | case HANDLE_EMPTY_DB_FIELD_HIDES_PARA: | |||
944 | { | |||
945 | bool bTmp; | |||
946 | if (rValue >>= bTmp) | |||
947 | { | |||
948 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMPTY_DB_FIELD_HIDES_PARA, | |||
949 | bTmp); | |||
950 | } | |||
951 | } | |||
952 | break; | |||
953 | case HANDLE_CONTINUOUS_ENDNOTES: | |||
954 | { | |||
955 | bool bTmp; | |||
956 | if (rValue >>= bTmp) | |||
957 | { | |||
958 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, | |||
959 | bTmp); | |||
960 | } | |||
961 | } | |||
962 | break; | |||
963 | case HANDLE_PROTECT_BOOKMARKS: | |||
964 | { | |||
965 | bool bTmp; | |||
966 | if (rValue >>= bTmp) | |||
967 | { | |||
968 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_BOOKMARKS, | |||
969 | bTmp); | |||
970 | } | |||
971 | } | |||
972 | break; | |||
973 | case HANDLE_PROTECT_FIELDS: | |||
974 | { | |||
975 | bool bTmp; | |||
976 | if (rValue >>= bTmp) | |||
977 | { | |||
978 | mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_FIELDS, | |||
979 | bTmp); | |||
980 | } | |||
981 | } | |||
982 | break; | |||
983 | case HANDLE_HEADER_SPACING_BELOW_LAST_PARA: | |||
984 | { | |||
985 | bool bTmp; | |||
986 | if (rValue >>= bTmp) | |||
987 | { | |||
988 | mpDoc->getIDocumentSettingAccess().set( | |||
989 | DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA, bTmp); | |||
990 | } | |||
991 | } | |||
992 | break; | |||
993 | case HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA: | |||
994 | { | |||
995 | bool bTmp; | |||
996 | if (rValue >>= bTmp) | |||
997 | { | |||
998 | mpDoc->getIDocumentSettingAccess().set( | |||
999 | DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA, bTmp); | |||
1000 | } | |||
1001 | } | |||
1002 | break; | |||
1003 | default: | |||
1004 | throw UnknownPropertyException(OUString::number(rInfo.mnHandle)); | |||
1005 | } | |||
1006 | } | |||
1007 | ||||
1008 | void SwXDocumentSettings::_postSetValues () | |||
1009 | { | |||
1010 | // set printer only once, namely here! | |||
1011 | if( mpPrinter != nullptr ) | |||
1012 | { | |||
1013 | // #i86352# the printer is also used as container for options by sfx | |||
1014 | // when setting a printer it should have decent default options | |||
1015 | SfxItemSet aOptions( mpPrinter->GetOptions() ); | |||
1016 | SwPrintData aPrtData( mpDoc->getIDocumentDeviceAccess().getPrintData() ); | |||
1017 | SwAddPrinterItem aAddPrinterItem (aPrtData); | |||
1018 | aOptions.Put(aAddPrinterItem); | |||
1019 | mpPrinter->SetOptions( aOptions ); | |||
1020 | mpPrinter->SetPrinterSettingsPreferred( mbPreferPrinterPapersize ); | |||
1021 | ||||
1022 | mpDoc->getIDocumentDeviceAccess().setPrinter( mpPrinter, true, true ); | |||
1023 | } | |||
1024 | ||||
1025 | mpPrinter = nullptr; | |||
1026 | mpDocSh = nullptr; | |||
1027 | mpDoc = nullptr; | |||
1028 | } | |||
1029 | ||||
1030 | void SwXDocumentSettings::_preGetValues () | |||
1031 | { | |||
1032 | mpDocSh = mpModel->GetDocShell(); | |||
1033 | if (nullptr == mpDocSh) | |||
1034 | throw UnknownPropertyException(); | |||
1035 | mpDoc = mpDocSh->GetDoc(); | |||
1036 | if (nullptr == mpDoc) | |||
1037 | throw UnknownPropertyException(); | |||
1038 | } | |||
1039 | ||||
1040 | void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue ) | |||
1041 | { | |||
1042 | switch( rInfo.mnHandle ) | |||
1043 | { | |||
1044 | case HANDLE_FORBIDDEN_CHARS: | |||
1045 | { | |||
1046 | Reference<XForbiddenCharacters> xRet(*mpModel->GetPropertyHelper(), UNO_QUERY); | |||
1047 | rValue <<= xRet; | |||
1048 | } | |||
1049 | break; | |||
1050 | case HANDLE_LINK_UPDATE_MODE: | |||
1051 | { | |||
1052 | rValue <<= static_cast < sal_Int16 > ( mpDoc->getIDocumentSettingAccess().getLinkUpdateMode(true) ); | |||
1053 | } | |||
1054 | break; | |||
1055 | case HANDLE_FIELD_AUTO_UPDATE: | |||
1056 | { | |||
1057 | SwFieldUpdateFlags nFlags = mpDoc->getIDocumentSettingAccess().getFieldUpdateFlags(true); | |||
1058 | rValue <<= nFlags == AUTOUPD_FIELD_ONLY || nFlags == AUTOUPD_FIELD_AND_CHARTS; | |||
1059 | } | |||
1060 | break; | |||
1061 | case HANDLE_CHART_AUTO_UPDATE: | |||
1062 | { | |||
1063 | SwFieldUpdateFlags nFlags = mpDoc->getIDocumentSettingAccess().getFieldUpdateFlags(true); | |||
1064 | rValue <<= nFlags == AUTOUPD_FIELD_AND_CHARTS; | |||
1065 | } | |||
1066 | break; | |||
1067 | case HANDLE_ADD_PARA_TABLE_SPACING: | |||
1068 | { | |||
1069 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::PARA_SPACE_MAX); | |||
1070 | } | |||
1071 | break; | |||
1072 | case HANDLE_ADD_PARA_TABLE_SPACING_AT_START: | |||
1073 | { | |||
1074 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::PARA_SPACE_MAX_AT_PAGES); | |||
1075 | } | |||
1076 | break; | |||
1077 | case HANDLE_ALIGN_TAB_STOP_POSITION: | |||
1078 | { | |||
1079 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::TAB_COMPAT); | |||
1080 | } | |||
1081 | break; | |||
1082 | case HANDLE_PRINTER_NAME: | |||
1083 | { | |||
1084 | SfxPrinter *pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( false ); | |||
1085 | rValue <<= pPrinter ? pPrinter->GetName() : OUString(); | |||
1086 | } | |||
1087 | break; | |||
1088 | case HANDLE_PRINTER_SETUP: | |||
1089 | { | |||
1090 | SfxPrinter *pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( false ); | |||
1091 | if (pPrinter) | |||
1092 | { | |||
1093 | SvMemoryStream aStream; | |||
1094 | pPrinter->Store( aStream ); | |||
1095 | sal_uInt32 nSize = aStream.TellEnd(); | |||
1096 | aStream.Seek ( STREAM_SEEK_TO_BEGIN0L ); | |||
1097 | Sequence < sal_Int8 > aSequence( nSize ); | |||
1098 | aStream.ReadBytes(aSequence.getArray(), nSize); | |||
1099 | rValue <<= aSequence; | |||
1100 | } | |||
1101 | else | |||
1102 | { | |||
1103 | Sequence < sal_Int8 > aSequence ( 0 ); | |||
1104 | rValue <<= aSequence; | |||
1105 | } | |||
1106 | } | |||
1107 | break; | |||
1108 | case HANDLE_PRINTER_PAPER: | |||
1109 | { | |||
1110 | SfxPrinter *pTempPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( false ); | |||
1111 | rValue <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred(); | |||
1112 | } | |||
1113 | break; | |||
1114 | case HANDLE_IS_KERN_ASIAN_PUNCTUATION: | |||
1115 | { | |||
1116 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::KERN_ASIAN_PUNCTUATION); | |||
1117 | } | |||
1118 | break; | |||
1119 | case HANDLE_APPLY_USER_DATA: | |||
1120 | { | |||
1121 | rValue <<= mpDocSh->IsUseUserData(); | |||
1122 | } | |||
1123 | break; | |||
1124 | case HANDLE_SAVE_THUMBNAIL: | |||
1125 | { | |||
1126 | rValue <<= mpDocSh->IsUseThumbnailSave(); | |||
1127 | } | |||
1128 | break; | |||
1129 | case HANDLE_CHARACTER_COMPRESSION_TYPE: | |||
1130 | { | |||
1131 | rValue <<= static_cast < sal_Int16 > (mpDoc->getIDocumentSettingAccess().getCharacterCompressionType()); | |||
1132 | } | |||
1133 | break; | |||
1134 | case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS: | |||
1135 | { | |||
1136 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::GLOBAL_DOCUMENT_SAVE_LINKS); | |||
1137 | } | |||
1138 | break; | |||
1139 | case HANDLE_CURRENT_DATABASE_DATA_SOURCE: | |||
1140 | { | |||
1141 | const SwDBData& rData = mpDoc->GetDBDesc(); | |||
1142 | rValue <<= rData.sDataSource; | |||
1143 | } | |||
1144 | break; | |||
1145 | case HANDLE_CURRENT_DATABASE_COMMAND: | |||
1146 | { | |||
1147 | const SwDBData& rData = mpDoc->GetDBDesc(); | |||
1148 | rValue <<= rData.sCommand; | |||
1149 | } | |||
1150 | break; | |||
1151 | case HANDLE_CURRENT_DATABASE_COMMAND_TYPE: | |||
1152 | { | |||
1153 | const SwDBData& rData = mpDoc->GetDBDesc(); | |||
1154 | rValue <<= rData.nCommandType; | |||
1155 | } | |||
1156 | break; | |||
1157 | case HANDLE_EMBEDDED_DATABASE_NAME: | |||
1158 | { | |||
1159 | #if HAVE_FEATURE_DBCONNECTIVITY1 | |||
1160 | rValue <<= mpDoc->GetDBManager()->getEmbeddedName(); | |||
1161 | #else | |||
1162 | rValue = uno::Any(); | |||
1163 | #endif | |||
1164 | } | |||
1165 | break; | |||
1166 | case HANDLE_SAVE_VERSION_ON_CLOSE: | |||
1167 | { | |||
1168 | rValue <<= mpDocSh->IsSaveVersionOnClose(); | |||
1169 | } | |||
1170 | break; | |||
1171 | case HANDLE_UPDATE_FROM_TEMPLATE: | |||
1172 | { | |||
1173 | rValue <<= mpDocSh->IsQueryLoadTemplate(); | |||
1174 | } | |||
1175 | break; | |||
1176 | case HANDLE_PRINTER_INDEPENDENT_LAYOUT: | |||
1177 | { | |||
1178 | // returns short (see css.document.PrinterIndependentLayout) | |||
1179 | sal_Int16 nVirDevType = mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::USE_VIRTUAL_DEVICE) ? | |||
1180 | ( mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE) ? | |||
1181 | document::PrinterIndependentLayout::HIGH_RESOLUTION : | |||
1182 | document::PrinterIndependentLayout::LOW_RESOLUTION ) : | |||
1183 | document::PrinterIndependentLayout::DISABLED; | |||
1184 | rValue <<= nVirDevType; | |||
1185 | } | |||
1186 | break; | |||
1187 | case HANDLE_IS_LABEL_DOC: | |||
1188 | { | |||
1189 | bool bLabel = mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::LABEL_DOCUMENT); | |||
1190 | rValue <<= bLabel; | |||
1191 | } | |||
1192 | break; | |||
1193 | case HANDLE_IS_ADD_FLY_OFFSET: | |||
1194 | { | |||
1195 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ADD_FLY_OFFSETS); | |||
1196 | } | |||
1197 | break; | |||
1198 | case HANDLE_IS_ADD_VERTICAL_FLY_OFFSET: | |||
1199 | { | |||
1200 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS); | |||
1201 | } | |||
1202 | break; | |||
1203 | case HANDLE_IS_ADD_EXTERNAL_LEADING: | |||
1204 | { | |||
1205 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING); | |||
1206 | } | |||
1207 | break; | |||
1208 | case HANDLE_OLD_NUMBERING: | |||
1209 | { | |||
1210 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::OLD_NUMBERING); | |||
1211 | } | |||
1212 | break; | |||
1213 | case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING: | |||
1214 | { | |||
1215 | rValue <<= false; | |||
1216 | } | |||
1217 | break; | |||
1218 | case HANDLE_ALLOW_PRINTJOB_CANCEL: | |||
1219 | { | |||
1220 | rValue <<= mpDocSh->Stamp_GetPrintCancelState(); | |||
1221 | } | |||
1222 | break; | |||
1223 | case HANDLE_USE_FORMER_LINE_SPACING: | |||
1224 | { | |||
1225 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::OLD_LINE_SPACING); | |||
1226 | } | |||
1227 | break; | |||
1228 | case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS: | |||
1229 | { | |||
1230 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS); | |||
1231 | } | |||
1232 | break; | |||
1233 | case HANDLE_ADD_PARA_LINE_SPACING_TO_TABLE_CELLS: | |||
1234 | { | |||
1235 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ADD_PARA_LINE_SPACING_TO_TABLE_CELLS); | |||
1236 | } | |||
1237 | break; | |||
1238 | case HANDLE_USE_FORMER_OBJECT_POSITIONING: | |||
1239 | { | |||
1240 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::USE_FORMER_OBJECT_POS); | |||
1241 | } | |||
1242 | break; | |||
1243 | case HANDLE_USE_FORMER_TEXT_WRAPPING: | |||
1244 | { | |||
1245 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING); | |||
1246 | } | |||
1247 | break; | |||
1248 | case HANDLE_CHANGES_PASSWORD: | |||
1249 | { | |||
1250 | rValue <<= mpDoc->getIDocumentRedlineAccess().GetRedlinePassword(); | |||
1251 | } | |||
1252 | break; | |||
1253 | case HANDLE_CONSIDER_WRAP_ON_OBJPOS: | |||
1254 | { | |||
1255 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION); | |||
1256 | } | |||
1257 | break; | |||
1258 | case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: | |||
1259 | { | |||
1260 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING); | |||
1261 | } | |||
1262 | break; | |||
1263 | case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: | |||
1264 | { | |||
1265 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK); | |||
1266 | } | |||
1267 | break; | |||
1268 | case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: | |||
1269 | { | |||
1270 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT); | |||
1271 | } | |||
1272 | break; | |||
1273 | case HANDLE_TABLE_ROW_KEEP : | |||
1274 | { | |||
1275 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::TABLE_ROW_KEEP); | |||
1276 | } | |||
1277 | break; | |||
1278 | case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: | |||
1279 | { | |||
1280 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION); | |||
1281 | } | |||
1282 | break; | |||
1283 | case HANDLE_LOAD_READONLY: | |||
1284 | { | |||
1285 | rValue <<= mpDocSh->IsLoadReadonly(); | |||
1286 | } | |||
1287 | break; | |||
1288 | case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: | |||
1289 | { | |||
1290 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE); | |||
1291 | } | |||
1292 | break; | |||
1293 | case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES: | |||
1294 | { | |||
1295 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME); | |||
1296 | } | |||
1297 | break; | |||
1298 | case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING: | |||
1299 | { | |||
1300 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::UNIX_FORCE_ZERO_EXT_LEADING); | |||
1301 | } | |||
1302 | break; | |||
1303 | case HANDLE_USE_OLD_PRINTER_METRICS: | |||
1304 | { | |||
1305 | rValue <<= false; | |||
1306 | } | |||
1307 | break; | |||
1308 | case HANDLE_TABS_RELATIVE_TO_INDENT: | |||
1309 | { | |||
1310 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT); | |||
1311 | } | |||
1312 | break; | |||
1313 | case HANDLE_RSID: | |||
1314 | { | |||
1315 | rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsid() ); | |||
1316 | } | |||
1317 | break; | |||
1318 | case HANDLE_RSID_ROOT: | |||
1319 | { | |||
1320 | rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsidRoot() ); | |||
1321 | } | |||
1322 | break; | |||
1323 | case HANDLE_PROTECT_FORM: | |||
1324 | { | |||
1325 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FORM); | |||
1326 | } | |||
1327 | break; | |||
1328 | case HANDLE_MS_WORD_COMP_TRAILING_BLANKS: | |||
1329 | { | |||
1330 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS); | |||
1331 | } | |||
1332 | break; | |||
1333 | case HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY: | |||
1334 | { | |||
1335 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY); | |||
1336 | } | |||
1337 | break; | |||
1338 | case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: | |||
1339 | { | |||
1340 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST); | |||
1341 | } | |||
1342 | break; | |||
1343 | case HANDLE_MODIFYPASSWORDINFO: | |||
1344 | { | |||
1345 | rValue <<= mpDocSh->GetModifyPasswordInfo(); | |||
1346 | } | |||
1347 | break; | |||
1348 | case HANDLE_MATH_BASELINE_ALIGNMENT: | |||
1349 | { | |||
1350 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ); | |||
1351 | } | |||
1352 | break; | |||
1353 | case HANDLE_INVERT_BORDER_SPACING: | |||
1354 | { | |||
1355 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::INVERT_BORDER_SPACING); | |||
1356 | } | |||
1357 | break; | |||
1358 | case HANDLE_COLLAPSE_EMPTY_CELL_PARA: | |||
1359 | { | |||
1360 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::COLLAPSE_EMPTY_CELL_PARA ); | |||
1361 | } | |||
1362 | break; | |||
1363 | case HANDLE_SMALL_CAPS_PERCENTAGE_66: | |||
1364 | { | |||
1365 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::SMALL_CAPS_PERCENTAGE_66 ); | |||
1366 | } | |||
1367 | break; | |||
1368 | case HANDLE_TAB_OVERFLOW: | |||
1369 | { | |||
1370 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::TAB_OVERFLOW ); | |||
1371 | } | |||
1372 | break; | |||
1373 | case HANDLE_UNBREAKABLE_NUMBERINGS: | |||
1374 | { | |||
1375 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::UNBREAKABLE_NUMBERINGS ); | |||
1376 | } | |||
1377 | break; | |||
1378 | case HANDLE_STYLES_NODEFAULT: | |||
1379 | { | |||
1380 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::STYLES_NODEFAULT ); | |||
1381 | } | |||
1382 | break; | |||
1383 | case HANDLE_FLOATTABLE_NOMARGINS: | |||
1384 | { | |||
1385 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::FLOATTABLE_NOMARGINS ); | |||
1386 | } | |||
1387 | break; | |||
1388 | case HANDLE_CLIPPED_PICTURES: | |||
1389 | { | |||
1390 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::CLIPPED_PICTURES ); | |||
1391 | } | |||
1392 | break; | |||
1393 | case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS: | |||
1394 | { | |||
1395 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::BACKGROUND_PARA_OVER_DRAWINGS ); | |||
1396 | } | |||
1397 | break; | |||
1398 | case HANDLE_EMBED_FONTS: | |||
1399 | { | |||
1400 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ); | |||
1401 | } | |||
1402 | break; | |||
1403 | case HANDLE_EMBED_USED_FONTS: | |||
1404 | { | |||
1405 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_USED_FONTS ); | |||
1406 | } | |||
1407 | break; | |||
1408 | case HANDLE_EMBED_LATIN_SCRIPT_FONTS: | |||
1409 | { | |||
1410 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS ); | |||
1411 | } | |||
1412 | break; | |||
1413 | case HANDLE_EMBED_ASIAN_SCRIPT_FONTS: | |||
1414 | { | |||
1415 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS ); | |||
1416 | } | |||
1417 | break; | |||
1418 | case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS: | |||
1419 | { | |||
1420 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS ); | |||
1421 | } | |||
1422 | break; | |||
1423 | case HANDLE_EMBED_SYSTEM_FONTS: | |||
1424 | { | |||
1425 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_SYSTEM_FONTS ); | |||
1426 | } | |||
1427 | break; | |||
1428 | case HANDLE_TAB_OVER_MARGIN: | |||
1429 | { | |||
1430 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::TAB_OVER_MARGIN ); | |||
1431 | } | |||
1432 | break; | |||
1433 | case HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK: | |||
1434 | { | |||
1435 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK ); | |||
1436 | } | |||
1437 | break; | |||
1438 | case HANDLE_SURROUND_TEXT_WRAP_SMALL: | |||
1439 | { | |||
1440 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::SURROUND_TEXT_WRAP_SMALL ); | |||
1441 | } | |||
1442 | break; | |||
1443 | case HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: | |||
1444 | { | |||
1445 | rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ); | |||
1446 | } | |||
1447 | break; | |||
1448 | case HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE: | |||
1449 | { | |||
1450 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::PROP_LINE_SPACING_SHRINKS_FIRST_LINE); | |||
1451 | } | |||
1452 | break; | |||
1453 | case HANDLE_SUBTRACT_FLYS: | |||
1454 | { | |||
1455 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::SUBTRACT_FLYS); | |||
1456 | } | |||
1457 | break; | |||
1458 | case HANDLE_DISABLE_OFF_PAGE_POSITIONING: | |||
1459 | { | |||
1460 | rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING); | |||
1461 | } | |||
1462 | break; | |||
1463 | case HANDLE_EMPTY_DB_FIELD_HIDES_PARA: | |||
1464 | { | |||
1465 | rValue <<= mpDoc->getIDocumentSettingAccess().get( | |||
1466 | DocumentSettingId::EMPTY_DB_FIELD_HIDES_PARA); | |||
1467 | } | |||
1468 | break; | |||
1469 | case HANDLE_CONTINUOUS_ENDNOTES: | |||
1470 | { | |||
1471 | rValue | |||
1472 | <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::CONTINUOUS_ENDNOTES); | |||
1473 | } | |||
1474 | break; | |||
1475 | case HANDLE_PROTECT_BOOKMARKS: | |||
1476 | { | |||
1477 | rValue <<= mpDoc->getIDocumentSettingAccess().get( | |||
1478 | DocumentSettingId::PROTECT_BOOKMARKS); | |||
1479 | } | |||
1480 | break; | |||
1481 | case HANDLE_PROTECT_FIELDS: | |||
1482 | { | |||
1483 | rValue <<= mpDoc->getIDocumentSettingAccess().get( | |||
1484 | DocumentSettingId::PROTECT_FIELDS); | |||
1485 | } | |||
1486 | break; | |||
1487 | case HANDLE_HEADER_SPACING_BELOW_LAST_PARA: | |||
1488 | { | |||
1489 | rValue <<= mpDoc->getIDocumentSettingAccess().get( | |||
1490 | DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA); | |||
1491 | } | |||
1492 | break; | |||
1493 | case HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA: | |||
1494 | { | |||
1495 | rValue <<= mpDoc->getIDocumentSettingAccess().get( | |||
1496 | DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA); | |||
1497 | } | |||
1498 | break; | |||
1499 | default: | |||
1500 | throw UnknownPropertyException(OUString::number(rInfo.mnHandle)); | |||
1501 | } | |||
1502 | } | |||
1503 | ||||
1504 | void SwXDocumentSettings::_postGetValues () | |||
1505 | { | |||
1506 | mpDocSh = nullptr; | |||
1507 | mpDoc = nullptr; | |||
1508 | } | |||
1509 | ||||
1510 | // XServiceInfo | |||
1511 | OUString SAL_CALL SwXDocumentSettings::getImplementationName( ) | |||
1512 | { | |||
1513 | return "SwXDocumentSettings"; | |||
1514 | } | |||
1515 | ||||
1516 | sal_Bool SAL_CALL SwXDocumentSettings::supportsService( const OUString& ServiceName ) | |||
1517 | { | |||
1518 | return cppu::supportsService(this, ServiceName); | |||
1519 | } | |||
1520 | ||||
1521 | Sequence< OUString > SAL_CALL SwXDocumentSettings::getSupportedServiceNames( ) | |||
1522 | { | |||
1523 | return { "com.sun.star.document.Settings", "com.sun.star.text.DocumentSettings", "com.sun.star.text.PrintSettings" }; | |||
1524 | } | |||
1525 | ||||
1526 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||
22 | |||||||||
23 | #include "sal/config.h" | ||||||||
24 | |||||||||
25 | #include <cassert> | ||||||||
26 | #include <cstddef> | ||||||||
27 | #include <functional> | ||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
29 | #include <type_traits> | ||||||||
30 | #endif | ||||||||
31 | |||||||||
32 | #include "sal/types.h" | ||||||||
33 | |||||||||
34 | namespace rtl | ||||||||
35 | { | ||||||||
36 | |||||||||
37 | /** Template reference class for reference type. | ||||||||
38 | */ | ||||||||
39 | template <class reference_type> | ||||||||
40 | class Reference | ||||||||
41 | { | ||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||
43 | */ | ||||||||
44 | reference_type * m_pBody; | ||||||||
45 | |||||||||
46 | |||||||||
47 | public: | ||||||||
48 | /** Constructor... | ||||||||
49 | */ | ||||||||
50 | Reference() | ||||||||
51 | : m_pBody (NULL__null) | ||||||||
52 | {} | ||||||||
53 | |||||||||
54 | |||||||||
55 | /** Constructor... | ||||||||
56 | */ | ||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||
58 | : m_pBody (pBody) | ||||||||
59 | { | ||||||||
60 | } | ||||||||
61 | |||||||||
62 | /** Constructor... | ||||||||
63 | */ | ||||||||
64 | Reference (reference_type * pBody) | ||||||||
65 | : m_pBody (pBody) | ||||||||
66 | { | ||||||||
67 | if (m_pBody) | ||||||||
68 | m_pBody->acquire(); | ||||||||
69 | } | ||||||||
70 | |||||||||
71 | /** Copy constructor... | ||||||||
72 | */ | ||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||
75 | { | ||||||||
76 | if (m_pBody) | ||||||||
77 | m_pBody->acquire(); | ||||||||
78 | } | ||||||||
79 | |||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
81 | /** Move constructor... | ||||||||
82 | */ | ||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||
85 | { | ||||||||
86 | handle.m_pBody = nullptr; | ||||||||
87 | } | ||||||||
88 | #endif | ||||||||
89 | |||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||
92 | |||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||
94 | |||||||||
95 | @param rRef another reference | ||||||||
96 | */ | ||||||||
97 | template< class derived_type > | ||||||||
98 | inline Reference( | ||||||||
99 | const Reference< derived_type > & rRef, | ||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||
101 | : m_pBody (rRef.get()) | ||||||||
102 | { | ||||||||
103 | if (m_pBody) | ||||||||
104 | m_pBody->acquire(); | ||||||||
105 | } | ||||||||
106 | #endif | ||||||||
107 | |||||||||
108 | /** Destructor... | ||||||||
109 | */ | ||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||
111 | { | ||||||||
112 | if (m_pBody) | ||||||||
113 | m_pBody->release(); | ||||||||
114 | } | ||||||||
115 | |||||||||
116 | /** Set... | ||||||||
117 | Similar to assignment. | ||||||||
118 | */ | ||||||||
119 | Reference<reference_type> & | ||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||
121 | { | ||||||||
122 | if (pBody) | ||||||||
123 | pBody->acquire(); | ||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||
125 | m_pBody = pBody; | ||||||||
126 | if (pOld) | ||||||||
127 | pOld->release(); | ||||||||
128 | return *this; | ||||||||
129 | } | ||||||||
130 | |||||||||
131 | /** Assignment. | ||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||
133 | bind it to the body represented by the handle. | ||||||||
134 | */ | ||||||||
135 | Reference<reference_type> & | ||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||
137 | { | ||||||||
138 | return set( handle.m_pBody ); | ||||||||
139 | } | ||||||||
140 | |||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
142 | /** Assignment. | ||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||
144 | * bind it to the body represented by the handle, and | ||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||
146 | */ | ||||||||
147 | Reference<reference_type> & | ||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||
149 | { | ||||||||
150 | // self-movement guts ourself | ||||||||
151 | if (m_pBody) | ||||||||
152 | m_pBody->release(); | ||||||||
153 | m_pBody = handle.m_pBody; | ||||||||
154 | handle.m_pBody = nullptr; | ||||||||
155 | return *this; | ||||||||
156 | } | ||||||||
157 | #endif | ||||||||
158 | |||||||||
159 | /** Assignment... | ||||||||
160 | */ | ||||||||
161 | Reference<reference_type> & | ||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||
163 | { | ||||||||
164 | return set( pBody ); | ||||||||
165 | } | ||||||||
166 | |||||||||
167 | /** Unbind the body from this handle. | ||||||||
168 | Note that for a handle representing a large body, | ||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||
171 | since in the second case two large objects exist in memory | ||||||||
172 | (the old body and the new body). | ||||||||
173 | */ | ||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||
175 | { | ||||||||
176 | if (m_pBody
| ||||||||
177 | { | ||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||
179 | m_pBody = NULL__null; | ||||||||
180 | pOld->release(); | ||||||||
181 | } | ||||||||
182 | return *this; | ||||||||
183 | } | ||||||||
184 | |||||||||
185 | |||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||
188 | are the same. | ||||||||
189 | */ | ||||||||
190 | reference_type * SAL_CALL get() const | ||||||||
191 | { | ||||||||
192 | return m_pBody; | ||||||||
| |||||||||
193 | } | ||||||||
194 | |||||||||
195 | |||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||
197 | */ | ||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||
199 | { | ||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||
201 | return m_pBody; | ||||||||
202 | } | ||||||||
203 | |||||||||
204 | |||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||
206 | */ | ||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||
208 | { | ||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||
210 | return *m_pBody; | ||||||||
211 | } | ||||||||
212 | |||||||||
213 | |||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||
215 | */ | ||||||||
216 | bool SAL_CALL is() const | ||||||||
217 | { | ||||||||
218 | return (m_pBody != NULL__null); | ||||||||
219 | } | ||||||||
220 | |||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||
223 | */ | ||||||||
224 | explicit operator bool() const | ||||||||
225 | { | ||||||||
226 | return is(); | ||||||||
227 | } | ||||||||
228 | #endif | ||||||||
229 | |||||||||
230 | /** Returns True if this points to pBody. | ||||||||
231 | */ | ||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||
233 | { | ||||||||
234 | return (m_pBody == pBody); | ||||||||
235 | } | ||||||||
236 | |||||||||
237 | |||||||||
238 | /** Returns True if handle points to the same body. | ||||||||
239 | */ | ||||||||
240 | bool | ||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||
242 | { | ||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||
244 | } | ||||||||
245 | |||||||||
246 | |||||||||
247 | /** Needed to place References into STL collection. | ||||||||
248 | */ | ||||||||
249 | bool | ||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||
251 | { | ||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||
253 | } | ||||||||
254 | |||||||||
255 | |||||||||
256 | /** Needed to place References into STL collection. | ||||||||
257 | */ | ||||||||
258 | bool | ||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||
260 | { | ||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||
262 | } | ||||||||
263 | |||||||||
264 | |||||||||
265 | /** Needed to place References into STL collection. | ||||||||
266 | */ | ||||||||
267 | bool | ||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||
269 | { | ||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||
271 | } | ||||||||
272 | }; | ||||||||
273 | |||||||||
274 | } // namespace rtl | ||||||||
275 | |||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
277 | namespace std | ||||||||
278 | { | ||||||||
279 | |||||||||
280 | /// @cond INTERNAL | ||||||||
281 | /** | ||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||
283 | |||||||||
284 | @since LibreOffice 6.3 | ||||||||
285 | */ | ||||||||
286 | template<typename T> | ||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||
288 | { | ||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||
290 | { return std::size_t(s.get()); } | ||||||||
291 | }; | ||||||||
292 | /// @endcond | ||||||||
293 | |||||||||
294 | } | ||||||||
295 | |||||||||
296 | #endif | ||||||||
297 | |||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||
299 | |||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |