Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <osl/mutex.hxx>
21 : #include <sfx2/printer.hxx>
22 : #include <vcl/svapp.hxx>
23 : #include <svtools/ctrltool.hxx>
24 : #include <svl/itemprop.hxx>
25 : #include <unotools/localedatawrapper.hxx>
26 : #include <editeng/paperinf.hxx>
27 : #include <vcl/settings.hxx>
28 : #include <vcl/print.hxx>
29 : #include <toolkit/awt/vclxdevice.hxx>
30 : #include <com/sun/star/beans/PropertyAttribute.hpp>
31 : #include <com/sun/star/formula/SymbolDescriptor.hpp>
32 : #include <com/sun/star/awt/Size.hpp>
33 : #include <com/sun/star/script/XLibraryContainer.hpp>
34 : #include <xmloff/xmluconv.hxx>
35 : #include <rtl/ustrbuf.hxx>
36 : #include <comphelper/propertysetinfo.hxx>
37 : #include <comphelper/servicehelper.hxx>
38 : #include <cppuhelper/supportsservice.hxx>
39 : #include <unotools/moduleoptions.hxx>
40 : #include <tools/mapunit.hxx>
41 :
42 : #include <unomodel.hxx>
43 : #include <document.hxx>
44 : #include <view.hxx>
45 : #include <symbol.hxx>
46 : #include <starmath.hrc>
47 : #include <smdll.hxx>
48 : #include "cfgitem.hxx"
49 :
50 : using namespace ::cppu;
51 : using namespace ::std;
52 : using namespace ::comphelper;
53 : using namespace ::com::sun::star;
54 : using namespace ::com::sun::star::uno;
55 : using namespace ::com::sun::star::beans;
56 : using namespace ::com::sun::star::lang;
57 : using namespace ::com::sun::star::formula;
58 : using namespace ::com::sun::star::view;
59 : using namespace ::com::sun::star::script;
60 :
61 0 : SmPrintUIOptions::SmPrintUIOptions()
62 : {
63 0 : ResStringArray aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS ) );
64 : SAL_WARN_IF( aLocalizedStrings.Count() < 18, "starmath", "resource incomplete" );
65 0 : if( aLocalizedStrings.Count() < 9 ) // bad resource ?
66 0 : return;
67 :
68 0 : SmModule *pp = SM_MOD();
69 0 : SmMathConfig *pConfig = pp->GetConfig();
70 : SAL_WARN_IF( !pConfig, "starmath", "SmConfig not found" );
71 0 : if (!pConfig)
72 0 : return;
73 :
74 0 : sal_Int32 nNumProps = 10, nIdx=0;
75 :
76 : // create sequence of print UI options
77 : // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
78 0 : m_aUIProperties.realloc( nNumProps );
79 :
80 : // load the math PrinterOptions into the custom tab
81 0 : m_aUIProperties[nIdx].Name = "OptionsUIFile";
82 0 : m_aUIProperties[nIdx++].Value <<= OUString("modules/smath/ui/printeroptions.ui");
83 :
84 : // create Section for formula (results in an extra tab page in dialog)
85 0 : SvtModuleOptions aOpt;
86 : OUString aAppGroupname(
87 : aLocalizedStrings.GetString( 0 ).
88 0 : replaceFirst( "%s", aOpt.GetModuleName( SvtModuleOptions::EModule::MATH ) ) );
89 0 : m_aUIProperties[nIdx++].Value = setGroupControlOpt("tabcontrol-page2", aAppGroupname, ".HelpID:vcl:PrintDialog:TabPage:AppPage");
90 :
91 : // create subgroup for print options
92 0 : m_aUIProperties[nIdx++].Value = setSubgroupControlOpt("contents", aLocalizedStrings.GetString(1), OUString());
93 :
94 : // create a bool option for title row (matches to SID_PRINTTITLE)
95 0 : m_aUIProperties[nIdx++].Value = setBoolControlOpt("title", aLocalizedStrings.GetString( 2 ),
96 : ".HelpID:vcl:PrintDialog:TitleRow:CheckBox",
97 : PRTUIOPT_TITLE_ROW,
98 0 : pConfig->IsPrintTitle());
99 : // create a bool option for formula text (matches to SID_PRINTTEXT)
100 0 : m_aUIProperties[nIdx++].Value = setBoolControlOpt("formulatext", aLocalizedStrings.GetString( 3 ),
101 : ".HelpID:vcl:PrintDialog:FormulaText:CheckBox",
102 : PRTUIOPT_FORMULA_TEXT,
103 0 : pConfig->IsPrintFormulaText());
104 : // create a bool option for border (matches to SID_PRINTFRAME)
105 0 : m_aUIProperties[nIdx++].Value = setBoolControlOpt("borders", aLocalizedStrings.GetString( 4 ),
106 : ".HelpID:vcl:PrintDialog:Border:CheckBox",
107 : PRTUIOPT_BORDER,
108 0 : pConfig->IsPrintFrame());
109 :
110 : // create subgroup for print format
111 0 : m_aUIProperties[nIdx++].Value = setSubgroupControlOpt("size", aLocalizedStrings.GetString(5), OUString());
112 :
113 : // create a radio button group for print format (matches to SID_PRINTSIZE)
114 : Sequence< OUString > aChoices{
115 : aLocalizedStrings.GetString( 6 ),
116 : aLocalizedStrings.GetString( 7 ),
117 : aLocalizedStrings.GetString( 8 )
118 0 : };
119 : Sequence< OUString > aHelpIds{
120 : ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0",
121 : ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1",
122 : ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2"
123 0 : };
124 : Sequence< OUString > aWidgetIds{
125 : "originalsize",
126 : "fittopage",
127 : "scaling"
128 0 : };
129 0 : OUString aPrintFormatProp( PRTUIOPT_PRINT_FORMAT );
130 0 : m_aUIProperties[nIdx++].Value = setChoiceRadiosControlOpt(aWidgetIds, OUString(),
131 : aHelpIds,
132 : aPrintFormatProp,
133 0 : aChoices, static_cast< sal_Int32 >(pConfig->GetPrintSize())
134 0 : );
135 :
136 : // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
137 0 : vcl::PrinterOptionsHelper::UIControlOptions aRangeOpt( aPrintFormatProp, 2, true );
138 0 : m_aUIProperties[nIdx++].Value = setRangeControlOpt("scalingspin", OUString(),
139 : ".HelpID:vcl:PrintDialog:PrintScale:NumericField",
140 : PRTUIOPT_PRINT_SCALE,
141 0 : pConfig->GetPrintZoomFactor(), // initial value
142 : 10, // min value
143 : 1000, // max value
144 0 : aRangeOpt);
145 :
146 0 : Sequence< PropertyValue > aHintNoLayoutPage( 1 );
147 0 : aHintNoLayoutPage[0].Name = "HintNoLayoutPage";
148 0 : aHintNoLayoutPage[0].Value = makeAny( sal_True );
149 0 : m_aUIProperties[nIdx++].Value <<= aHintNoLayoutPage;
150 :
151 0 : assert(nIdx == nNumProps);
152 : }
153 :
154 :
155 :
156 :
157 : // class SmModel
158 :
159 :
160 : // values from com/sun/star/beans/PropertyAttribute
161 : #define PROPERTY_NONE 0
162 :
163 : enum SmModelPropertyHandles
164 : {
165 : HANDLE_FORMULA,
166 : HANDLE_FONT_NAME_VARIABLES,
167 : HANDLE_FONT_NAME_FUNCTIONS,
168 : HANDLE_FONT_NAME_NUMBERS,
169 : HANDLE_FONT_NAME_TEXT,
170 : HANDLE_CUSTOM_FONT_NAME_SERIF,
171 : HANDLE_CUSTOM_FONT_NAME_SANS,
172 : HANDLE_CUSTOM_FONT_NAME_FIXED,
173 : HANDLE_CUSTOM_FONT_FIXED_POSTURE,
174 : HANDLE_CUSTOM_FONT_FIXED_WEIGHT,
175 : HANDLE_CUSTOM_FONT_SANS_POSTURE,
176 : HANDLE_CUSTOM_FONT_SANS_WEIGHT,
177 : HANDLE_CUSTOM_FONT_SERIF_POSTURE,
178 : HANDLE_CUSTOM_FONT_SERIF_WEIGHT,
179 : HANDLE_FONT_VARIABLES_POSTURE,
180 : HANDLE_FONT_VARIABLES_WEIGHT,
181 : HANDLE_FONT_FUNCTIONS_POSTURE,
182 : HANDLE_FONT_FUNCTIONS_WEIGHT,
183 : HANDLE_FONT_NUMBERS_POSTURE,
184 : HANDLE_FONT_NUMBERS_WEIGHT,
185 : HANDLE_FONT_TEXT_POSTURE,
186 : HANDLE_FONT_TEXT_WEIGHT,
187 : HANDLE_BASE_FONT_HEIGHT,
188 : HANDLE_RELATIVE_FONT_HEIGHT_TEXT,
189 : HANDLE_RELATIVE_FONT_HEIGHT_INDICES,
190 : HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS,
191 : HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS,
192 : HANDLE_RELATIVE_FONT_HEIGHT_LIMITS,
193 : HANDLE_IS_TEXT_MODE,
194 : HANDLE_GREEK_CHAR_STYLE,
195 : HANDLE_ALIGNMENT,
196 : HANDLE_RELATIVE_SPACING,
197 : HANDLE_RELATIVE_LINE_SPACING,
198 : HANDLE_RELATIVE_ROOT_SPACING,
199 : HANDLE_RELATIVE_INDEX_SUPERSCRIPT,
200 : HANDLE_RELATIVE_INDEX_SUBSCRIPT,
201 : HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT,
202 : HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH,
203 : HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH,
204 : HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT,
205 : HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE,
206 : HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE,
207 : HANDLE_RELATIVE_BRACKET_EXCESS_SIZE,
208 : HANDLE_RELATIVE_BRACKET_DISTANCE,
209 : HANDLE_IS_SCALE_ALL_BRACKETS,
210 : HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE,
211 : HANDLE_RELATIVE_MATRIX_LINE_SPACING,
212 : HANDLE_RELATIVE_MATRIX_COLUMN_SPACING,
213 : HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT,
214 : HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT,
215 : HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE,
216 : HANDLE_RELATIVE_OPERATOR_SPACING,
217 : HANDLE_LEFT_MARGIN,
218 : HANDLE_RIGHT_MARGIN,
219 : HANDLE_TOP_MARGIN,
220 : HANDLE_BOTTOM_MARGIN,
221 : HANDLE_PRINTER_NAME,
222 : HANDLE_PRINTER_SETUP,
223 : HANDLE_SYMBOLS,
224 : HANDLE_USED_SYMBOLS,
225 : HANDLE_BASIC_LIBRARIES,
226 : HANDLE_RUNTIME_UID,
227 : HANDLE_LOAD_READONLY, // Security Options
228 : HANDLE_DIALOG_LIBRARIES, // #i73329#
229 : HANDLE_BASELINE,
230 : HANDLE_INTEROP_GRAB_BAG,
231 : };
232 :
233 340 : static PropertySetInfo * lcl_createModelPropertyInfo ()
234 : {
235 : static PropertyMapEntry aModelPropertyInfoMap[] =
236 : {
237 14 : { OUString("Alignment") , HANDLE_ALIGNMENT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 },
238 14 : { OUString("BaseFontHeight") , HANDLE_BASE_FONT_HEIGHT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 },
239 14 : { OUString("BasicLibraries") , HANDLE_BASIC_LIBRARIES , cppu::UnoType<script::XLibraryContainer>::get(), PropertyAttribute::READONLY, 0 },
240 14 : { OUString("BottomMargin") , HANDLE_BOTTOM_MARGIN , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_BOTTOMSPACE },
241 14 : { OUString("CustomFontNameFixed") , HANDLE_CUSTOM_FONT_NAME_FIXED , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_FIXED },
242 14 : { OUString("CustomFontNameSans") , HANDLE_CUSTOM_FONT_NAME_SANS , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_SANS },
243 14 : { OUString("CustomFontNameSerif") , HANDLE_CUSTOM_FONT_NAME_SERIF , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_SERIF },
244 14 : { OUString("DialogLibraries") , HANDLE_DIALOG_LIBRARIES , cppu::UnoType<script::XLibraryContainer>::get(), PropertyAttribute::READONLY, 0 },
245 14 : { OUString("FontFixedIsBold") , HANDLE_CUSTOM_FONT_FIXED_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_FIXED },
246 14 : { OUString("FontFixedIsItalic") , HANDLE_CUSTOM_FONT_FIXED_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_FIXED },
247 14 : { OUString("FontFunctionsIsBold") , HANDLE_FONT_FUNCTIONS_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_FUNCTION },
248 14 : { OUString("FontFunctionsIsItalic") , HANDLE_FONT_FUNCTIONS_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_FUNCTION },
249 14 : { OUString("FontNameFunctions") , HANDLE_FONT_NAME_FUNCTIONS , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_FUNCTION },
250 14 : { OUString("FontNameNumbers") , HANDLE_FONT_NAME_NUMBERS , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_NUMBER },
251 14 : { OUString("FontNameText") , HANDLE_FONT_NAME_TEXT , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_TEXT },
252 14 : { OUString("FontNameVariables") , HANDLE_FONT_NAME_VARIABLES , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, FNT_VARIABLE },
253 14 : { OUString("FontNumbersIsBold") , HANDLE_FONT_NUMBERS_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_NUMBER },
254 14 : { OUString("FontNumbersIsItalic") , HANDLE_FONT_NUMBERS_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_NUMBER },
255 14 : { OUString("FontSansIsBold") , HANDLE_CUSTOM_FONT_SANS_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_SANS },
256 14 : { OUString("FontSansIsItalic") , HANDLE_CUSTOM_FONT_SANS_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_SANS },
257 14 : { OUString("FontSerifIsBold") , HANDLE_CUSTOM_FONT_SERIF_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_SERIF },
258 14 : { OUString("FontSerifIsItalic") , HANDLE_CUSTOM_FONT_SERIF_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_SERIF },
259 14 : { OUString("FontTextIsBold") , HANDLE_FONT_TEXT_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_TEXT },
260 14 : { OUString("FontTextIsItalic") , HANDLE_FONT_TEXT_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_TEXT },
261 14 : { OUString("FontVariablesIsBold") , HANDLE_FONT_VARIABLES_WEIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_VARIABLE },
262 14 : { OUString("FontVariablesIsItalic") , HANDLE_FONT_VARIABLES_POSTURE , cppu::UnoType<bool>::get(), PROPERTY_NONE, FNT_VARIABLE },
263 14 : { OUString("Formula") , HANDLE_FORMULA , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
264 14 : { OUString("IsScaleAllBrackets") , HANDLE_IS_SCALE_ALL_BRACKETS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
265 14 : { OUString("IsTextMode") , HANDLE_IS_TEXT_MODE , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
266 14 : { OUString("GreekCharStyle") , HANDLE_GREEK_CHAR_STYLE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 },
267 14 : { OUString("LeftMargin") , HANDLE_LEFT_MARGIN , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_LEFTSPACE },
268 14 : { OUString("PrinterName") , HANDLE_PRINTER_NAME , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
269 14 : { OUString("PrinterSetup") , HANDLE_PRINTER_SETUP , cppu::UnoType<const Sequence < sal_Int8 >>::get(), PROPERTY_NONE, 0 },
270 14 : { OUString("RelativeBracketDistance") , HANDLE_RELATIVE_BRACKET_DISTANCE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_BRACKETSPACE },
271 14 : { OUString("RelativeBracketExcessSize") , HANDLE_RELATIVE_BRACKET_EXCESS_SIZE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_BRACKETSIZE },
272 14 : { OUString("RelativeFontHeightFunctions") , HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, SIZ_FUNCTION },
273 14 : { OUString("RelativeFontHeightIndices") , HANDLE_RELATIVE_FONT_HEIGHT_INDICES , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, SIZ_INDEX },
274 14 : { OUString("RelativeFontHeightLimits") , HANDLE_RELATIVE_FONT_HEIGHT_LIMITS , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, SIZ_LIMITS },
275 14 : { OUString("RelativeFontHeightOperators") , HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, SIZ_OPERATOR },
276 14 : { OUString("RelativeFontHeightText") , HANDLE_RELATIVE_FONT_HEIGHT_TEXT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, SIZ_TEXT },
277 14 : { OUString("RelativeFractionBarExcessLength") , HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_FRACTION },
278 14 : { OUString("RelativeFractionBarLineWeight") , HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_STROKEWIDTH },
279 14 : { OUString("RelativeFractionDenominatorDepth") , HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_DENOMINATOR },
280 14 : { OUString("RelativeFractionNumeratorHeight") , HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_NUMERATOR },
281 14 : { OUString("RelativeIndexSubscript") , HANDLE_RELATIVE_INDEX_SUBSCRIPT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_SUBSCRIPT },
282 14 : { OUString("RelativeIndexSuperscript") , HANDLE_RELATIVE_INDEX_SUPERSCRIPT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_SUPERSCRIPT },
283 14 : { OUString("RelativeLineSpacing") , HANDLE_RELATIVE_LINE_SPACING , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_VERTICAL },
284 14 : { OUString("RelativeLowerLimitDistance") , HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_LOWERLIMIT },
285 14 : { OUString("RelativeMatrixColumnSpacing") , HANDLE_RELATIVE_MATRIX_COLUMN_SPACING , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_MATRIXCOL },
286 14 : { OUString("RelativeMatrixLineSpacing") , HANDLE_RELATIVE_MATRIX_LINE_SPACING , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_MATRIXROW },
287 14 : { OUString("RelativeOperatorExcessSize") , HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_OPERATORSIZE },
288 14 : { OUString("RelativeOperatorSpacing") , HANDLE_RELATIVE_OPERATOR_SPACING , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_OPERATORSPACE },
289 14 : { OUString("RelativeRootSpacing") , HANDLE_RELATIVE_ROOT_SPACING , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_ROOT },
290 14 : { OUString("RelativeScaleBracketExcessSize") , HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_NORMALBRACKETSIZE },
291 14 : { OUString("RelativeSpacing") , HANDLE_RELATIVE_SPACING , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_HORIZONTAL },
292 14 : { OUString("RelativeSymbolMinimumHeight") , HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_ORNAMENTSPACE },
293 14 : { OUString("RelativeSymbolPrimaryHeight") , HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_ORNAMENTSIZE },
294 14 : { OUString("RelativeUpperLimitDistance") , HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_UPPERLIMIT },
295 14 : { OUString("RightMargin") , HANDLE_RIGHT_MARGIN , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_RIGHTSPACE },
296 14 : { OUString("RuntimeUID") , HANDLE_RUNTIME_UID , cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0 },
297 14 : { OUString("Symbols") , HANDLE_SYMBOLS , cppu::UnoType<Sequence < SymbolDescriptor >>::get(), PROPERTY_NONE, 0 },
298 14 : { OUString("UserDefinedSymbolsInUse") , HANDLE_USED_SYMBOLS , cppu::UnoType<Sequence < SymbolDescriptor >>::get(), PropertyAttribute::READONLY, 0 },
299 14 : { OUString("TopMargin") , HANDLE_TOP_MARGIN , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, DIS_TOPSPACE },
300 : // #i33095# Security Options
301 14 : { OUString("LoadReadonly") , HANDLE_LOAD_READONLY , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
302 : // #i972#
303 14 : { OUString("BaseLine") , HANDLE_BASELINE , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 },
304 14 : { OUString("InteropGrabBag") , HANDLE_INTEROP_GRAB_BAG , cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), PROPERTY_NONE, 0 },
305 : { OUString(), 0, css::uno::Type(), 0, 0 }
306 1278 : };
307 340 : PropertySetInfo *pInfo = new PropertySetInfo ( aModelPropertyInfoMap );
308 340 : return pInfo;
309 : }
310 :
311 340 : SmModel::SmModel( SfxObjectShell *pObjSh )
312 : : SfxBaseModel(pObjSh)
313 340 : , PropertySetHelper ( lcl_createModelPropertyInfo () )
314 : {
315 340 : }
316 :
317 646 : SmModel::~SmModel() throw ()
318 : {
319 646 : }
320 :
321 116099 : uno::Any SAL_CALL SmModel::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
322 : {
323 : uno::Any aRet = ::cppu::queryInterface ( rType,
324 : // OWeakObject interfaces
325 : dynamic_cast< XInterface* > ( static_cast< XUnoTunnel* > ( this )),
326 : static_cast< XWeak* > ( this ),
327 : // PropertySetHelper interfaces
328 : static_cast< XPropertySet* > ( this ),
329 : static_cast< XMultiPropertySet* > ( this ),
330 : // my own interfaces
331 : static_cast< XServiceInfo* > ( this ),
332 116099 : static_cast< XRenderable* > ( this ) );
333 116099 : if (!aRet.hasValue())
334 88998 : aRet = SfxBaseModel::queryInterface ( rType );
335 116099 : return aRet;
336 : }
337 :
338 272744 : void SAL_CALL SmModel::acquire() throw()
339 : {
340 272744 : OWeakObject::acquire();
341 272744 : }
342 :
343 272727 : void SAL_CALL SmModel::release() throw()
344 : {
345 272727 : OWeakObject::release();
346 272727 : }
347 :
348 36 : uno::Sequence< uno::Type > SAL_CALL SmModel::getTypes( ) throw(uno::RuntimeException, std::exception)
349 : {
350 36 : SolarMutexGuard aGuard;
351 36 : uno::Sequence< uno::Type > aTypes = SfxBaseModel::getTypes();
352 36 : sal_Int32 nLen = aTypes.getLength();
353 36 : aTypes.realloc(nLen + 4);
354 36 : uno::Type* pTypes = aTypes.getArray();
355 36 : pTypes[nLen++] = cppu::UnoType<XServiceInfo>::get();
356 36 : pTypes[nLen++] = cppu::UnoType<XPropertySet>::get();
357 36 : pTypes[nLen++] = cppu::UnoType<XMultiPropertySet>::get();
358 36 : pTypes[nLen++] = cppu::UnoType<XRenderable>::get();
359 :
360 36 : return aTypes;
361 : }
362 :
363 : namespace
364 : {
365 : class theSmModelUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSmModelUnoTunnelId> {};
366 : }
367 :
368 5276 : const uno::Sequence< sal_Int8 > & SmModel::getUnoTunnelId()
369 : {
370 5276 : return theSmModelUnoTunnelId::get().getSeq();
371 : }
372 :
373 3020 : sal_Int64 SAL_CALL SmModel::getSomething( const uno::Sequence< sal_Int8 >& rId )
374 : throw(uno::RuntimeException, std::exception)
375 : {
376 6040 : if( rId.getLength() == 16
377 9060 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
378 6040 : rId.getConstArray(), 16 ) )
379 : {
380 2256 : return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
381 : }
382 :
383 764 : return SfxBaseModel::getSomething( rId );
384 : }
385 :
386 3 : static sal_Int16 lcl_AnyToINT16(const uno::Any& rAny)
387 : {
388 3 : uno::TypeClass eType = rAny.getValueType().getTypeClass();
389 :
390 3 : sal_Int16 nRet = 0;
391 3 : if( eType == uno::TypeClass_DOUBLE )
392 0 : nRet = (sal_Int16)*static_cast<double const *>(rAny.getValue());
393 3 : else if( eType == uno::TypeClass_FLOAT )
394 0 : nRet = (sal_Int16)*static_cast<float const *>(rAny.getValue());
395 : else
396 3 : rAny >>= nRet;
397 3 : return nRet;
398 : }
399 :
400 2 : OUString SmModel::getImplementationName() throw( uno::RuntimeException, std::exception )
401 : {
402 2 : return OUString("com.sun.star.comp.Math.FormulaDocument");
403 : }
404 :
405 579 : sal_Bool SmModel::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
406 : {
407 579 : return cppu::supportsService(this, rServiceName);
408 : }
409 :
410 1732 : uno::Sequence< OUString > SmModel::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
411 : {
412 : return uno::Sequence<OUString>{
413 : "com.sun.star.document.OfficeDocument",
414 : "com.sun.star.formula.FormulaProperties"
415 1732 : };
416 : }
417 :
418 178 : void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* pValues)
419 : throw (RuntimeException, UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, std::exception)
420 : {
421 178 : SolarMutexGuard aGuard;
422 :
423 178 : SmDocShell *pDocSh = static_cast < SmDocShell * > (GetObjectShell());
424 :
425 178 : if ( NULL == pDocSh )
426 0 : throw UnknownPropertyException();
427 :
428 356 : SmFormat aFormat = pDocSh->GetFormat();
429 :
430 356 : for (; *ppEntries; ppEntries++, pValues++ )
431 : {
432 178 : if ((*ppEntries)->mnAttributes & PropertyAttribute::READONLY)
433 0 : throw PropertyVetoException();
434 :
435 178 : switch ( (*ppEntries)->mnHandle )
436 : {
437 : case HANDLE_FORMULA:
438 : {
439 6 : OUString aText;
440 6 : *pValues >>= aText;
441 6 : pDocSh->SetText(aText);
442 : }
443 6 : break;
444 : case HANDLE_FONT_NAME_VARIABLES :
445 : case HANDLE_FONT_NAME_FUNCTIONS :
446 : case HANDLE_FONT_NAME_NUMBERS :
447 : case HANDLE_FONT_NAME_TEXT :
448 : case HANDLE_CUSTOM_FONT_NAME_SERIF :
449 : case HANDLE_CUSTOM_FONT_NAME_SANS :
450 : case HANDLE_CUSTOM_FONT_NAME_FIXED :
451 : {
452 21 : OUString sFontName;
453 21 : *pValues >>= sFontName;
454 21 : if(sFontName.isEmpty())
455 0 : throw IllegalArgumentException();
456 :
457 21 : if(OUString(aFormat.GetFont((*ppEntries)->mnMemberId).GetName()) != sFontName)
458 : {
459 7 : const SmFace rOld = aFormat.GetFont((*ppEntries)->mnMemberId);
460 :
461 14 : SmFace aSet( sFontName, rOld.GetSize() );
462 7 : aSet.SetBorderWidth( rOld.GetBorderWidth() );
463 7 : aSet.SetAlign( ALIGN_BASELINE );
464 14 : aFormat.SetFont( (*ppEntries)->mnMemberId, aSet );
465 21 : }
466 : }
467 21 : break;
468 : case HANDLE_CUSTOM_FONT_FIXED_POSTURE:
469 : case HANDLE_CUSTOM_FONT_SANS_POSTURE :
470 : case HANDLE_CUSTOM_FONT_SERIF_POSTURE:
471 : case HANDLE_FONT_VARIABLES_POSTURE :
472 : case HANDLE_FONT_FUNCTIONS_POSTURE :
473 : case HANDLE_FONT_NUMBERS_POSTURE :
474 : case HANDLE_FONT_TEXT_POSTURE :
475 : {
476 21 : if((*pValues).getValueType() != cppu::UnoType<bool>::get())
477 0 : throw IllegalArgumentException();
478 21 : bool bVal = *static_cast<sal_Bool const *>((*pValues).getValue());
479 21 : vcl::Font aNewFont(aFormat.GetFont((*ppEntries)->mnMemberId));
480 21 : aNewFont.SetItalic((bVal) ? ITALIC_NORMAL : ITALIC_NONE);
481 21 : aFormat.SetFont((*ppEntries)->mnMemberId, aNewFont);
482 : }
483 21 : break;
484 : case HANDLE_CUSTOM_FONT_FIXED_WEIGHT :
485 : case HANDLE_CUSTOM_FONT_SANS_WEIGHT :
486 : case HANDLE_CUSTOM_FONT_SERIF_WEIGHT :
487 : case HANDLE_FONT_VARIABLES_WEIGHT :
488 : case HANDLE_FONT_FUNCTIONS_WEIGHT :
489 : case HANDLE_FONT_NUMBERS_WEIGHT :
490 : case HANDLE_FONT_TEXT_WEIGHT :
491 : {
492 21 : if((*pValues).getValueType() != cppu::UnoType<bool>::get())
493 0 : throw IllegalArgumentException();
494 21 : bool bVal = *static_cast<sal_Bool const *>((*pValues).getValue());
495 21 : vcl::Font aNewFont(aFormat.GetFont((*ppEntries)->mnMemberId));
496 21 : aNewFont.SetWeight((bVal) ? WEIGHT_BOLD : WEIGHT_NORMAL);
497 21 : aFormat.SetFont((*ppEntries)->mnMemberId, aNewFont);
498 : }
499 21 : break;
500 : case HANDLE_BASE_FONT_HEIGHT :
501 : {
502 : // Point!
503 3 : sal_Int16 nVal = lcl_AnyToINT16(*pValues);
504 3 : if(nVal < 1)
505 0 : throw IllegalArgumentException();
506 3 : Size aSize = aFormat.GetBaseSize();
507 3 : nVal *= 20;
508 3 : nVal = static_cast < sal_Int16 > ( convertTwipToMm100(nVal) );
509 3 : aSize.Height() = nVal;
510 3 : aFormat.SetBaseSize(aSize);
511 :
512 : // apply base size to fonts
513 3 : const Size aTmp( aFormat.GetBaseSize() );
514 27 : for (sal_uInt16 i = FNT_BEGIN; i <= FNT_END; i++)
515 24 : aFormat.SetFontSize(i, aTmp);
516 : }
517 3 : break;
518 : case HANDLE_RELATIVE_FONT_HEIGHT_TEXT :
519 : case HANDLE_RELATIVE_FONT_HEIGHT_INDICES :
520 : case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS :
521 : case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS :
522 : case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS :
523 : {
524 15 : sal_Int16 nVal = 0;
525 15 : *pValues >>= nVal;
526 15 : if(nVal < 1)
527 0 : throw IllegalArgumentException();
528 15 : aFormat.SetRelSize((*ppEntries)->mnMemberId, nVal);
529 : }
530 15 : break;
531 :
532 : case HANDLE_IS_TEXT_MODE :
533 : {
534 3 : aFormat.SetTextmode(*static_cast<sal_Bool const *>((*pValues).getValue()));
535 : }
536 3 : break;
537 :
538 : case HANDLE_GREEK_CHAR_STYLE :
539 : {
540 2 : sal_Int16 nVal = 0;
541 2 : *pValues >>= nVal;
542 2 : if (nVal < 0 || nVal > 2)
543 0 : throw IllegalArgumentException();
544 2 : aFormat.SetGreekCharStyle( nVal );
545 : }
546 2 : break;
547 :
548 : case HANDLE_ALIGNMENT :
549 : {
550 : // SmHorAlign uses the same values as HorizontalAlignment
551 3 : sal_Int16 nVal = 0;
552 3 : *pValues >>= nVal;
553 3 : if(nVal < 0 || nVal > 2)
554 0 : throw IllegalArgumentException();
555 3 : aFormat.SetHorAlign((SmHorAlign)nVal);
556 : }
557 3 : break;
558 :
559 : case HANDLE_RELATIVE_SPACING :
560 : case HANDLE_RELATIVE_LINE_SPACING :
561 : case HANDLE_RELATIVE_ROOT_SPACING :
562 : case HANDLE_RELATIVE_INDEX_SUPERSCRIPT :
563 : case HANDLE_RELATIVE_INDEX_SUBSCRIPT :
564 : case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT :
565 : case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH:
566 : case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH:
567 : case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT :
568 : case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE :
569 : case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE :
570 : case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE :
571 : case HANDLE_RELATIVE_BRACKET_DISTANCE :
572 : case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE :
573 : case HANDLE_RELATIVE_MATRIX_LINE_SPACING :
574 : case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING :
575 : case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT :
576 : case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT :
577 : case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE :
578 : case HANDLE_RELATIVE_OPERATOR_SPACING :
579 : case HANDLE_LEFT_MARGIN :
580 : case HANDLE_RIGHT_MARGIN :
581 : case HANDLE_TOP_MARGIN :
582 : case HANDLE_BOTTOM_MARGIN :
583 : {
584 74 : sal_Int16 nVal = 0;
585 74 : *pValues >>= nVal;
586 74 : if(nVal < 0)
587 0 : throw IllegalArgumentException();
588 74 : aFormat.SetDistance((*ppEntries)->mnMemberId, nVal);
589 : }
590 74 : break;
591 : case HANDLE_IS_SCALE_ALL_BRACKETS :
592 3 : aFormat.SetScaleNormalBrackets(*static_cast<sal_Bool const *>((*pValues).getValue()));
593 3 : break;
594 : case HANDLE_PRINTER_NAME:
595 : {
596 : // embedded documents just ignore this property for now
597 2 : if ( pDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
598 : {
599 0 : SfxPrinter *pPrinter = pDocSh->GetPrinter ( );
600 0 : if (pPrinter)
601 : {
602 0 : OUString sPrinterName;
603 0 : if (*pValues >>= sPrinterName )
604 : {
605 0 : if ( !sPrinterName.isEmpty() )
606 : {
607 0 : VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
608 0 : if (pNewPrinter->IsKnown())
609 0 : pDocSh->SetPrinter ( pNewPrinter );
610 : else
611 0 : pNewPrinter.disposeAndClear();
612 : }
613 : }
614 : else
615 0 : throw IllegalArgumentException();
616 : }
617 : }
618 : }
619 2 : break;
620 : case HANDLE_PRINTER_SETUP:
621 : {
622 0 : Sequence < sal_Int8 > aSequence;
623 0 : if ( *pValues >>= aSequence )
624 : {
625 0 : sal_uInt32 nSize = aSequence.getLength();
626 0 : SvMemoryStream aStream ( aSequence.getArray(), nSize, StreamMode::READ );
627 0 : aStream.Seek ( STREAM_SEEK_TO_BEGIN );
628 : static sal_uInt16 const nRange[] =
629 : {
630 : SID_PRINTSIZE, SID_PRINTSIZE,
631 : SID_PRINTZOOM, SID_PRINTZOOM,
632 : SID_PRINTTITLE, SID_PRINTTITLE,
633 : SID_PRINTTEXT, SID_PRINTTEXT,
634 : SID_PRINTFRAME, SID_PRINTFRAME,
635 : SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
636 : SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
637 : 0
638 : };
639 0 : SfxItemSet *pItemSet = new SfxItemSet( SmDocShell::GetPool(), nRange );
640 0 : SmModule *pp = SM_MOD();
641 0 : pp->GetConfig()->ConfigToItemSet(*pItemSet);
642 0 : VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
643 :
644 0 : pDocSh->SetPrinter( pPrinter );
645 : }
646 : else
647 0 : throw IllegalArgumentException();
648 : }
649 0 : break;
650 : case HANDLE_SYMBOLS:
651 : {
652 : // this is set
653 0 : Sequence < SymbolDescriptor > aSequence;
654 0 : if ( *pValues >>= aSequence )
655 : {
656 0 : sal_uInt32 nSize = aSequence.getLength();
657 0 : SmModule *pp = SM_MOD();
658 0 : SmSymbolManager &rManager = pp->GetSymbolManager();
659 0 : SymbolDescriptor *pDescriptor = aSequence.getArray();
660 0 : for (sal_uInt32 i = 0; i < nSize ; i++, pDescriptor++)
661 : {
662 0 : vcl::Font aFont;
663 0 : aFont.SetName ( pDescriptor->sFontName );
664 0 : aFont.SetCharSet ( static_cast < rtl_TextEncoding > (pDescriptor->nCharSet) );
665 0 : aFont.SetFamily ( static_cast < FontFamily > (pDescriptor->nFamily ) );
666 0 : aFont.SetPitch ( static_cast < FontPitch > (pDescriptor->nPitch ) );
667 0 : aFont.SetWeight ( static_cast < FontWeight > (pDescriptor->nWeight ) );
668 0 : aFont.SetItalic ( static_cast < FontItalic > (pDescriptor->nItalic ) );
669 : SmSym aSymbol ( pDescriptor->sName, aFont, static_cast < sal_Unicode > (pDescriptor->nCharacter),
670 0 : pDescriptor->sSymbolSet );
671 0 : aSymbol.SetExportName ( pDescriptor->sExportName );
672 0 : aSymbol.SetDocSymbol( true );
673 0 : rManager.AddOrReplaceSymbol ( aSymbol );
674 0 : }
675 : }
676 : else
677 0 : throw IllegalArgumentException();
678 : }
679 0 : break;
680 : // #i33095# Security Options
681 : case HANDLE_LOAD_READONLY :
682 : {
683 2 : if ( (*pValues).getValueType() != cppu::UnoType<bool>::get() )
684 0 : throw IllegalArgumentException();
685 2 : bool bReadonly = false;
686 2 : if ( *pValues >>= bReadonly )
687 2 : pDocSh->SetLoadReadonly( bReadonly );
688 2 : break;
689 : }
690 : case HANDLE_INTEROP_GRAB_BAG:
691 0 : setGrabBagItem(*pValues);
692 0 : break;
693 : }
694 : }
695 :
696 178 : pDocSh->SetFormat( aFormat );
697 :
698 : // #i67283# since about all of the above changes are likely to change
699 : // the formula size we have to recalculate the vis-area now
700 356 : pDocSh->SetVisArea( Rectangle( Point(0, 0), pDocSh->GetSize() ) );
701 178 : }
702 :
703 35506 : void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValue )
704 : throw (RuntimeException, UnknownPropertyException, WrappedTargetException, std::exception)
705 : {
706 35506 : SmDocShell *pDocSh = static_cast < SmDocShell * > (GetObjectShell());
707 :
708 35506 : if ( NULL == pDocSh )
709 0 : throw UnknownPropertyException();
710 :
711 35506 : const SmFormat & aFormat = pDocSh->GetFormat();
712 :
713 71012 : for (; *ppEntries; ppEntries++, pValue++ )
714 : {
715 35506 : switch ( (*ppEntries)->mnHandle )
716 : {
717 : case HANDLE_FORMULA:
718 117 : *pValue <<= OUString(pDocSh->GetText());
719 117 : break;
720 : case HANDLE_FONT_NAME_VARIABLES :
721 : case HANDLE_FONT_NAME_FUNCTIONS :
722 : case HANDLE_FONT_NAME_NUMBERS :
723 : case HANDLE_FONT_NAME_TEXT :
724 : case HANDLE_CUSTOM_FONT_NAME_SERIF :
725 : case HANDLE_CUSTOM_FONT_NAME_SANS :
726 : case HANDLE_CUSTOM_FONT_NAME_FIXED :
727 : {
728 3941 : const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
729 3941 : *pValue <<= OUString(rFace.GetName());
730 : }
731 3941 : break;
732 : case HANDLE_CUSTOM_FONT_FIXED_POSTURE:
733 : case HANDLE_CUSTOM_FONT_SANS_POSTURE :
734 : case HANDLE_CUSTOM_FONT_SERIF_POSTURE:
735 : case HANDLE_FONT_VARIABLES_POSTURE :
736 : case HANDLE_FONT_FUNCTIONS_POSTURE :
737 : case HANDLE_FONT_NUMBERS_POSTURE :
738 : case HANDLE_FONT_TEXT_POSTURE :
739 : {
740 3941 : const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
741 3941 : bool bVal = IsItalic( rFace );
742 3941 : (*pValue).setValue(&bVal, (*ppEntries)->maType);
743 : }
744 3941 : break;
745 : case HANDLE_CUSTOM_FONT_FIXED_WEIGHT :
746 : case HANDLE_CUSTOM_FONT_SANS_WEIGHT :
747 : case HANDLE_CUSTOM_FONT_SERIF_WEIGHT :
748 : case HANDLE_FONT_VARIABLES_WEIGHT :
749 : case HANDLE_FONT_FUNCTIONS_WEIGHT :
750 : case HANDLE_FONT_NUMBERS_WEIGHT :
751 : case HANDLE_FONT_TEXT_WEIGHT :
752 : {
753 3941 : const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
754 3941 : bool bVal = IsBold( rFace ); // bold?
755 3941 : (*pValue).setValue(&bVal, (*ppEntries)->maType);
756 : }
757 3941 : break;
758 : case HANDLE_BASE_FONT_HEIGHT :
759 : {
760 : // Point!
761 563 : sal_Int16 nVal = static_cast < sal_Int16 > (aFormat.GetBaseSize().Height());
762 563 : nVal = static_cast < sal_Int16 > (convertMm100ToTwip(nVal));
763 563 : nVal = (nVal + 10) / 20;
764 563 : *pValue <<= nVal;
765 : }
766 563 : break;
767 : case HANDLE_RELATIVE_FONT_HEIGHT_TEXT :
768 : case HANDLE_RELATIVE_FONT_HEIGHT_INDICES :
769 : case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS :
770 : case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS :
771 : case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS :
772 2815 : *pValue <<= (sal_Int16) aFormat.GetRelSize((*ppEntries)->mnMemberId);
773 2815 : break;
774 :
775 : case HANDLE_IS_TEXT_MODE :
776 : {
777 563 : sal_Bool bVal = aFormat.IsTextmode();
778 563 : (*pValue).setValue(&bVal, cppu::UnoType<bool>::get());
779 : }
780 563 : break;
781 :
782 : case HANDLE_GREEK_CHAR_STYLE :
783 561 : *pValue <<= (sal_Int16)aFormat.GetGreekCharStyle();
784 561 : break;
785 :
786 : case HANDLE_ALIGNMENT :
787 : // SmHorAlign uses the same values as HorizontalAlignment
788 563 : *pValue <<= (sal_Int16)aFormat.GetHorAlign();
789 563 : break;
790 :
791 : case HANDLE_RELATIVE_SPACING :
792 : case HANDLE_RELATIVE_LINE_SPACING :
793 : case HANDLE_RELATIVE_ROOT_SPACING :
794 : case HANDLE_RELATIVE_INDEX_SUPERSCRIPT :
795 : case HANDLE_RELATIVE_INDEX_SUBSCRIPT :
796 : case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT :
797 : case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH:
798 : case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH:
799 : case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT :
800 : case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE :
801 : case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE :
802 : case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE :
803 : case HANDLE_RELATIVE_BRACKET_DISTANCE :
804 : case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE :
805 : case HANDLE_RELATIVE_MATRIX_LINE_SPACING :
806 : case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING :
807 : case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT :
808 : case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT :
809 : case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE :
810 : case HANDLE_RELATIVE_OPERATOR_SPACING :
811 : case HANDLE_LEFT_MARGIN :
812 : case HANDLE_RIGHT_MARGIN :
813 : case HANDLE_TOP_MARGIN :
814 : case HANDLE_BOTTOM_MARGIN :
815 13512 : *pValue <<= (sal_Int16)aFormat.GetDistance((*ppEntries)->mnMemberId);
816 13512 : break;
817 : case HANDLE_IS_SCALE_ALL_BRACKETS :
818 : {
819 563 : sal_Bool bVal = aFormat.IsScaleNormalBrackets();
820 563 : (*pValue).setValue(&bVal, cppu::UnoType<bool>::get());
821 : }
822 563 : break;
823 : case HANDLE_PRINTER_NAME:
824 : {
825 561 : SfxPrinter *pPrinter = pDocSh->GetPrinter ( );
826 561 : *pValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString();
827 : }
828 561 : break;
829 : case HANDLE_PRINTER_SETUP:
830 : {
831 561 : SfxPrinter *pPrinter = pDocSh->GetPrinter ();
832 561 : if (pPrinter)
833 : {
834 0 : SvMemoryStream aStream;
835 0 : pPrinter->Store( aStream );
836 0 : aStream.Seek ( STREAM_SEEK_TO_END );
837 0 : sal_uInt32 nSize = aStream.Tell();
838 0 : aStream.Seek ( STREAM_SEEK_TO_BEGIN );
839 0 : Sequence < sal_Int8 > aSequence ( nSize );
840 0 : aStream.Read ( aSequence.getArray(), nSize );
841 0 : *pValue <<= aSequence;
842 : }
843 : }
844 561 : break;
845 : case HANDLE_SYMBOLS:
846 : case HANDLE_USED_SYMBOLS:
847 : {
848 1122 : const bool bUsedSymbolsOnly = (*ppEntries)->mnHandle == HANDLE_USED_SYMBOLS;
849 1122 : const std::set< OUString > &rUsedSymbols = pDocSh->GetUsedSymbols();
850 :
851 : // this is get
852 1122 : SmModule *pp = SM_MOD();
853 1122 : const SmSymbolManager &rManager = pp->GetSymbolManager();
854 1122 : vector < const SmSym * > aVector;
855 :
856 2244 : const SymbolPtrVec_t aSymbols( rManager.GetSymbols() );
857 1122 : size_t nCount = 0;
858 135762 : for (size_t i = 0; i < aSymbols.size(); ++i)
859 : {
860 134640 : const SmSym * pSymbol = aSymbols[ i ];
861 403920 : if (pSymbol && !pSymbol->IsPredefined() &&
862 0 : (!bUsedSymbolsOnly ||
863 134640 : rUsedSymbols.find( pSymbol->GetName() ) != rUsedSymbols.end()))
864 : {
865 0 : aVector.push_back ( pSymbol );
866 0 : nCount++;
867 : }
868 : }
869 2244 : Sequence < SymbolDescriptor > aSequence ( nCount );
870 1122 : SymbolDescriptor * pDescriptor = aSequence.getArray();
871 :
872 1122 : vector < const SmSym * >::const_iterator aIter = aVector.begin(), aEnd = aVector.end();
873 1122 : for(; aIter != aEnd; pDescriptor++, ++aIter)
874 : {
875 0 : pDescriptor->sName = (*aIter)->GetName();
876 0 : pDescriptor->sExportName = (*aIter)->GetExportName();
877 0 : pDescriptor->sSymbolSet = (*aIter)->GetSymbolSetName();
878 0 : pDescriptor->nCharacter = static_cast < sal_Int32 > ((*aIter)->GetCharacter());
879 :
880 0 : vcl::Font rFont = (*aIter)->GetFace();
881 0 : pDescriptor->sFontName = rFont.GetName();
882 0 : pDescriptor->nCharSet = sal::static_int_cast< sal_Int16 >(rFont.GetCharSet());
883 0 : pDescriptor->nFamily = sal::static_int_cast< sal_Int16 >(rFont.GetFamily());
884 0 : pDescriptor->nPitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());
885 0 : pDescriptor->nWeight = sal::static_int_cast< sal_Int16 >(rFont.GetWeight());
886 0 : pDescriptor->nItalic = sal::static_int_cast< sal_Int16 >(rFont.GetItalic());
887 0 : }
888 2244 : *pValue <<= aSequence;
889 : }
890 1122 : break;
891 : case HANDLE_BASIC_LIBRARIES:
892 0 : *pValue <<= pDocSh->GetBasicContainer();
893 0 : break;
894 : case HANDLE_DIALOG_LIBRARIES:
895 0 : *pValue <<= pDocSh->GetDialogContainer();
896 0 : break;
897 : case HANDLE_RUNTIME_UID:
898 499 : *pValue <<= getRuntimeUID();
899 499 : break;
900 : // #i33095# Security Options
901 : case HANDLE_LOAD_READONLY :
902 : {
903 561 : *pValue <<= pDocSh->IsLoadReadonly();
904 561 : break;
905 : }
906 : // #i972#
907 : case HANDLE_BASELINE:
908 : {
909 561 : if ( !pDocSh->pTree )
910 0 : pDocSh->Parse();
911 561 : if ( pDocSh->pTree )
912 : {
913 561 : if ( !pDocSh->IsFormulaArranged() )
914 0 : pDocSh->ArrangeFormula();
915 :
916 561 : *pValue <<= static_cast<sal_Int32>( pDocSh->pTree->GetFormulaBaseline() );
917 : }
918 561 : break;
919 : }
920 : case HANDLE_INTEROP_GRAB_BAG:
921 561 : getGrabBagItem(*pValue);
922 561 : break;
923 : }
924 : }
925 35506 : }
926 :
927 :
928 :
929 0 : sal_Int32 SAL_CALL SmModel::getRendererCount(
930 : const uno::Any& /*rSelection*/,
931 : const uno::Sequence< beans::PropertyValue >& /*xOptions*/ )
932 : throw (IllegalArgumentException, RuntimeException, std::exception)
933 : {
934 0 : SolarMutexGuard aGuard;
935 0 : return 1;
936 : }
937 :
938 :
939 0 : static Size lcl_GuessPaperSize()
940 : {
941 0 : Size aRes;
942 0 : const LocaleDataWrapper& rLocWrp( AllSettings().GetLocaleDataWrapper() );
943 0 : if( MEASURE_METRIC == rLocWrp.getMeasurementSystemEnum() )
944 : {
945 : // in 100th mm
946 0 : PaperInfo aInfo( PAPER_A4 );
947 0 : aRes.Width() = aInfo.getWidth();
948 0 : aRes.Height() = aInfo.getHeight();
949 : }
950 : else
951 : {
952 : // in 100th mm
953 0 : PaperInfo aInfo( PAPER_LETTER );
954 0 : aRes.Width() = aInfo.getWidth();
955 0 : aRes.Height() = aInfo.getHeight();
956 : }
957 0 : return aRes;
958 : }
959 :
960 0 : uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
961 : sal_Int32 nRenderer,
962 : const uno::Any& /*rSelection*/,
963 : const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ )
964 : throw (IllegalArgumentException, RuntimeException, std::exception)
965 : {
966 0 : SolarMutexGuard aGuard;
967 :
968 0 : if (0 != nRenderer)
969 0 : throw IllegalArgumentException();
970 :
971 0 : SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() );
972 0 : if (!pDocSh)
973 0 : throw RuntimeException();
974 :
975 0 : SmPrinterAccess aPrinterAccess( *pDocSh );
976 0 : Printer *pPrinter = aPrinterAccess.GetPrinter();
977 0 : Size aPrtPaperSize ( pPrinter->GetPaperSize() );
978 :
979 : // if paper size is 0 (usually if no 'real' printer is found),
980 : // guess the paper size
981 0 : if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
982 0 : aPrtPaperSize = lcl_GuessPaperSize();
983 0 : awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() );
984 :
985 0 : uno::Sequence< beans::PropertyValue > aRenderer(1);
986 0 : PropertyValue &rValue = aRenderer.getArray()[0];
987 0 : rValue.Name = "PageSize";
988 0 : rValue.Value <<= aPageSize;
989 :
990 0 : if (!m_pPrintUIOptions)
991 0 : m_pPrintUIOptions.reset(new SmPrintUIOptions);
992 0 : m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
993 :
994 0 : return aRenderer;
995 : }
996 :
997 0 : void SAL_CALL SmModel::render(
998 : sal_Int32 nRenderer,
999 : const uno::Any& rSelection,
1000 : const uno::Sequence< beans::PropertyValue >& rxOptions )
1001 : throw (IllegalArgumentException, RuntimeException, std::exception)
1002 : {
1003 0 : SolarMutexGuard aGuard;
1004 :
1005 0 : if (0 != nRenderer)
1006 0 : throw IllegalArgumentException();
1007 :
1008 0 : SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() );
1009 0 : if (!pDocSh)
1010 0 : throw RuntimeException();
1011 :
1012 : // get device to be rendered in
1013 0 : uno::Reference< awt::XDevice > xRenderDevice;
1014 0 : for (sal_Int32 i = 0, nCount = rxOptions.getLength(); i < nCount; ++i)
1015 : {
1016 0 : if( rxOptions[i].Name == "RenderDevice" )
1017 0 : rxOptions[i].Value >>= xRenderDevice;
1018 : }
1019 :
1020 0 : if (xRenderDevice.is())
1021 : {
1022 0 : VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
1023 : VclPtr< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice()
1024 0 : : VclPtr< OutputDevice >();
1025 0 : if (!pOut)
1026 0 : throw RuntimeException();
1027 :
1028 0 : pOut->SetMapMode( MAP_100TH_MM );
1029 :
1030 0 : uno::Reference< frame::XModel > xModel;
1031 0 : rSelection >>= xModel;
1032 0 : if (xModel == pDocSh->GetModel())
1033 : {
1034 : //!! when called via API we may not have an active view
1035 : //!! thus we go and look for a view that can be used.
1036 0 : const TypeId aTypeId = TYPE( SmViewShell );
1037 0 : SfxViewShell* pViewSh = SfxViewShell::GetFirst( &aTypeId, false /* search non-visible views as well*/ );
1038 0 : while (pViewSh && pViewSh->GetObjectShell() != pDocSh)
1039 0 : pViewSh = SfxViewShell::GetNext( *pViewSh, &aTypeId, false /* search non-visible views as well*/ );
1040 0 : SmViewShell *pView = PTR_CAST( SmViewShell, pViewSh );
1041 : SAL_WARN_IF( !pView, "starmath", "SmModel::render : no SmViewShell found" );
1042 :
1043 0 : if (pView)
1044 : {
1045 0 : SmPrinterAccess aPrinterAccess( *pDocSh );
1046 0 : Printer *pPrinter = aPrinterAccess.GetPrinter();
1047 :
1048 0 : Size aPrtPaperSize ( pPrinter->GetPaperSize() );
1049 0 : Size aOutputSize ( pPrinter->GetOutputSize() );
1050 0 : Point aPrtPageOffset( pPrinter->GetPageOffset() );
1051 :
1052 : // no real printer ??
1053 0 : if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
1054 : {
1055 0 : aPrtPaperSize = lcl_GuessPaperSize();
1056 : // factors from Windows DIN A4
1057 0 : aOutputSize = Size( (long)(aPrtPaperSize.Width() * 0.941),
1058 0 : (long)(aPrtPaperSize.Height() * 0.961));
1059 0 : aPrtPageOffset = Point( (long)(aPrtPaperSize.Width() * 0.0250),
1060 0 : (long)(aPrtPaperSize.Height() * 0.0214));
1061 : }
1062 0 : Point aZeroPoint;
1063 0 : Rectangle OutputRect( aZeroPoint, aOutputSize );
1064 :
1065 :
1066 : // set minimum top and bottom border
1067 0 : if (aPrtPageOffset.Y() < 2000)
1068 0 : OutputRect.Top() += 2000 - aPrtPageOffset.Y();
1069 0 : if ((aPrtPaperSize.Height() - (aPrtPageOffset.Y() + OutputRect.Bottom())) < 2000)
1070 0 : OutputRect.Bottom() -= 2000 - (aPrtPaperSize.Height() -
1071 0 : (aPrtPageOffset.Y() + OutputRect.Bottom()));
1072 :
1073 : // set minimum left and right border
1074 0 : if (aPrtPageOffset.X() < 2500)
1075 0 : OutputRect.Left() += 2500 - aPrtPageOffset.X();
1076 0 : if ((aPrtPaperSize.Width() - (aPrtPageOffset.X() + OutputRect.Right())) < 1500)
1077 0 : OutputRect.Right() -= 1500 - (aPrtPaperSize.Width() -
1078 0 : (aPrtPageOffset.X() + OutputRect.Right()));
1079 :
1080 0 : if (!m_pPrintUIOptions)
1081 0 : m_pPrintUIOptions.reset(new SmPrintUIOptions);
1082 0 : m_pPrintUIOptions->processProperties( rxOptions );
1083 :
1084 0 : pView->Impl_Print( *pOut, *m_pPrintUIOptions, Rectangle( OutputRect ), Point() );
1085 :
1086 : // release SmPrintUIOptions when everything is done.
1087 : // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
1088 0 : if (m_pPrintUIOptions->getBoolValue( "IsLastPage", false ))
1089 : {
1090 0 : m_pPrintUIOptions.reset();
1091 0 : }
1092 : }
1093 0 : }
1094 0 : }
1095 0 : }
1096 :
1097 839 : void SAL_CALL SmModel::setParent( const uno::Reference< uno::XInterface >& xParent)
1098 : throw( lang::NoSupportException, uno::RuntimeException, std::exception )
1099 : {
1100 839 : SolarMutexGuard aGuard;
1101 839 : SfxBaseModel::setParent( xParent );
1102 1678 : uno::Reference< lang::XUnoTunnel > xParentTunnel( xParent, uno::UNO_QUERY );
1103 839 : if ( xParentTunnel.is() )
1104 : {
1105 560 : SvGlobalName aSfxIdent( SFX_GLOBAL_CLASSID );
1106 560 : SfxObjectShell* pDoc = reinterpret_cast<SfxObjectShell *>(xParentTunnel->getSomething(
1107 560 : uno::Sequence< sal_Int8 >( aSfxIdent.GetByteSequence() ) ) );
1108 560 : if ( pDoc )
1109 560 : GetObjectShell()->OnDocumentPrinterChanged( pDoc->GetDocumentPrinter() );
1110 839 : }
1111 839 : }
1112 :
1113 69 : void SmModel::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version )
1114 : {
1115 69 : static_cast< SmDocShell* >( GetObjectShell())->writeFormulaOoxml( m_pSerializer, version );
1116 69 : }
1117 :
1118 30 : void SmModel::writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
1119 : {
1120 30 : static_cast<SmDocShell*>(GetObjectShell())->writeFormulaRtf(rBuffer, nEncoding);
1121 30 : }
1122 :
1123 267 : void SmModel::readFormulaOoxml( oox::formulaimport::XmlStream& stream )
1124 : {
1125 267 : static_cast< SmDocShell* >( GetObjectShell())->readFormulaOoxml( stream );
1126 267 : }
1127 :
1128 267 : Size SmModel::getFormulaSize() const
1129 : {
1130 267 : return static_cast< SmDocShell* >( GetObjectShell())->GetSize();
1131 42 : }
1132 :
1133 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|