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