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