1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_starmath.hxx"
32 #include <vos/mutex.hxx>
33 #include <osl/mutex.hxx>
34 #include <sfx2/printer.hxx>
35 #include <vcl/svapp.hxx>
36 #include <svtools/ctrltool.hxx>
37 #include <svl/itemprop.hxx>
38 #include <unotools/localedatawrapper.hxx>
39 #include <unotools/processfactory.hxx>
40 #include <editeng/paperinf.hxx>
41 #include <vcl/settings.hxx>
42 #include <vcl/print.hxx>
43 #include <toolkit/awt/vclxdevice.hxx>
44 #include <com/sun/star/beans/PropertyState.hpp>
45 #include <com/sun/star/beans/PropertyAttribute.hpp>
46 #include <com/sun/star/formula/SymbolDescriptor.hpp>
47 #include <com/sun/star/awt/Size.hpp>
48 #include <com/sun/star/script/XLibraryContainer.hpp>
49 #include <xmloff/xmluconv.hxx>
50 #include <rtl/ustrbuf.hxx>
51 #include <comphelper/propertysetinfo.hxx>
52 #include <unotools/moduleoptions.hxx>
54 #include <unomodel.hxx>
55 #include <document.hxx>
58 #include <starmath.hrc>
62 using namespace ::vos
;
63 using namespace ::rtl
;
64 using namespace ::cppu
;
65 using namespace ::std
;
66 using namespace ::comphelper
;
67 using namespace ::com::sun::star
;
68 using namespace ::com::sun::star::uno
;
69 using namespace ::com::sun::star::beans
;
70 using namespace ::com::sun::star::lang
;
71 using namespace ::com::sun::star::formula
;
72 using namespace ::com::sun::star::view
;
73 using namespace ::com::sun::star::script
;
76 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
77 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
79 ////////////////////////////////////////////////////////////
81 SmPrintUIOptions::SmPrintUIOptions()
83 ResStringArray
aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS
) );
84 DBG_ASSERT( aLocalizedStrings
.Count() >= 9, "resource incomplete" );
85 if( aLocalizedStrings
.Count() < 9 ) // bad resource ?
88 SmModule
*pp
= SM_MOD();
89 SmConfig
*pConfig
= pp
->GetConfig();
90 DBG_ASSERT( pConfig
, "SmConfig not found" );
94 // create sequence of print UI options
95 // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
96 m_aUIProperties
.realloc( 9 );
98 // create Section for formula (results in an extra tab page in dialog)
99 SvtModuleOptions aOpt
;
100 String
aAppGroupname( aLocalizedStrings
.GetString( 0 ) );
101 aAppGroupname
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
102 aOpt
.GetModuleName( SvtModuleOptions::E_SMATH
) );
103 m_aUIProperties
[0].Value
= getGroupControlOpt( aAppGroupname
, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TabPage:AppPage" ) ) );
105 // create subgroup for print options
106 m_aUIProperties
[1].Value
= getSubgroupControlOpt( aLocalizedStrings
.GetString( 1 ), rtl::OUString() );
108 // create a bool option for title row (matches to SID_PRINTTITLE)
109 m_aUIProperties
[2].Value
= getBoolControlOpt( aLocalizedStrings
.GetString( 2 ),
110 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TitleRow:CheckBox" ) ),
111 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_TITLE_ROW
) ),
112 pConfig
->IsPrintTitle() );
113 // create a bool option for formula text (matches to SID_PRINTTEXT)
114 m_aUIProperties
[3].Value
= getBoolControlOpt( aLocalizedStrings
.GetString( 3 ),
115 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:FormulaText:CheckBox" ) ),
116 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_FORMULA_TEXT
) ),
117 pConfig
->IsPrintFormulaText() );
118 // create a bool option for border (matches to SID_PRINTFRAME)
119 m_aUIProperties
[4].Value
= getBoolControlOpt( aLocalizedStrings
.GetString( 4 ),
120 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:Border:CheckBox" ) ),
121 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_BORDER
) ),
122 pConfig
->IsPrintFrame() );
124 // create subgroup for print format
125 m_aUIProperties
[5].Value
= getSubgroupControlOpt( aLocalizedStrings
.GetString( 5 ), rtl::OUString() );
127 // create a radio button group for print format (matches to SID_PRINTSIZE)
128 Sequence
< rtl::OUString
> aChoices( 3 );
129 aChoices
[0] = aLocalizedStrings
.GetString( 6 );
130 aChoices
[1] = aLocalizedStrings
.GetString( 7 );
131 aChoices
[2] = aLocalizedStrings
.GetString( 8 );
132 Sequence
< rtl::OUString
> aHelpIds( 3 );
133 aHelpIds
[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0" ) );
134 aHelpIds
[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1" ) );
135 aHelpIds
[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2" ) );
136 OUString
aPrintFormatProp( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_FORMAT
) );
137 m_aUIProperties
[6].Value
= getChoiceControlOpt( rtl::OUString(),
140 aChoices
, static_cast< sal_Int32
>(pConfig
->GetPrintSize())
143 // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
144 vcl::PrinterOptionsHelper::UIControlOptions
aRangeOpt( aPrintFormatProp
, 2, sal_True
);
145 m_aUIProperties
[ 7 ].Value
= getRangeControlOpt( rtl::OUString(),
146 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintScale:NumericField" ) ),
147 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_SCALE
) ),
148 pConfig
->GetPrintZoomFactor(), // initial value
153 Sequence
< PropertyValue
> aHintNoLayoutPage( 1 );
154 aHintNoLayoutPage
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HintNoLayoutPage" ) );
155 aHintNoLayoutPage
[0].Value
= makeAny( sal_True
);
156 m_aUIProperties
[8].Value
<<= aHintNoLayoutPage
;
158 // IsIgnoreSpacesRight is a parser option! Thus we don't add it to the printer UI.
160 // // create subgroup for misc options
161 // m_aUIProperties[8].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 9 ) );
163 // // create a bool option for ignore spacing (matches to SID_NO_RIGHT_SPACES)
164 // m_aUIProperties[9].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ),
165 // rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_NO_RIGHT_SPACE ) ),
166 // pConfig->IsIgnoreSpacesRight() );
170 ////////////////////////////////////////////////////////////
175 // values from com/sun/star/beans/PropertyAttribute
176 #define PROPERTY_NONE 0
177 #define PROPERTY_READONLY 16
179 enum SmModelPropertyHandles
182 HANDLE_FONT_NAME_VARIABLES
,
183 HANDLE_FONT_NAME_FUNCTIONS
,
184 HANDLE_FONT_NAME_NUMBERS
,
185 HANDLE_FONT_NAME_TEXT
,
186 HANDLE_CUSTOM_FONT_NAME_SERIF
,
187 HANDLE_CUSTOM_FONT_NAME_SANS
,
188 HANDLE_CUSTOM_FONT_NAME_FIXED
,
189 HANDLE_CUSTOM_FONT_FIXED_POSTURE
,
190 HANDLE_CUSTOM_FONT_FIXED_WEIGHT
,
191 HANDLE_CUSTOM_FONT_SANS_POSTURE
,
192 HANDLE_CUSTOM_FONT_SANS_WEIGHT
,
193 HANDLE_CUSTOM_FONT_SERIF_POSTURE
,
194 HANDLE_CUSTOM_FONT_SERIF_WEIGHT
,
195 HANDLE_FONT_VARIABLES_POSTURE
,
196 HANDLE_FONT_VARIABLES_WEIGHT
,
197 HANDLE_FONT_FUNCTIONS_POSTURE
,
198 HANDLE_FONT_FUNCTIONS_WEIGHT
,
199 HANDLE_FONT_NUMBERS_POSTURE
,
200 HANDLE_FONT_NUMBERS_WEIGHT
,
201 HANDLE_FONT_TEXT_POSTURE
,
202 HANDLE_FONT_TEXT_WEIGHT
,
203 HANDLE_BASE_FONT_HEIGHT
,
204 HANDLE_RELATIVE_FONT_HEIGHT_TEXT
,
205 HANDLE_RELATIVE_FONT_HEIGHT_INDICES
,
206 HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
,
207 HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
,
208 HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
,
210 HANDLE_GREEK_CHAR_STYLE
,
212 HANDLE_RELATIVE_SPACING
,
213 HANDLE_RELATIVE_LINE_SPACING
,
214 HANDLE_RELATIVE_ROOT_SPACING
,
215 HANDLE_RELATIVE_INDEX_SUPERSCRIPT
,
216 HANDLE_RELATIVE_INDEX_SUBSCRIPT
,
217 HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
,
218 HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
,
219 HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
,
220 HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
,
221 HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
,
222 HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
,
223 HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
,
224 HANDLE_RELATIVE_BRACKET_DISTANCE
,
225 HANDLE_IS_SCALE_ALL_BRACKETS
,
226 HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
,
227 HANDLE_RELATIVE_MATRIX_LINE_SPACING
,
228 HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
,
229 HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
,
230 HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
,
231 HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
,
232 HANDLE_RELATIVE_OPERATOR_SPACING
,
236 HANDLE_BOTTOM_MARGIN
,
238 HANDLE_PRINTER_SETUP
,
241 HANDLE_BASIC_LIBRARIES
, /* #93295# */
243 // --> PB 2004-08-25 #i33095# Security Options
244 HANDLE_LOAD_READONLY
,
246 HANDLE_DIALOG_LIBRARIES
, // #i73329#
247 HANDLE_BASELINE
// 3.7.2010 #i972#
250 PropertySetInfo
* lcl_createModelPropertyInfo ()
252 static PropertyMapEntry aModelPropertyInfoMap
[] =
254 { RTL_CONSTASCII_STRINGPARAM( "Alignment" ), HANDLE_ALIGNMENT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
255 { RTL_CONSTASCII_STRINGPARAM( "BaseFontHeight" ), HANDLE_BASE_FONT_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
256 { RTL_CONSTASCII_STRINGPARAM( "BasicLibraries" ), HANDLE_BASIC_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
257 { RTL_CONSTASCII_STRINGPARAM( "BottomMargin" ), HANDLE_BOTTOM_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BOTTOMSPACE
},
258 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameFixed" ), HANDLE_CUSTOM_FONT_NAME_FIXED
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FIXED
},
259 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSans" ), HANDLE_CUSTOM_FONT_NAME_SANS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SANS
},
260 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSerif" ), HANDLE_CUSTOM_FONT_NAME_SERIF
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SERIF
},
261 { RTL_CONSTASCII_STRINGPARAM( "DialogLibraries" ), HANDLE_DIALOG_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
262 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsBold"), HANDLE_CUSTOM_FONT_FIXED_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
263 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsItalic"), HANDLE_CUSTOM_FONT_FIXED_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
264 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsBold"), HANDLE_FONT_FUNCTIONS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
265 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsItalic"), HANDLE_FONT_FUNCTIONS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
266 { RTL_CONSTASCII_STRINGPARAM( "FontNameFunctions" ), HANDLE_FONT_NAME_FUNCTIONS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FUNCTION
},
267 { RTL_CONSTASCII_STRINGPARAM( "FontNameNumbers" ), HANDLE_FONT_NAME_NUMBERS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_NUMBER
},
268 { RTL_CONSTASCII_STRINGPARAM( "FontNameText" ), HANDLE_FONT_NAME_TEXT
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_TEXT
},
269 { RTL_CONSTASCII_STRINGPARAM( "FontNameVariables" ), HANDLE_FONT_NAME_VARIABLES
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_VARIABLE
},
270 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsBold"), HANDLE_FONT_NUMBERS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
271 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsItalic"), HANDLE_FONT_NUMBERS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
272 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsBold"), HANDLE_CUSTOM_FONT_SANS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
273 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsItalic"), HANDLE_CUSTOM_FONT_SANS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
274 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsBold"), HANDLE_CUSTOM_FONT_SERIF_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
275 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsItalic"), HANDLE_CUSTOM_FONT_SERIF_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
276 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsBold"), HANDLE_FONT_TEXT_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
277 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsItalic"), HANDLE_FONT_TEXT_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
278 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsBold"), HANDLE_FONT_VARIABLES_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
279 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsItalic"), HANDLE_FONT_VARIABLES_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
280 { RTL_CONSTASCII_STRINGPARAM( "Formula" ), HANDLE_FORMULA
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0},
281 { RTL_CONSTASCII_STRINGPARAM( "IsScaleAllBrackets" ), HANDLE_IS_SCALE_ALL_BRACKETS
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
282 { RTL_CONSTASCII_STRINGPARAM( "IsTextMode" ), HANDLE_IS_TEXT_MODE
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
283 { RTL_CONSTASCII_STRINGPARAM( "GreekCharStyle" ), HANDLE_GREEK_CHAR_STYLE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
284 { RTL_CONSTASCII_STRINGPARAM( "LeftMargin" ), HANDLE_LEFT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LEFTSPACE
},
285 { RTL_CONSTASCII_STRINGPARAM( "PrinterName" ), HANDLE_PRINTER_NAME
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0 },
286 { RTL_CONSTASCII_STRINGPARAM( "PrinterSetup" ), HANDLE_PRINTER_SETUP
, &::getCppuType((const Sequence
< sal_Int8
>*)0), PROPERTY_NONE
, 0 },
287 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketDistance" ), HANDLE_RELATIVE_BRACKET_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSPACE
},
288 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketExcessSize" ), HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSIZE
},
289 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightFunctions" ), HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_FUNCTION
},
290 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightIndices" ), HANDLE_RELATIVE_FONT_HEIGHT_INDICES
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_INDEX
},
291 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightLimits" ), HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_LIMITS
},
292 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightOperators" ), HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_OPERATOR
},
293 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightText" ), HANDLE_RELATIVE_FONT_HEIGHT_TEXT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_TEXT
},
294 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarExcessLength"), HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_FRACTION
},
295 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarLineWeight" ), HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_STROKEWIDTH
},
296 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionDenominatorDepth"), HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_DENOMINATOR
},
297 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionNumeratorHeight" ), HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NUMERATOR
},
298 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSubscript" ), HANDLE_RELATIVE_INDEX_SUBSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUBSCRIPT
},
299 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSuperscript" ), HANDLE_RELATIVE_INDEX_SUPERSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUPERSCRIPT
},
300 { RTL_CONSTASCII_STRINGPARAM( "RelativeLineSpacing" ), HANDLE_RELATIVE_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_VERTICAL
},
301 { RTL_CONSTASCII_STRINGPARAM( "RelativeLowerLimitDistance" ), HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LOWERLIMIT
},
302 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixColumnSpacing" ), HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXCOL
},
303 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixLineSpacing" ), HANDLE_RELATIVE_MATRIX_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXROW
},
304 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorExcessSize" ), HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSIZE
},
305 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorSpacing" ), HANDLE_RELATIVE_OPERATOR_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSPACE
},
306 { RTL_CONSTASCII_STRINGPARAM( "RelativeRootSpacing" ), HANDLE_RELATIVE_ROOT_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ROOT
},
307 { RTL_CONSTASCII_STRINGPARAM( "RelativeScaleBracketExcessSize" ), HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NORMALBRACKETSIZE
},
308 { RTL_CONSTASCII_STRINGPARAM( "RelativeSpacing" ), HANDLE_RELATIVE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_HORIZONTAL
},
309 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolMinimumHeight" ), HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSPACE
},
310 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolPrimaryHeight" ), HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSIZE
},
311 { RTL_CONSTASCII_STRINGPARAM( "RelativeUpperLimitDistance" ), HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_UPPERLIMIT
},
312 { RTL_CONSTASCII_STRINGPARAM( "RightMargin" ), HANDLE_RIGHT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_RIGHTSPACE
},
313 { RTL_CONSTASCII_STRINGPARAM( "RuntimeUID" ), HANDLE_RUNTIME_UID
, &::getCppuType(static_cast< const rtl::OUString
* >(0)), PropertyAttribute::READONLY
, 0 },
314 { RTL_CONSTASCII_STRINGPARAM( "Symbols" ), HANDLE_SYMBOLS
, &::getCppuType((const Sequence
< SymbolDescriptor
> *)0), PROPERTY_NONE
, 0 },
315 { RTL_CONSTASCII_STRINGPARAM( "UserDefinedSymbolsInUse" ), HANDLE_USED_SYMBOLS
, &::getCppuType((const Sequence
< SymbolDescriptor
> *)0), PropertyAttribute::READONLY
, 0 },
316 { RTL_CONSTASCII_STRINGPARAM( "TopMargin" ), HANDLE_TOP_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_TOPSPACE
},
317 // --> PB 2004-08-25 #i33095# Security Options
318 { RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY
, &::getBooleanCppuType(), PROPERTY_NONE
, 0 },
320 // --> 3.7.2010 #i972#
321 { RTL_CONSTASCII_STRINGPARAM( "BaseLine"), HANDLE_BASELINE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
323 { NULL
, 0, 0, NULL
, 0, 0 }
325 PropertySetInfo
*pInfo
= new PropertySetInfo ( aModelPropertyInfoMap
);
328 //-----------------------------------------------------------------------
329 SmModel::SmModel( SfxObjectShell
*pObjSh
)
330 : SfxBaseModel(pObjSh
)
331 , PropertySetHelper ( lcl_createModelPropertyInfo () )
332 , m_pPrintUIOptions( NULL
)
336 //-----------------------------------------------------------------------
337 SmModel::~SmModel() throw ()
339 delete m_pPrintUIOptions
;
341 /*-- 28.03.00 14:18:17---------------------------------------------------
343 -----------------------------------------------------------------------*/
344 uno::Any SAL_CALL
SmModel::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
346 uno::Any aRet
= ::cppu::queryInterface ( rType
,
347 // OWeakObject interfaces
348 dynamic_cast< XInterface
* > ( static_cast< XUnoTunnel
* > ( this )),
349 static_cast< XWeak
* > ( this ),
350 // PropertySetHelper interfaces
351 static_cast< XPropertySet
* > ( this ),
352 static_cast< XMultiPropertySet
* > ( this ),
353 //static_cast< XPropertyState* > ( this ),
355 static_cast< XServiceInfo
* > ( this ),
356 static_cast< XRenderable
* > ( this ) );
357 if (!aRet
.hasValue())
358 aRet
= SfxBaseModel::queryInterface ( rType
);
361 /*-- 28.03.00 14:18:18---------------------------------------------------
363 -----------------------------------------------------------------------*/
364 void SAL_CALL
SmModel::acquire() throw()
366 OWeakObject::acquire();
368 /*-- 28.03.00 14:18:18---------------------------------------------------
370 -----------------------------------------------------------------------*/
371 void SAL_CALL
SmModel::release() throw()
373 OWeakObject::release();
375 /*-- 28.03.00 14:18:19---------------------------------------------------
377 -----------------------------------------------------------------------*/
378 uno::Sequence
< uno::Type
> SAL_CALL
SmModel::getTypes( ) throw(uno::RuntimeException
)
380 ::vos::OGuard
aGuard(Application::GetSolarMutex());
381 uno::Sequence
< uno::Type
> aTypes
= SfxBaseModel::getTypes();
382 sal_Int32 nLen
= aTypes
.getLength();
383 aTypes
.realloc(nLen
+ 4);
384 uno::Type
* pTypes
= aTypes
.getArray();
385 pTypes
[nLen
++] = ::getCppuType((Reference
<XServiceInfo
>*)0);
386 pTypes
[nLen
++] = ::getCppuType((Reference
<XPropertySet
>*)0);
387 pTypes
[nLen
++] = ::getCppuType((Reference
<XMultiPropertySet
>*)0);
388 pTypes
[nLen
++] = ::getCppuType((Reference
<XRenderable
>*)0);
390 // XPropertyState not supported?? (respective virtual functions from
391 // PropertySetHelper not overloaded)
392 //pTypes[nLen++] = ::getCppuType((Reference<XPropertyState>*)0);
396 /* -----------------------------28.03.00 14:23--------------------------------
398 ---------------------------------------------------------------------------*/
399 const uno::Sequence
< sal_Int8
> & SmModel::getUnoTunnelId()
401 static osl::Mutex aCreateMutex
;
402 osl::Guard
<osl::Mutex
> aGuard( aCreateMutex
);
404 static uno::Sequence
< sal_Int8
> aSeq
;
405 if(!aSeq
.getLength())
408 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
411 } /* -----------------------------28.03.00 14:23--------------------------------
413 ---------------------------------------------------------------------------*/
414 sal_Int64 SAL_CALL
SmModel::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
415 throw(uno::RuntimeException
)
417 if( rId
.getLength() == 16
418 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
419 rId
.getConstArray(), 16 ) )
421 return sal::static_int_cast
< sal_Int64
>(reinterpret_cast< sal_uIntPtr
>(this));
424 return SfxBaseModel::getSomething( rId
);
426 /*-- 07.01.00 16:32:59---------------------------------------------------
428 -----------------------------------------------------------------------*/
429 /*-- 07.01.00 16:33:00---------------------------------------------------
431 -----------------------------------------------------------------------*/
432 sal_Int16
lcl_AnyToINT16(const uno::Any
& rAny
)
434 uno::TypeClass eType
= rAny
.getValueType().getTypeClass();
437 if( eType
== uno::TypeClass_DOUBLE
)
438 nRet
= (sal_Int16
)*(double*)rAny
.getValue();
439 else if( eType
== uno::TypeClass_FLOAT
)
440 nRet
= (sal_Int16
)*(float*)rAny
.getValue();
445 //-----------------------------------------------------------------------------
447 OUString
SmModel::getImplementationName(void) throw( uno::RuntimeException
)
449 return getImplementationName_Static();
453 ::rtl::OUString
SmModel::getImplementationName_Static()
455 return rtl::OUString::createFromAscii("com.sun.star.comp.math.FormulaDocument");
458 /*-- 20.01.04 11:21:00---------------------------------------------------
460 -----------------------------------------------------------------------*/
461 sal_Bool
SmModel::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
464 rServiceName
== A2OU("com.sun.star.document.OfficeDocument" ) ||
465 rServiceName
== A2OU("com.sun.star.formula.FormulaProperties")
468 /*-- 20.01.04 11:21:00---------------------------------------------------
470 -----------------------------------------------------------------------*/
471 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames(void) throw( uno::RuntimeException
)
473 return getSupportedServiceNames_Static();
476 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames_Static(void)
478 ::vos::OGuard
aGuard(Application::GetSolarMutex());
480 uno::Sequence
< OUString
> aRet(2);
481 OUString
* pArray
= aRet
.getArray();
482 pArray
[0] = A2OU("com.sun.star.document.OfficeDocument");
483 pArray
[1] = A2OU("com.sun.star.formula.FormulaProperties");
487 void SmModel::_setPropertyValues(const PropertyMapEntry
** ppEntries
, const Any
* pValues
)
488 throw( UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
)
490 ::vos::OGuard
aGuard(Application::GetSolarMutex());
492 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
494 if ( NULL
== pDocSh
)
495 throw UnknownPropertyException();
497 SmFormat aFormat
= pDocSh
->GetFormat();
499 for (; *ppEntries
; ppEntries
++, pValues
++ )
501 if ((*ppEntries
)->mnAttributes
& PropertyAttribute::READONLY
)
502 throw PropertyVetoException();
504 switch ( (*ppEntries
)->mnHandle
)
510 pDocSh
->SetText(aText
);
513 case HANDLE_FONT_NAME_VARIABLES
:
514 case HANDLE_FONT_NAME_FUNCTIONS
:
515 case HANDLE_FONT_NAME_NUMBERS
:
516 case HANDLE_FONT_NAME_TEXT
:
517 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
518 case HANDLE_CUSTOM_FONT_NAME_SANS
:
519 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
523 String sFontName
= aText
;
525 throw IllegalArgumentException();
527 if(aFormat
.GetFont((*ppEntries
)->mnMemberId
).GetName() != sFontName
)
529 const SmFace rOld
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
531 SmFace
aSet( sFontName
, rOld
.GetSize() );
532 aSet
.SetBorderWidth( rOld
.GetBorderWidth() );
533 aSet
.SetAlign( ALIGN_BASELINE
);
534 aFormat
.SetFont( (*ppEntries
)->mnMemberId
, aSet
);
538 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
539 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
540 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
541 case HANDLE_FONT_VARIABLES_POSTURE
:
542 case HANDLE_FONT_FUNCTIONS_POSTURE
:
543 case HANDLE_FONT_NUMBERS_POSTURE
:
544 case HANDLE_FONT_TEXT_POSTURE
:
546 if((*pValues
).getValueType() != ::getBooleanCppuType())
547 throw IllegalArgumentException();
548 sal_Bool bVal
= *(sal_Bool
*)(*pValues
).getValue();
549 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
550 aNewFont
.SetItalic((bVal
) ? ITALIC_NORMAL
: ITALIC_NONE
);
551 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
554 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
555 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
556 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
557 case HANDLE_FONT_VARIABLES_WEIGHT
:
558 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
559 case HANDLE_FONT_NUMBERS_WEIGHT
:
560 case HANDLE_FONT_TEXT_WEIGHT
:
562 if((*pValues
).getValueType() != ::getBooleanCppuType())
563 throw IllegalArgumentException();
564 sal_Bool bVal
= *(sal_Bool
*)(*pValues
).getValue();
565 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
566 aNewFont
.SetWeight((bVal
) ? WEIGHT_BOLD
: WEIGHT_NORMAL
);
567 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
570 case HANDLE_BASE_FONT_HEIGHT
:
573 sal_Int16 nVal
= lcl_AnyToINT16(*pValues
);
575 throw IllegalArgumentException();
576 Size aSize
= aFormat
.GetBaseSize();
578 nVal
= static_cast < sal_Int16
> ( TWIP_TO_MM100(nVal
) );
579 aSize
.Height() = nVal
;
580 aFormat
.SetBaseSize(aSize
);
582 // apply base size to fonts
583 const Size
aTmp( aFormat
.GetBaseSize() );
584 for (sal_uInt16 i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
585 aFormat
.SetFontSize(i
, aTmp
);
588 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
589 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
590 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
591 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
592 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
597 throw IllegalArgumentException();
598 aFormat
.SetRelSize((*ppEntries
)->mnMemberId
, nVal
);
602 case HANDLE_IS_TEXT_MODE
:
604 aFormat
.SetTextmode(*(sal_Bool
*)(*pValues
).getValue());
608 case HANDLE_GREEK_CHAR_STYLE
:
612 if (nVal
< 0 || nVal
> 2)
613 throw IllegalArgumentException();
614 aFormat
.SetGreekCharStyle( nVal
);
618 case HANDLE_ALIGNMENT
:
620 // SmHorAlign uses the same values as HorizontalAlignment
623 if(nVal
< 0 || nVal
> 2)
624 throw IllegalArgumentException();
625 aFormat
.SetHorAlign((SmHorAlign
)nVal
);
629 case HANDLE_RELATIVE_SPACING
:
630 case HANDLE_RELATIVE_LINE_SPACING
:
631 case HANDLE_RELATIVE_ROOT_SPACING
:
632 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
633 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
634 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
635 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
636 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
637 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
638 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
639 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
640 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
641 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
642 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
643 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
644 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
645 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
646 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
647 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
648 case HANDLE_RELATIVE_OPERATOR_SPACING
:
649 case HANDLE_LEFT_MARGIN
:
650 case HANDLE_RIGHT_MARGIN
:
651 case HANDLE_TOP_MARGIN
:
652 case HANDLE_BOTTOM_MARGIN
:
657 throw IllegalArgumentException();
658 aFormat
.SetDistance((*ppEntries
)->mnMemberId
, nVal
);
661 case HANDLE_IS_SCALE_ALL_BRACKETS
:
662 aFormat
.SetScaleNormalBrackets(*(sal_Bool
*)(*pValues
).getValue());
664 case HANDLE_PRINTER_NAME
:
666 // embedded documents just ignore this property for now
667 if ( pDocSh
->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
)
669 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
672 OUString sPrinterName
;
673 if (*pValues
>>= sPrinterName
)
675 if ( sPrinterName
.getLength() )
677 SfxPrinter
*pNewPrinter
= new SfxPrinter ( pPrinter
->GetOptions().Clone(), sPrinterName
);
678 if (pNewPrinter
->IsKnown())
679 pDocSh
->SetPrinter ( pNewPrinter
);
685 throw IllegalArgumentException();
690 case HANDLE_PRINTER_SETUP
:
692 Sequence
< sal_Int8
> aSequence
;
693 if ( *pValues
>>= aSequence
)
695 sal_uInt32 nSize
= aSequence
.getLength();
696 SvMemoryStream
aStream ( aSequence
.getArray(), nSize
, STREAM_READ
);
697 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
698 static sal_uInt16 __READONLY_DATA nRange
[] =
700 SID_PRINTSIZE
, SID_PRINTSIZE
,
701 SID_PRINTZOOM
, SID_PRINTZOOM
,
702 SID_PRINTTITLE
, SID_PRINTTITLE
,
703 SID_PRINTTEXT
, SID_PRINTTEXT
,
704 SID_PRINTFRAME
, SID_PRINTFRAME
,
705 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
708 SfxItemSet
*pItemSet
= new SfxItemSet( pDocSh
->GetPool(), nRange
);
709 SmModule
*pp
= SM_MOD();
710 pp
->GetConfig()->ConfigToItemSet(*pItemSet
);
711 SfxPrinter
*pPrinter
= SfxPrinter::Create ( aStream
, pItemSet
);
713 pDocSh
->SetPrinter( pPrinter
);
716 throw IllegalArgumentException();
722 Sequence
< SymbolDescriptor
> aSequence
;
723 if ( *pValues
>>= aSequence
)
725 sal_uInt32 nSize
= aSequence
.getLength();
726 SmModule
*pp
= SM_MOD();
727 SmSymbolManager
&rManager
= pp
->GetSymbolManager();
728 SymbolDescriptor
*pDescriptor
= aSequence
.getArray();
729 for (sal_uInt32 i
= 0; i
< nSize
; i
++, pDescriptor
++)
732 aFont
.SetName ( pDescriptor
->sFontName
);
733 aFont
.SetCharSet ( static_cast < rtl_TextEncoding
> (pDescriptor
->nCharSet
) );
734 aFont
.SetFamily ( static_cast < FontFamily
> (pDescriptor
->nFamily
) );
735 aFont
.SetPitch ( static_cast < FontPitch
> (pDescriptor
->nPitch
) );
736 aFont
.SetWeight ( static_cast < FontWeight
> (pDescriptor
->nWeight
) );
737 aFont
.SetItalic ( static_cast < FontItalic
> (pDescriptor
->nItalic
) );
738 SmSym
aSymbol ( pDescriptor
->sName
, aFont
, static_cast < sal_Unicode
> (pDescriptor
->nCharacter
),
739 pDescriptor
->sSymbolSet
);
740 aSymbol
.SetExportName ( pDescriptor
->sExportName
);
741 aSymbol
.SetDocSymbol( sal_True
);
742 rManager
.AddOrReplaceSymbol ( aSymbol
);
746 throw IllegalArgumentException();
749 // --> PB 2004-08-25 #i33095# Security Options
750 case HANDLE_LOAD_READONLY
:
752 if ( (*pValues
).getValueType() != ::getBooleanCppuType() )
753 throw IllegalArgumentException();
754 sal_Bool bReadonly
= sal_False
;
755 if ( *pValues
>>= bReadonly
)
756 pDocSh
->SetLoadReadonly( bReadonly
);
763 pDocSh
->SetFormat( aFormat
);
765 // #i67283# since about all of the above changes are likely to change
766 // the formula size we have to recalculate the vis-area now
767 pDocSh
->SetVisArea( Rectangle( Point(0, 0), pDocSh
->GetSize() ) );
770 void SmModel::_getPropertyValues( const PropertyMapEntry
**ppEntries
, Any
*pValue
)
771 throw( UnknownPropertyException
, WrappedTargetException
)
773 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
775 if ( NULL
== pDocSh
)
776 throw UnknownPropertyException();
778 const SmFormat
& aFormat
= pDocSh
->GetFormat();
780 for (; *ppEntries
; ppEntries
++, pValue
++ )
782 switch ( (*ppEntries
)->mnHandle
)
785 *pValue
<<= OUString(pDocSh
->GetText());
787 case HANDLE_FONT_NAME_VARIABLES
:
788 case HANDLE_FONT_NAME_FUNCTIONS
:
789 case HANDLE_FONT_NAME_NUMBERS
:
790 case HANDLE_FONT_NAME_TEXT
:
791 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
792 case HANDLE_CUSTOM_FONT_NAME_SANS
:
793 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
795 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
796 *pValue
<<= OUString(rFace
.GetName());
799 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
800 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
801 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
802 case HANDLE_FONT_VARIABLES_POSTURE
:
803 case HANDLE_FONT_FUNCTIONS_POSTURE
:
804 case HANDLE_FONT_NUMBERS_POSTURE
:
805 case HANDLE_FONT_TEXT_POSTURE
:
807 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
808 sal_Bool bVal
= IsItalic( rFace
);
809 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
812 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
813 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
814 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
815 case HANDLE_FONT_VARIABLES_WEIGHT
:
816 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
817 case HANDLE_FONT_NUMBERS_WEIGHT
:
818 case HANDLE_FONT_TEXT_WEIGHT
:
820 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
821 sal_Bool bVal
= IsBold( rFace
); // bold?
822 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
825 case HANDLE_BASE_FONT_HEIGHT
:
828 sal_Int16 nVal
= static_cast < sal_Int16
> (aFormat
.GetBaseSize().Height());
829 nVal
= static_cast < sal_Int16
> (MM100_TO_TWIP(nVal
));
830 nVal
= (nVal
+ 10) / 20;
834 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
835 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
836 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
837 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
838 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
839 *pValue
<<= (sal_Int16
) aFormat
.GetRelSize((*ppEntries
)->mnMemberId
);
842 case HANDLE_IS_TEXT_MODE
:
844 sal_Bool bVal
= aFormat
.IsTextmode();
845 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
849 case HANDLE_GREEK_CHAR_STYLE
:
850 *pValue
<<= (sal_Int16
)aFormat
.GetGreekCharStyle();
853 case HANDLE_ALIGNMENT
:
854 // SmHorAlign uses the same values as HorizontalAlignment
855 *pValue
<<= (sal_Int16
)aFormat
.GetHorAlign();
858 case HANDLE_RELATIVE_SPACING
:
859 case HANDLE_RELATIVE_LINE_SPACING
:
860 case HANDLE_RELATIVE_ROOT_SPACING
:
861 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
862 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
863 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
864 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
865 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
866 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
867 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
868 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
869 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
870 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
871 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
872 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
873 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
874 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
875 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
876 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
877 case HANDLE_RELATIVE_OPERATOR_SPACING
:
878 case HANDLE_LEFT_MARGIN
:
879 case HANDLE_RIGHT_MARGIN
:
880 case HANDLE_TOP_MARGIN
:
881 case HANDLE_BOTTOM_MARGIN
:
882 *pValue
<<= (sal_Int16
)aFormat
.GetDistance((*ppEntries
)->mnMemberId
);
884 case HANDLE_IS_SCALE_ALL_BRACKETS
:
886 sal_Bool bVal
= aFormat
.IsScaleNormalBrackets();
887 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
890 case HANDLE_PRINTER_NAME
:
892 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
893 *pValue
<<= pPrinter
? OUString ( pPrinter
->GetName()) : OUString();
896 case HANDLE_PRINTER_SETUP
:
898 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ();
901 SvMemoryStream aStream
;
902 pPrinter
->Store( aStream
);
903 aStream
.Seek ( STREAM_SEEK_TO_END
);
904 sal_uInt32 nSize
= aStream
.Tell();
905 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
906 Sequence
< sal_Int8
> aSequence ( nSize
);
907 aStream
.Read ( aSequence
.getArray(), nSize
);
908 *pValue
<<= aSequence
;
913 case HANDLE_USED_SYMBOLS
:
915 const bool bUsedSymbolsOnly
= (*ppEntries
)->mnHandle
== HANDLE_USED_SYMBOLS
;
916 const std::set
< rtl::OUString
> &rUsedSymbols
= pDocSh
->GetUsedSymbols();
919 SmModule
*pp
= SM_MOD();
920 const SmSymbolManager
&rManager
= pp
->GetSymbolManager();
921 vector
< const SmSym
* > aVector
;
923 const SymbolPtrVec_t
aSymbols( rManager
.GetSymbols() );
925 for (size_t i
= 0; i
< aSymbols
.size(); ++i
)
927 const SmSym
* pSymbol
= aSymbols
[ i
];
928 const bool bIsUsedSymbol
= rUsedSymbols
.find( pSymbol
->GetName() ) != rUsedSymbols
.end();
929 if (pSymbol
&& !pSymbol
->IsPredefined() &&
930 (!bUsedSymbolsOnly
|| bIsUsedSymbol
))
932 aVector
.push_back ( pSymbol
);
936 Sequence
< SymbolDescriptor
> aSequence ( nCount
);
937 SymbolDescriptor
* pDescriptor
= aSequence
.getArray();
939 vector
< const SmSym
* >::const_iterator aIter
= aVector
.begin(), aEnd
= aVector
.end();
940 for(; aIter
!= aEnd
; pDescriptor
++, aIter
++)
942 pDescriptor
->sName
= (*aIter
)->GetName();
943 pDescriptor
->sExportName
= (*aIter
)->GetExportName();
944 pDescriptor
->sSymbolSet
= (*aIter
)->GetSymbolSetName();
945 pDescriptor
->nCharacter
= static_cast < sal_Int32
> ((*aIter
)->GetCharacter());
947 Font rFont
= (*aIter
)->GetFace();
948 pDescriptor
->sFontName
= rFont
.GetName();
949 pDescriptor
->nCharSet
= sal::static_int_cast
< sal_Int16
>(rFont
.GetCharSet());
950 pDescriptor
->nFamily
= sal::static_int_cast
< sal_Int16
>(rFont
.GetFamily());
951 pDescriptor
->nPitch
= sal::static_int_cast
< sal_Int16
>(rFont
.GetPitch());
952 pDescriptor
->nWeight
= sal::static_int_cast
< sal_Int16
>(rFont
.GetWeight());
953 pDescriptor
->nItalic
= sal::static_int_cast
< sal_Int16
>(rFont
.GetItalic());
955 *pValue
<<= aSequence
;
958 case HANDLE_BASIC_LIBRARIES
:
959 *pValue
<<= pDocSh
->GetBasicContainer();
961 case HANDLE_DIALOG_LIBRARIES
:
962 *pValue
<<= pDocSh
->GetDialogContainer();
964 case HANDLE_RUNTIME_UID
:
965 *pValue
<<= getRuntimeUID();
967 // --> PB 2004-08-25 #i33095# Security Options
968 case HANDLE_LOAD_READONLY
:
970 *pValue
<<= pDocSh
->IsLoadReadonly();
974 // --> 3.7.2010 #i972#
975 case HANDLE_BASELINE
:
977 if ( !pDocSh
->pTree
)
981 if ( !pDocSh
->IsFormulaArranged() )
982 pDocSh
->ArrangeFormula();
984 *pValue
<<= static_cast<sal_Int32
>( pDocSh
->pTree
->GetFormulaBaseline() );
993 //////////////////////////////////////////////////////////////////////
995 sal_Int32 SAL_CALL
SmModel::getRendererCount(
996 const uno::Any
& /*rSelection*/,
997 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
998 throw (IllegalArgumentException
, RuntimeException
)
1000 ::vos::OGuard
aGuard(Application::GetSolarMutex());
1005 static Size
lcl_GuessPaperSize()
1008 Reference
< XMultiServiceFactory
> xMgr( getProcessServiceFactory() );
1009 LocaleDataWrapper
aLocWrp( xMgr
, AllSettings().GetLocale() );
1010 if( MEASURE_METRIC
== aLocWrp
.getMeasurementSystemEnum() )
1013 PaperInfo
aInfo( PAPER_A4
);
1014 aRes
.Width() = aInfo
.getWidth();
1015 aRes
.Height() = aInfo
.getHeight();
1020 PaperInfo
aInfo( PAPER_LETTER
);
1021 aRes
.Width() = aInfo
.getWidth();
1022 aRes
.Height() = aInfo
.getHeight();
1027 uno::Sequence
< beans::PropertyValue
> SAL_CALL
SmModel::getRenderer(
1028 sal_Int32 nRenderer
,
1029 const uno::Any
& /*rSelection*/,
1030 const uno::Sequence
< beans::PropertyValue
>& /*rxOptions*/ )
1031 throw (IllegalArgumentException
, RuntimeException
)
1033 ::vos::OGuard
aGuard(Application::GetSolarMutex());
1036 throw IllegalArgumentException();
1038 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
1040 throw RuntimeException();
1042 SmPrinterAccess
aPrinterAccess( *pDocSh
);
1043 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
1044 //Point aPrtPageOffset( pPrinter->GetPageOffset() );
1045 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
1047 // if paper size is 0 (usually if no 'real' printer is found),
1048 // guess the paper size
1049 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
1050 aPrtPaperSize
= lcl_GuessPaperSize();
1051 awt::Size
aPageSize( aPrtPaperSize
.Width(), aPrtPaperSize
.Height() );
1053 uno::Sequence
< beans::PropertyValue
> aRenderer(1);
1054 PropertyValue
&rValue
= aRenderer
.getArray()[0];
1055 rValue
.Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
1056 rValue
.Value
<<= aPageSize
;
1058 if (!m_pPrintUIOptions
)
1059 m_pPrintUIOptions
= new SmPrintUIOptions();
1060 m_pPrintUIOptions
->appendPrintUIOptions( aRenderer
);
1065 void SAL_CALL
SmModel::render(
1066 sal_Int32 nRenderer
,
1067 const uno::Any
& rSelection
,
1068 const uno::Sequence
< beans::PropertyValue
>& rxOptions
)
1069 throw (IllegalArgumentException
, RuntimeException
)
1071 ::vos::OGuard
aGuard(Application::GetSolarMutex());
1074 throw IllegalArgumentException();
1076 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
1078 throw RuntimeException();
1080 // get device to be rendered in
1081 uno::Reference
< awt::XDevice
> xRenderDevice
;
1082 for (sal_Int32 i
= 0, nCount
= rxOptions
.getLength(); i
< nCount
; ++i
)
1084 if( rxOptions
[i
].Name
== OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
1085 rxOptions
[i
].Value
>>= xRenderDevice
;
1088 if (xRenderDevice
.is())
1090 VCLXDevice
* pDevice
= VCLXDevice::GetImplementation( xRenderDevice
);
1091 OutputDevice
* pOut
= pDevice
? pDevice
->GetOutputDevice() : NULL
;
1094 throw RuntimeException();
1096 pOut
->SetMapMode( MAP_100TH_MM
);
1098 uno::Reference
< frame::XModel
> xModel
;
1099 rSelection
>>= xModel
;
1100 if (xModel
== pDocSh
->GetModel())
1102 //!! when called via API we may not have an active view
1103 //!! thus we go and look for a view that can be used.
1104 const TypeId aTypeId
= TYPE( SmViewShell
);
1105 SfxViewShell
* pViewSh
= SfxViewShell::GetFirst( &aTypeId
, sal_False
/* search non-visible views as well*/ );
1106 while (pViewSh
&& pViewSh
->GetObjectShell() != pDocSh
)
1107 pViewSh
= SfxViewShell::GetNext( *pViewSh
, &aTypeId
, sal_False
/* search non-visible views as well*/ );
1108 SmViewShell
*pView
= PTR_CAST( SmViewShell
, pViewSh
);
1109 DBG_ASSERT( pView
, "SmModel::render : no SmViewShell found" );
1113 SmPrinterAccess
aPrinterAccess( *pDocSh
);
1114 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
1116 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
1117 Size
aOutputSize ( pPrinter
->GetOutputSize() );
1118 Point
aPrtPageOffset( pPrinter
->GetPageOffset() );
1120 // no real printer ??
1121 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
1123 aPrtPaperSize
= lcl_GuessPaperSize();
1124 // factors from Windows DIN A4
1125 aOutputSize
= Size( (long)(aPrtPaperSize
.Width() * 0.941),
1126 (long)(aPrtPaperSize
.Height() * 0.961));
1127 aPrtPageOffset
= Point( (long)(aPrtPaperSize
.Width() * 0.0250),
1128 (long)(aPrtPaperSize
.Height() * 0.0214));
1131 Rectangle
OutputRect( aZeroPoint
, aOutputSize
);
1134 // set minimum top and bottom border
1135 if (aPrtPageOffset
.Y() < 2000)
1136 OutputRect
.Top() += 2000 - aPrtPageOffset
.Y();
1137 if ((aPrtPaperSize
.Height() - (aPrtPageOffset
.Y() + OutputRect
.Bottom())) < 2000)
1138 OutputRect
.Bottom() -= 2000 - (aPrtPaperSize
.Height() -
1139 (aPrtPageOffset
.Y() + OutputRect
.Bottom()));
1141 // set minimum left and right border
1142 if (aPrtPageOffset
.X() < 2500)
1143 OutputRect
.Left() += 2500 - aPrtPageOffset
.X();
1144 if ((aPrtPaperSize
.Width() - (aPrtPageOffset
.X() + OutputRect
.Right())) < 1500)
1145 OutputRect
.Right() -= 1500 - (aPrtPaperSize
.Width() -
1146 (aPrtPageOffset
.X() + OutputRect
.Right()));
1148 if (!m_pPrintUIOptions
)
1149 m_pPrintUIOptions
= new SmPrintUIOptions();
1150 m_pPrintUIOptions
->processProperties( rxOptions
);
1152 pView
->Impl_Print( *pOut
, *m_pPrintUIOptions
, Rectangle( OutputRect
), Point() );
1154 // release SmPrintUIOptions when everything is done.
1155 // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
1156 if (m_pPrintUIOptions
->getBoolValue( "IsLastPage", sal_False
))
1158 delete m_pPrintUIOptions
; m_pPrintUIOptions
= 0;
1165 void SAL_CALL
SmModel::setParent( const uno::Reference
< uno::XInterface
>& xParent
)
1166 throw( lang::NoSupportException
, uno::RuntimeException
)
1168 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1169 SfxBaseModel::setParent( xParent
);
1170 uno::Reference
< lang::XUnoTunnel
> xParentTunnel( xParent
, uno::UNO_QUERY
);
1171 if ( xParentTunnel
.is() )
1173 SvGlobalName
aSfxIdent( SFX_GLOBAL_CLASSID
);
1174 SfxObjectShell
* pDoc
= reinterpret_cast<SfxObjectShell
*>(xParentTunnel
->getSomething(
1175 uno::Sequence
< sal_Int8
>( aSfxIdent
.GetByteSequence() ) ) );
1177 GetObjectShell()->OnDocumentPrinterChanged( pDoc
->GetDocumentPrinter() );