1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
42 #include <unomodel.hxx>
43 #include <document.hxx>
46 #include <starmath.hrc>
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
;
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))
64 ////////////////////////////////////////////////////////////
66 SmPrintUIOptions::SmPrintUIOptions()
68 ResStringArray
aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS
) );
69 OSL_ENSURE( aLocalizedStrings
.Count() >= 18, "resource incomplete" );
70 if( aLocalizedStrings
.Count() < 9 ) // bad resource ?
73 SmModule
*pp
= SM_MOD();
74 SmConfig
*pConfig
= pp
->GetConfig();
75 OSL_ENSURE( pConfig
, "SmConfig not found" );
79 sal_Int32 nNumProps
= 10, nIdx
=0;
81 // create sequence of print UI options
82 // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
83 m_aUIProperties
.realloc( nNumProps
);
85 // load the math PrinterOptions into the custom tab
86 m_aUIProperties
[nIdx
].Name
= OUString("OptionsUIFile");
87 m_aUIProperties
[nIdx
++].Value
<<= OUString("modules/smath/ui/printeroptions.ui");
89 // create Section for formula (results in an extra tab page in dialog)
90 SvtModuleOptions aOpt
;
91 OUString
aAppGroupname(
92 aLocalizedStrings
.GetString( 0 ).
93 replaceFirst( "%s", aOpt
.GetModuleName( SvtModuleOptions::E_SMATH
) ) );
94 m_aUIProperties
[nIdx
++].Value
= setGroupControlOpt("tabcontrol-page2", aAppGroupname
, ".HelpID:vcl:PrintDialog:TabPage:AppPage");
96 // create subgroup for print options
97 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("contents", aLocalizedStrings
.GetString(1), OUString());
99 // create a bool option for title row (matches to SID_PRINTTITLE)
100 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("title", aLocalizedStrings
.GetString( 2 ),
101 ".HelpID:vcl:PrintDialog:TitleRow:CheckBox",
103 pConfig
->IsPrintTitle());
104 // create a bool option for formula text (matches to SID_PRINTTEXT)
105 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("formulatext", aLocalizedStrings
.GetString( 3 ),
106 ".HelpID:vcl:PrintDialog:FormulaText:CheckBox",
107 PRTUIOPT_FORMULA_TEXT
,
108 pConfig
->IsPrintFormulaText());
109 // create a bool option for border (matches to SID_PRINTFRAME)
110 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("borders", aLocalizedStrings
.GetString( 4 ),
111 ".HelpID:vcl:PrintDialog:Border:CheckBox",
113 pConfig
->IsPrintFrame());
115 // create subgroup for print format
116 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("size", aLocalizedStrings
.GetString(5), OUString());
118 // create a radio button group for print format (matches to SID_PRINTSIZE)
119 Sequence
< OUString
> aChoices( 3 );
120 aChoices
[0] = aLocalizedStrings
.GetString( 6 );
121 aChoices
[1] = aLocalizedStrings
.GetString( 7 );
122 aChoices
[2] = aLocalizedStrings
.GetString( 8 );
123 Sequence
< OUString
> aHelpIds( 3 );
124 aHelpIds
[0] = ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0";
125 aHelpIds
[1] = ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1";
126 aHelpIds
[2] = ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2";
127 Sequence
< OUString
> aWidgetIds( 3 );
128 aWidgetIds
[0] = "originalsize";
129 aWidgetIds
[1] = "fittopage";
130 aWidgetIds
[2] = "scaling";
131 OUString
aPrintFormatProp( PRTUIOPT_PRINT_FORMAT
);
132 m_aUIProperties
[nIdx
++].Value
= setChoiceRadiosControlOpt(aWidgetIds
, OUString(),
135 aChoices
, static_cast< sal_Int32
>(pConfig
->GetPrintSize())
138 // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
139 vcl::PrinterOptionsHelper::UIControlOptions
aRangeOpt( aPrintFormatProp
, 2, sal_True
);
140 m_aUIProperties
[nIdx
++].Value
= setRangeControlOpt("scalingspin", OUString(),
141 ".HelpID:vcl:PrintDialog:PrintScale:NumericField",
142 PRTUIOPT_PRINT_SCALE
,
143 pConfig
->GetPrintZoomFactor(), // initial value
148 Sequence
< PropertyValue
> aHintNoLayoutPage( 1 );
149 aHintNoLayoutPage
[0].Name
= "HintNoLayoutPage";
150 aHintNoLayoutPage
[0].Value
= makeAny( sal_True
);
151 m_aUIProperties
[nIdx
++].Value
<<= aHintNoLayoutPage
;
153 assert(nIdx
== nNumProps
);
157 ////////////////////////////////////////////////////////////
162 // values from com/sun/star/beans/PropertyAttribute
163 #define PROPERTY_NONE 0
165 enum SmModelPropertyHandles
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
,
196 HANDLE_GREEK_CHAR_STYLE
,
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
,
222 HANDLE_BOTTOM_MARGIN
,
224 HANDLE_PRINTER_SETUP
,
227 HANDLE_BASIC_LIBRARIES
,
229 HANDLE_LOAD_READONLY
, // Security Options
230 HANDLE_DIALOG_LIBRARIES
, // #i73329#
234 static PropertySetInfo
* lcl_createModelPropertyInfo ()
236 static PropertyMapEntry aModelPropertyInfoMap
[] =
238 { RTL_CONSTASCII_STRINGPARAM( "Alignment" ), HANDLE_ALIGNMENT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
239 { RTL_CONSTASCII_STRINGPARAM( "BaseFontHeight" ), HANDLE_BASE_FONT_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
240 { RTL_CONSTASCII_STRINGPARAM( "BasicLibraries" ), HANDLE_BASIC_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
241 { RTL_CONSTASCII_STRINGPARAM( "BottomMargin" ), HANDLE_BOTTOM_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BOTTOMSPACE
},
242 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameFixed" ), HANDLE_CUSTOM_FONT_NAME_FIXED
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FIXED
},
243 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSans" ), HANDLE_CUSTOM_FONT_NAME_SANS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SANS
},
244 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSerif" ), HANDLE_CUSTOM_FONT_NAME_SERIF
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SERIF
},
245 { RTL_CONSTASCII_STRINGPARAM( "DialogLibraries" ), HANDLE_DIALOG_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
246 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsBold"), HANDLE_CUSTOM_FONT_FIXED_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
247 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsItalic"), HANDLE_CUSTOM_FONT_FIXED_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
248 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsBold"), HANDLE_FONT_FUNCTIONS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
249 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsItalic"), HANDLE_FONT_FUNCTIONS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
250 { RTL_CONSTASCII_STRINGPARAM( "FontNameFunctions" ), HANDLE_FONT_NAME_FUNCTIONS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FUNCTION
},
251 { RTL_CONSTASCII_STRINGPARAM( "FontNameNumbers" ), HANDLE_FONT_NAME_NUMBERS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_NUMBER
},
252 { RTL_CONSTASCII_STRINGPARAM( "FontNameText" ), HANDLE_FONT_NAME_TEXT
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_TEXT
},
253 { RTL_CONSTASCII_STRINGPARAM( "FontNameVariables" ), HANDLE_FONT_NAME_VARIABLES
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_VARIABLE
},
254 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsBold"), HANDLE_FONT_NUMBERS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
255 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsItalic"), HANDLE_FONT_NUMBERS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
256 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsBold"), HANDLE_CUSTOM_FONT_SANS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
257 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsItalic"), HANDLE_CUSTOM_FONT_SANS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
258 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsBold"), HANDLE_CUSTOM_FONT_SERIF_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
259 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsItalic"), HANDLE_CUSTOM_FONT_SERIF_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
260 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsBold"), HANDLE_FONT_TEXT_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
261 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsItalic"), HANDLE_FONT_TEXT_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
262 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsBold"), HANDLE_FONT_VARIABLES_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
263 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsItalic"), HANDLE_FONT_VARIABLES_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
264 { RTL_CONSTASCII_STRINGPARAM( "Formula" ), HANDLE_FORMULA
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0},
265 { RTL_CONSTASCII_STRINGPARAM( "IsScaleAllBrackets" ), HANDLE_IS_SCALE_ALL_BRACKETS
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
266 { RTL_CONSTASCII_STRINGPARAM( "IsTextMode" ), HANDLE_IS_TEXT_MODE
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
267 { RTL_CONSTASCII_STRINGPARAM( "GreekCharStyle" ), HANDLE_GREEK_CHAR_STYLE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
268 { RTL_CONSTASCII_STRINGPARAM( "LeftMargin" ), HANDLE_LEFT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LEFTSPACE
},
269 { RTL_CONSTASCII_STRINGPARAM( "PrinterName" ), HANDLE_PRINTER_NAME
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0 },
270 { RTL_CONSTASCII_STRINGPARAM( "PrinterSetup" ), HANDLE_PRINTER_SETUP
, &::getCppuType((const Sequence
< sal_Int8
>*)0), PROPERTY_NONE
, 0 },
271 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketDistance" ), HANDLE_RELATIVE_BRACKET_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSPACE
},
272 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketExcessSize" ), HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSIZE
},
273 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightFunctions" ), HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_FUNCTION
},
274 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightIndices" ), HANDLE_RELATIVE_FONT_HEIGHT_INDICES
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_INDEX
},
275 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightLimits" ), HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_LIMITS
},
276 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightOperators" ), HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_OPERATOR
},
277 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightText" ), HANDLE_RELATIVE_FONT_HEIGHT_TEXT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_TEXT
},
278 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarExcessLength"), HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_FRACTION
},
279 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarLineWeight" ), HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_STROKEWIDTH
},
280 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionDenominatorDepth"), HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_DENOMINATOR
},
281 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionNumeratorHeight" ), HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NUMERATOR
},
282 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSubscript" ), HANDLE_RELATIVE_INDEX_SUBSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUBSCRIPT
},
283 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSuperscript" ), HANDLE_RELATIVE_INDEX_SUPERSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUPERSCRIPT
},
284 { RTL_CONSTASCII_STRINGPARAM( "RelativeLineSpacing" ), HANDLE_RELATIVE_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_VERTICAL
},
285 { RTL_CONSTASCII_STRINGPARAM( "RelativeLowerLimitDistance" ), HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LOWERLIMIT
},
286 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixColumnSpacing" ), HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXCOL
},
287 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixLineSpacing" ), HANDLE_RELATIVE_MATRIX_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXROW
},
288 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorExcessSize" ), HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSIZE
},
289 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorSpacing" ), HANDLE_RELATIVE_OPERATOR_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSPACE
},
290 { RTL_CONSTASCII_STRINGPARAM( "RelativeRootSpacing" ), HANDLE_RELATIVE_ROOT_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ROOT
},
291 { RTL_CONSTASCII_STRINGPARAM( "RelativeScaleBracketExcessSize" ), HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NORMALBRACKETSIZE
},
292 { RTL_CONSTASCII_STRINGPARAM( "RelativeSpacing" ), HANDLE_RELATIVE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_HORIZONTAL
},
293 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolMinimumHeight" ), HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSPACE
},
294 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolPrimaryHeight" ), HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSIZE
},
295 { RTL_CONSTASCII_STRINGPARAM( "RelativeUpperLimitDistance" ), HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_UPPERLIMIT
},
296 { RTL_CONSTASCII_STRINGPARAM( "RightMargin" ), HANDLE_RIGHT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_RIGHTSPACE
},
297 { RTL_CONSTASCII_STRINGPARAM( "RuntimeUID" ), HANDLE_RUNTIME_UID
, &::getCppuType(static_cast< const OUString
* >(0)), PropertyAttribute::READONLY
, 0 },
298 { RTL_CONSTASCII_STRINGPARAM( "Symbols" ), HANDLE_SYMBOLS
, &::getCppuType((const Sequence
< SymbolDescriptor
> *)0), PROPERTY_NONE
, 0 },
299 { RTL_CONSTASCII_STRINGPARAM( "UserDefinedSymbolsInUse" ), HANDLE_USED_SYMBOLS
, &::getCppuType((const Sequence
< SymbolDescriptor
> *)0), PropertyAttribute::READONLY
, 0 },
300 { RTL_CONSTASCII_STRINGPARAM( "TopMargin" ), HANDLE_TOP_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_TOPSPACE
},
301 // #i33095# Security Options
302 { RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY
, &::getBooleanCppuType(), PROPERTY_NONE
, 0 },
304 { RTL_CONSTASCII_STRINGPARAM( "BaseLine"), HANDLE_BASELINE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
305 { NULL
, 0, 0, NULL
, 0, 0 }
307 PropertySetInfo
*pInfo
= new PropertySetInfo ( aModelPropertyInfoMap
);
311 SmModel::SmModel( SfxObjectShell
*pObjSh
)
312 : SfxBaseModel(pObjSh
)
313 , PropertySetHelper ( lcl_createModelPropertyInfo () )
314 , m_pPrintUIOptions( NULL
)
319 SmModel::~SmModel() throw ()
321 delete m_pPrintUIOptions
;
324 uno::Any SAL_CALL
SmModel::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
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 ),
335 static_cast< XServiceInfo
* > ( this ),
336 static_cast< XRenderable
* > ( this ) );
337 if (!aRet
.hasValue())
338 aRet
= SfxBaseModel::queryInterface ( rType
);
342 void SAL_CALL
SmModel::acquire() throw()
344 OWeakObject::acquire();
347 void SAL_CALL
SmModel::release() throw()
349 OWeakObject::release();
352 uno::Sequence
< uno::Type
> SAL_CALL
SmModel::getTypes( ) throw(uno::RuntimeException
)
354 SolarMutexGuard aGuard
;
355 uno::Sequence
< uno::Type
> aTypes
= SfxBaseModel::getTypes();
356 sal_Int32 nLen
= aTypes
.getLength();
357 aTypes
.realloc(nLen
+ 4);
358 uno::Type
* pTypes
= aTypes
.getArray();
359 pTypes
[nLen
++] = ::getCppuType((Reference
<XServiceInfo
>*)0);
360 pTypes
[nLen
++] = ::getCppuType((Reference
<XPropertySet
>*)0);
361 pTypes
[nLen
++] = ::getCppuType((Reference
<XMultiPropertySet
>*)0);
362 pTypes
[nLen
++] = ::getCppuType((Reference
<XRenderable
>*)0);
369 class theSmModelUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSmModelUnoTunnelId
> {};
372 const uno::Sequence
< sal_Int8
> & SmModel::getUnoTunnelId()
374 return theSmModelUnoTunnelId::get().getSeq();
377 sal_Int64 SAL_CALL
SmModel::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
378 throw(uno::RuntimeException
)
380 if( rId
.getLength() == 16
381 && 0 == memcmp( getUnoTunnelId().getConstArray(),
382 rId
.getConstArray(), 16 ) )
384 return sal::static_int_cast
< sal_Int64
>(reinterpret_cast< sal_uIntPtr
>(this));
387 return SfxBaseModel::getSomething( rId
);
390 static sal_Int16
lcl_AnyToINT16(const uno::Any
& rAny
)
392 uno::TypeClass eType
= rAny
.getValueType().getTypeClass();
395 if( eType
== uno::TypeClass_DOUBLE
)
396 nRet
= (sal_Int16
)*(double*)rAny
.getValue();
397 else if( eType
== uno::TypeClass_FLOAT
)
398 nRet
= (sal_Int16
)*(float*)rAny
.getValue();
404 OUString
SmModel::getImplementationName(void) throw( uno::RuntimeException
)
406 return getImplementationName_Static();
410 OUString
SmModel::getImplementationName_Static()
412 return OUString("com.sun.star.comp.math.FormulaDocument");
415 sal_Bool
SmModel::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
418 rServiceName
== "com.sun.star.document.OfficeDocument" ||
419 rServiceName
== "com.sun.star.formula.FormulaProperties"
423 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames(void) throw( uno::RuntimeException
)
425 return getSupportedServiceNames_Static();
428 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames_Static(void)
430 SolarMutexGuard aGuard
;
432 uno::Sequence
< OUString
> aRet(2);
433 OUString
* pArray
= aRet
.getArray();
434 pArray
[0] = "com.sun.star.document.OfficeDocument";
435 pArray
[1] = "com.sun.star.formula.FormulaProperties";
439 void SmModel::_setPropertyValues(const PropertyMapEntry
** ppEntries
, const Any
* pValues
)
440 throw( UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
)
442 SolarMutexGuard aGuard
;
444 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
446 if ( NULL
== pDocSh
)
447 throw UnknownPropertyException();
449 SmFormat aFormat
= pDocSh
->GetFormat();
451 for (; *ppEntries
; ppEntries
++, pValues
++ )
453 if ((*ppEntries
)->mnAttributes
& PropertyAttribute::READONLY
)
454 throw PropertyVetoException();
456 switch ( (*ppEntries
)->mnHandle
)
462 pDocSh
->SetText(aText
);
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
:
474 *pValues
>>= sFontName
;
475 if(sFontName
.isEmpty())
476 throw IllegalArgumentException();
478 if(OUString(aFormat
.GetFont((*ppEntries
)->mnMemberId
).GetName()) != sFontName
)
480 const SmFace rOld
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
482 SmFace
aSet( sFontName
, rOld
.GetSize() );
483 aSet
.SetBorderWidth( rOld
.GetBorderWidth() );
484 aSet
.SetAlign( ALIGN_BASELINE
);
485 aFormat
.SetFont( (*ppEntries
)->mnMemberId
, aSet
);
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
:
497 if((*pValues
).getValueType() != ::getBooleanCppuType())
498 throw IllegalArgumentException();
499 bool bVal
= *(sal_Bool
*)(*pValues
).getValue();
500 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
501 aNewFont
.SetItalic((bVal
) ? ITALIC_NORMAL
: ITALIC_NONE
);
502 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
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
:
513 if((*pValues
).getValueType() != ::getBooleanCppuType())
514 throw IllegalArgumentException();
515 bool bVal
= *(sal_Bool
*)(*pValues
).getValue();
516 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
517 aNewFont
.SetWeight((bVal
) ? WEIGHT_BOLD
: WEIGHT_NORMAL
);
518 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
521 case HANDLE_BASE_FONT_HEIGHT
:
524 sal_Int16 nVal
= lcl_AnyToINT16(*pValues
);
526 throw IllegalArgumentException();
527 Size aSize
= aFormat
.GetBaseSize();
529 nVal
= static_cast < sal_Int16
> ( TWIP_TO_MM100(nVal
) );
530 aSize
.Height() = nVal
;
531 aFormat
.SetBaseSize(aSize
);
533 // apply base size to fonts
534 const Size
aTmp( aFormat
.GetBaseSize() );
535 for (sal_uInt16 i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
536 aFormat
.SetFontSize(i
, aTmp
);
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
:
548 throw IllegalArgumentException();
549 aFormat
.SetRelSize((*ppEntries
)->mnMemberId
, nVal
);
553 case HANDLE_IS_TEXT_MODE
:
555 aFormat
.SetTextmode(*(sal_Bool
*)(*pValues
).getValue());
559 case HANDLE_GREEK_CHAR_STYLE
:
563 if (nVal
< 0 || nVal
> 2)
564 throw IllegalArgumentException();
565 aFormat
.SetGreekCharStyle( nVal
);
569 case HANDLE_ALIGNMENT
:
571 // SmHorAlign uses the same values as HorizontalAlignment
574 if(nVal
< 0 || nVal
> 2)
575 throw IllegalArgumentException();
576 aFormat
.SetHorAlign((SmHorAlign
)nVal
);
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
:
608 throw IllegalArgumentException();
609 aFormat
.SetDistance((*ppEntries
)->mnMemberId
, nVal
);
612 case HANDLE_IS_SCALE_ALL_BRACKETS
:
613 aFormat
.SetScaleNormalBrackets(*(sal_Bool
*)(*pValues
).getValue());
615 case HANDLE_PRINTER_NAME
:
617 // embedded documents just ignore this property for now
618 if ( pDocSh
->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
)
620 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
623 OUString sPrinterName
;
624 if (*pValues
>>= sPrinterName
)
626 if ( !sPrinterName
.isEmpty() )
628 SfxPrinter
*pNewPrinter
= new SfxPrinter ( pPrinter
->GetOptions().Clone(), sPrinterName
);
629 if (pNewPrinter
->IsKnown())
630 pDocSh
->SetPrinter ( pNewPrinter
);
636 throw IllegalArgumentException();
641 case HANDLE_PRINTER_SETUP
:
643 Sequence
< sal_Int8
> aSequence
;
644 if ( *pValues
>>= aSequence
)
646 sal_uInt32 nSize
= aSequence
.getLength();
647 SvMemoryStream
aStream ( aSequence
.getArray(), nSize
, STREAM_READ
);
648 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
649 static sal_uInt16
const nRange
[] =
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
,
659 SfxItemSet
*pItemSet
= new SfxItemSet( pDocSh
->GetPool(), nRange
);
660 SmModule
*pp
= SM_MOD();
661 pp
->GetConfig()->ConfigToItemSet(*pItemSet
);
662 SfxPrinter
*pPrinter
= SfxPrinter::Create ( aStream
, pItemSet
);
664 pDocSh
->SetPrinter( pPrinter
);
667 throw IllegalArgumentException();
673 Sequence
< SymbolDescriptor
> aSequence
;
674 if ( *pValues
>>= aSequence
)
676 sal_uInt32 nSize
= aSequence
.getLength();
677 SmModule
*pp
= SM_MOD();
678 SmSymbolManager
&rManager
= pp
->GetSymbolManager();
679 SymbolDescriptor
*pDescriptor
= aSequence
.getArray();
680 for (sal_uInt32 i
= 0; i
< nSize
; i
++, pDescriptor
++)
683 aFont
.SetName ( pDescriptor
->sFontName
);
684 aFont
.SetCharSet ( static_cast < rtl_TextEncoding
> (pDescriptor
->nCharSet
) );
685 aFont
.SetFamily ( static_cast < FontFamily
> (pDescriptor
->nFamily
) );
686 aFont
.SetPitch ( static_cast < FontPitch
> (pDescriptor
->nPitch
) );
687 aFont
.SetWeight ( static_cast < FontWeight
> (pDescriptor
->nWeight
) );
688 aFont
.SetItalic ( static_cast < FontItalic
> (pDescriptor
->nItalic
) );
689 SmSym
aSymbol ( pDescriptor
->sName
, aFont
, static_cast < sal_Unicode
> (pDescriptor
->nCharacter
),
690 pDescriptor
->sSymbolSet
);
691 aSymbol
.SetExportName ( pDescriptor
->sExportName
);
692 aSymbol
.SetDocSymbol( sal_True
);
693 rManager
.AddOrReplaceSymbol ( aSymbol
);
697 throw IllegalArgumentException();
700 // #i33095# Security Options
701 case HANDLE_LOAD_READONLY
:
703 if ( (*pValues
).getValueType() != ::getBooleanCppuType() )
704 throw IllegalArgumentException();
705 sal_Bool bReadonly
= sal_False
;
706 if ( *pValues
>>= bReadonly
)
707 pDocSh
->SetLoadReadonly( bReadonly
);
713 pDocSh
->SetFormat( aFormat
);
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 pDocSh
->SetVisArea( Rectangle( Point(0, 0), pDocSh
->GetSize() ) );
720 void SmModel::_getPropertyValues( const PropertyMapEntry
**ppEntries
, Any
*pValue
)
721 throw( UnknownPropertyException
, WrappedTargetException
)
723 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
725 if ( NULL
== pDocSh
)
726 throw UnknownPropertyException();
728 const SmFormat
& aFormat
= pDocSh
->GetFormat();
730 for (; *ppEntries
; ppEntries
++, pValue
++ )
732 switch ( (*ppEntries
)->mnHandle
)
735 *pValue
<<= OUString(pDocSh
->GetText());
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
:
745 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
746 *pValue
<<= OUString(rFace
.GetName());
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
:
757 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
758 bool bVal
= IsItalic( rFace
);
759 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
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
:
770 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
771 bool bVal
= IsBold( rFace
); // bold?
772 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
775 case HANDLE_BASE_FONT_HEIGHT
:
778 sal_Int16 nVal
= static_cast < sal_Int16
> (aFormat
.GetBaseSize().Height());
779 nVal
= static_cast < sal_Int16
> (MM100_TO_TWIP(nVal
));
780 nVal
= (nVal
+ 10) / 20;
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 *pValue
<<= (sal_Int16
) aFormat
.GetRelSize((*ppEntries
)->mnMemberId
);
792 case HANDLE_IS_TEXT_MODE
:
794 sal_Bool bVal
= aFormat
.IsTextmode();
795 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
799 case HANDLE_GREEK_CHAR_STYLE
:
800 *pValue
<<= (sal_Int16
)aFormat
.GetGreekCharStyle();
803 case HANDLE_ALIGNMENT
:
804 // SmHorAlign uses the same values as HorizontalAlignment
805 *pValue
<<= (sal_Int16
)aFormat
.GetHorAlign();
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 *pValue
<<= (sal_Int16
)aFormat
.GetDistance((*ppEntries
)->mnMemberId
);
834 case HANDLE_IS_SCALE_ALL_BRACKETS
:
836 sal_Bool bVal
= aFormat
.IsScaleNormalBrackets();
837 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
840 case HANDLE_PRINTER_NAME
:
842 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
843 *pValue
<<= pPrinter
? OUString ( pPrinter
->GetName()) : OUString();
846 case HANDLE_PRINTER_SETUP
:
848 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ();
851 SvMemoryStream aStream
;
852 pPrinter
->Store( aStream
);
853 aStream
.Seek ( STREAM_SEEK_TO_END
);
854 sal_uInt32 nSize
= aStream
.Tell();
855 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
856 Sequence
< sal_Int8
> aSequence ( nSize
);
857 aStream
.Read ( aSequence
.getArray(), nSize
);
858 *pValue
<<= aSequence
;
863 case HANDLE_USED_SYMBOLS
:
865 const bool bUsedSymbolsOnly
= (*ppEntries
)->mnHandle
== HANDLE_USED_SYMBOLS
;
866 const std::set
< OUString
> &rUsedSymbols
= pDocSh
->GetUsedSymbols();
869 SmModule
*pp
= SM_MOD();
870 const SmSymbolManager
&rManager
= pp
->GetSymbolManager();
871 vector
< const SmSym
* > aVector
;
873 const SymbolPtrVec_t
aSymbols( rManager
.GetSymbols() );
875 for (size_t i
= 0; i
< aSymbols
.size(); ++i
)
877 const SmSym
* pSymbol
= aSymbols
[ i
];
878 if (pSymbol
&& !pSymbol
->IsPredefined() &&
879 (!bUsedSymbolsOnly
||
880 rUsedSymbols
.find( pSymbol
->GetName() ) != rUsedSymbols
.end()))
882 aVector
.push_back ( pSymbol
);
886 Sequence
< SymbolDescriptor
> aSequence ( nCount
);
887 SymbolDescriptor
* pDescriptor
= aSequence
.getArray();
889 vector
< const SmSym
* >::const_iterator aIter
= aVector
.begin(), aEnd
= aVector
.end();
890 for(; aIter
!= aEnd
; pDescriptor
++, ++aIter
)
892 pDescriptor
->sName
= (*aIter
)->GetName();
893 pDescriptor
->sExportName
= (*aIter
)->GetExportName();
894 pDescriptor
->sSymbolSet
= (*aIter
)->GetSymbolSetName();
895 pDescriptor
->nCharacter
= static_cast < sal_Int32
> ((*aIter
)->GetCharacter());
897 Font rFont
= (*aIter
)->GetFace();
898 pDescriptor
->sFontName
= rFont
.GetName();
899 pDescriptor
->nCharSet
= sal::static_int_cast
< sal_Int16
>(rFont
.GetCharSet());
900 pDescriptor
->nFamily
= sal::static_int_cast
< sal_Int16
>(rFont
.GetFamily());
901 pDescriptor
->nPitch
= sal::static_int_cast
< sal_Int16
>(rFont
.GetPitch());
902 pDescriptor
->nWeight
= sal::static_int_cast
< sal_Int16
>(rFont
.GetWeight());
903 pDescriptor
->nItalic
= sal::static_int_cast
< sal_Int16
>(rFont
.GetItalic());
905 *pValue
<<= aSequence
;
908 case HANDLE_BASIC_LIBRARIES
:
909 *pValue
<<= pDocSh
->GetBasicContainer();
911 case HANDLE_DIALOG_LIBRARIES
:
912 *pValue
<<= pDocSh
->GetDialogContainer();
914 case HANDLE_RUNTIME_UID
:
915 *pValue
<<= getRuntimeUID();
917 // #i33095# Security Options
918 case HANDLE_LOAD_READONLY
:
920 *pValue
<<= pDocSh
->IsLoadReadonly();
924 case HANDLE_BASELINE
:
926 if ( !pDocSh
->pTree
)
930 if ( !pDocSh
->IsFormulaArranged() )
931 pDocSh
->ArrangeFormula();
933 *pValue
<<= static_cast<sal_Int32
>( pDocSh
->pTree
->GetFormulaBaseline() );
941 //////////////////////////////////////////////////////////////////////
943 sal_Int32 SAL_CALL
SmModel::getRendererCount(
944 const uno::Any
& /*rSelection*/,
945 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
946 throw (IllegalArgumentException
, RuntimeException
)
948 SolarMutexGuard aGuard
;
953 static Size
lcl_GuessPaperSize()
956 const LocaleDataWrapper
& rLocWrp( AllSettings().GetLocaleDataWrapper() );
957 if( MEASURE_METRIC
== rLocWrp
.getMeasurementSystemEnum() )
960 PaperInfo
aInfo( PAPER_A4
);
961 aRes
.Width() = aInfo
.getWidth();
962 aRes
.Height() = aInfo
.getHeight();
967 PaperInfo
aInfo( PAPER_LETTER
);
968 aRes
.Width() = aInfo
.getWidth();
969 aRes
.Height() = aInfo
.getHeight();
974 uno::Sequence
< beans::PropertyValue
> SAL_CALL
SmModel::getRenderer(
976 const uno::Any
& /*rSelection*/,
977 const uno::Sequence
< beans::PropertyValue
>& /*rxOptions*/ )
978 throw (IllegalArgumentException
, RuntimeException
)
980 SolarMutexGuard aGuard
;
983 throw IllegalArgumentException();
985 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
987 throw RuntimeException();
989 SmPrinterAccess
aPrinterAccess( *pDocSh
);
990 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
991 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
993 // if paper size is 0 (usually if no 'real' printer is found),
994 // guess the paper size
995 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
996 aPrtPaperSize
= lcl_GuessPaperSize();
997 awt::Size
aPageSize( aPrtPaperSize
.Width(), aPrtPaperSize
.Height() );
999 uno::Sequence
< beans::PropertyValue
> aRenderer(1);
1000 PropertyValue
&rValue
= aRenderer
.getArray()[0];
1001 rValue
.Name
= "PageSize";
1002 rValue
.Value
<<= aPageSize
;
1004 if (!m_pPrintUIOptions
)
1005 m_pPrintUIOptions
= new SmPrintUIOptions();
1006 m_pPrintUIOptions
->appendPrintUIOptions( aRenderer
);
1011 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
)
1017 SolarMutexGuard aGuard
;
1020 throw IllegalArgumentException();
1022 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
1024 throw RuntimeException();
1026 // get device to be rendered in
1027 uno::Reference
< awt::XDevice
> xRenderDevice
;
1028 for (sal_Int32 i
= 0, nCount
= rxOptions
.getLength(); i
< nCount
; ++i
)
1030 if( rxOptions
[i
].Name
== "RenderDevice" )
1031 rxOptions
[i
].Value
>>= xRenderDevice
;
1034 if (xRenderDevice
.is())
1036 VCLXDevice
* pDevice
= VCLXDevice::GetImplementation( xRenderDevice
);
1037 OutputDevice
* pOut
= pDevice
? pDevice
->GetOutputDevice() : NULL
;
1040 throw RuntimeException();
1042 pOut
->SetMapMode( MAP_100TH_MM
);
1044 uno::Reference
< frame::XModel
> xModel
;
1045 rSelection
>>= xModel
;
1046 if (xModel
== pDocSh
->GetModel())
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 const TypeId aTypeId
= TYPE( SmViewShell
);
1051 SfxViewShell
* pViewSh
= SfxViewShell::GetFirst( &aTypeId
, sal_False
/* search non-visible views as well*/ );
1052 while (pViewSh
&& pViewSh
->GetObjectShell() != pDocSh
)
1053 pViewSh
= SfxViewShell::GetNext( *pViewSh
, &aTypeId
, sal_False
/* search non-visible views as well*/ );
1054 SmViewShell
*pView
= PTR_CAST( SmViewShell
, pViewSh
);
1055 OSL_ENSURE( pView
, "SmModel::render : no SmViewShell found" );
1059 SmPrinterAccess
aPrinterAccess( *pDocSh
);
1060 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
1062 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
1063 Size
aOutputSize ( pPrinter
->GetOutputSize() );
1064 Point
aPrtPageOffset( pPrinter
->GetPageOffset() );
1066 // no real printer ??
1067 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
1069 aPrtPaperSize
= lcl_GuessPaperSize();
1070 // factors from Windows DIN A4
1071 aOutputSize
= Size( (long)(aPrtPaperSize
.Width() * 0.941),
1072 (long)(aPrtPaperSize
.Height() * 0.961));
1073 aPrtPageOffset
= Point( (long)(aPrtPaperSize
.Width() * 0.0250),
1074 (long)(aPrtPaperSize
.Height() * 0.0214));
1077 Rectangle
OutputRect( aZeroPoint
, aOutputSize
);
1080 // set minimum top and bottom border
1081 if (aPrtPageOffset
.Y() < 2000)
1082 OutputRect
.Top() += 2000 - aPrtPageOffset
.Y();
1083 if ((aPrtPaperSize
.Height() - (aPrtPageOffset
.Y() + OutputRect
.Bottom())) < 2000)
1084 OutputRect
.Bottom() -= 2000 - (aPrtPaperSize
.Height() -
1085 (aPrtPageOffset
.Y() + OutputRect
.Bottom()));
1087 // set minimum left and right border
1088 if (aPrtPageOffset
.X() < 2500)
1089 OutputRect
.Left() += 2500 - aPrtPageOffset
.X();
1090 if ((aPrtPaperSize
.Width() - (aPrtPageOffset
.X() + OutputRect
.Right())) < 1500)
1091 OutputRect
.Right() -= 1500 - (aPrtPaperSize
.Width() -
1092 (aPrtPageOffset
.X() + OutputRect
.Right()));
1094 if (!m_pPrintUIOptions
)
1095 m_pPrintUIOptions
= new SmPrintUIOptions();
1096 m_pPrintUIOptions
->processProperties( rxOptions
);
1098 pView
->Impl_Print( *pOut
, *m_pPrintUIOptions
, Rectangle( OutputRect
), Point() );
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 if (m_pPrintUIOptions
->getBoolValue( "IsLastPage", sal_False
))
1104 delete m_pPrintUIOptions
; m_pPrintUIOptions
= 0;
1111 void SAL_CALL
SmModel::setParent( const uno::Reference
< uno::XInterface
>& xParent
)
1112 throw( lang::NoSupportException
, uno::RuntimeException
)
1114 SolarMutexGuard aGuard
;
1115 SfxBaseModel::setParent( xParent
);
1116 uno::Reference
< lang::XUnoTunnel
> xParentTunnel( xParent
, uno::UNO_QUERY
);
1117 if ( xParentTunnel
.is() )
1119 SvGlobalName
aSfxIdent( SFX_GLOBAL_CLASSID
);
1120 SfxObjectShell
* pDoc
= reinterpret_cast<SfxObjectShell
*>(xParentTunnel
->getSomething(
1121 uno::Sequence
< sal_Int8
>( aSfxIdent
.GetByteSequence() ) ) );
1123 GetObjectShell()->OnDocumentPrinterChanged( pDoc
->GetDocumentPrinter() );
1127 void SmModel::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer
, oox::core::OoxmlVersion version
)
1129 static_cast< SmDocShell
* >( GetObjectShell())->writeFormulaOoxml( m_pSerializer
, version
);
1132 void SmModel::writeFormulaRtf(OStringBuffer
& rBuffer
, rtl_TextEncoding nEncoding
)
1134 static_cast<SmDocShell
*>(GetObjectShell())->writeFormulaRtf(rBuffer
, nEncoding
);
1137 void SmModel::readFormulaOoxml( oox::formulaimport::XmlStream
& stream
)
1139 static_cast< SmDocShell
* >( GetObjectShell())->readFormulaOoxml( stream
);
1142 Size
SmModel::getFormulaSize() const
1144 return static_cast< SmDocShell
* >( GetObjectShell())->GetSize();
1147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */