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() >= 18, "resource incomplete" );
85 if( aLocalizedStrings
.Count() < 18 ) // 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() );
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 aLocalizedStrings
.GetString( 3 ),
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( 4 ),
115 aLocalizedStrings
.GetString( 5 ),
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( 6 ),
120 aLocalizedStrings
.GetString( 7 ),
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( 8 ), 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( 9 );
130 aChoices
[1] = aLocalizedStrings
.GetString( 11 );
131 aChoices
[2] = aLocalizedStrings
.GetString( 13 );
132 Sequence
< rtl::OUString
> aHelpTexts( 3 );
133 aHelpTexts
[0] = aLocalizedStrings
.GetString( 10 );
134 aHelpTexts
[1] = aLocalizedStrings
.GetString( 12 );
135 aHelpTexts
[2] = aLocalizedStrings
.GetString( 14 );
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 aLocalizedStrings
.GetString( 14 ),
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 ////////////////////////////////////////////////////////////
174 #define PROPERTY_NONE 0
175 enum SmModelPropertyHandles
178 HANDLE_FONT_NAME_VARIABLES
,
179 HANDLE_FONT_NAME_FUNCTIONS
,
180 HANDLE_FONT_NAME_NUMBERS
,
181 HANDLE_FONT_NAME_TEXT
,
182 HANDLE_CUSTOM_FONT_NAME_SERIF
,
183 HANDLE_CUSTOM_FONT_NAME_SANS
,
184 HANDLE_CUSTOM_FONT_NAME_FIXED
,
185 HANDLE_CUSTOM_FONT_FIXED_POSTURE
,
186 HANDLE_CUSTOM_FONT_FIXED_WEIGHT
,
187 HANDLE_CUSTOM_FONT_SANS_POSTURE
,
188 HANDLE_CUSTOM_FONT_SANS_WEIGHT
,
189 HANDLE_CUSTOM_FONT_SERIF_POSTURE
,
190 HANDLE_CUSTOM_FONT_SERIF_WEIGHT
,
191 HANDLE_FONT_VARIABLES_POSTURE
,
192 HANDLE_FONT_VARIABLES_WEIGHT
,
193 HANDLE_FONT_FUNCTIONS_POSTURE
,
194 HANDLE_FONT_FUNCTIONS_WEIGHT
,
195 HANDLE_FONT_NUMBERS_POSTURE
,
196 HANDLE_FONT_NUMBERS_WEIGHT
,
197 HANDLE_FONT_TEXT_POSTURE
,
198 HANDLE_FONT_TEXT_WEIGHT
,
199 HANDLE_BASE_FONT_HEIGHT
,
200 HANDLE_RELATIVE_FONT_HEIGHT_TEXT
,
201 HANDLE_RELATIVE_FONT_HEIGHT_INDICES
,
202 HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
,
203 HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
,
204 HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
,
206 HANDLE_GREEK_CHAR_STYLE
,
208 HANDLE_RELATIVE_SPACING
,
209 HANDLE_RELATIVE_LINE_SPACING
,
210 HANDLE_RELATIVE_ROOT_SPACING
,
211 HANDLE_RELATIVE_INDEX_SUPERSCRIPT
,
212 HANDLE_RELATIVE_INDEX_SUBSCRIPT
,
213 HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
,
214 HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
,
215 HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
,
216 HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
,
217 HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
,
218 HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
,
219 HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
,
220 HANDLE_RELATIVE_BRACKET_DISTANCE
,
221 HANDLE_IS_SCALE_ALL_BRACKETS
,
222 HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
,
223 HANDLE_RELATIVE_MATRIX_LINE_SPACING
,
224 HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
,
225 HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
,
226 HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
,
227 HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
,
228 HANDLE_RELATIVE_OPERATOR_SPACING
,
232 HANDLE_BOTTOM_MARGIN
,
234 HANDLE_PRINTER_SETUP
,
236 HANDLE_BASIC_LIBRARIES
, /* #93295# */
238 // --> PB 2004-08-25 #i33095# Security Options
239 HANDLE_LOAD_READONLY
,
241 HANDLE_DIALOG_LIBRARIES
// #i73329#
244 PropertySetInfo
* lcl_createModelPropertyInfo ()
246 static PropertyMapEntry aModelPropertyInfoMap
[] =
248 { RTL_CONSTASCII_STRINGPARAM( "Alignment" ), HANDLE_ALIGNMENT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
249 { RTL_CONSTASCII_STRINGPARAM( "BaseFontHeight" ), HANDLE_BASE_FONT_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
250 { RTL_CONSTASCII_STRINGPARAM( "BasicLibraries" ), HANDLE_BASIC_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
251 { RTL_CONSTASCII_STRINGPARAM( "BottomMargin" ), HANDLE_BOTTOM_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BOTTOMSPACE
},
252 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameFixed" ), HANDLE_CUSTOM_FONT_NAME_FIXED
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FIXED
},
253 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSans" ), HANDLE_CUSTOM_FONT_NAME_SANS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SANS
},
254 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSerif" ), HANDLE_CUSTOM_FONT_NAME_SERIF
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SERIF
},
255 { RTL_CONSTASCII_STRINGPARAM( "DialogLibraries" ), HANDLE_DIALOG_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
256 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsBold"), HANDLE_CUSTOM_FONT_FIXED_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
257 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsItalic"), HANDLE_CUSTOM_FONT_FIXED_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
258 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsBold"), HANDLE_FONT_FUNCTIONS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
259 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsItalic"), HANDLE_FONT_FUNCTIONS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
260 { RTL_CONSTASCII_STRINGPARAM( "FontNameFunctions" ), HANDLE_FONT_NAME_FUNCTIONS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FUNCTION
},
261 { RTL_CONSTASCII_STRINGPARAM( "FontNameNumbers" ), HANDLE_FONT_NAME_NUMBERS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_NUMBER
},
262 { RTL_CONSTASCII_STRINGPARAM( "FontNameText" ), HANDLE_FONT_NAME_TEXT
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_TEXT
},
263 { RTL_CONSTASCII_STRINGPARAM( "FontNameVariables" ), HANDLE_FONT_NAME_VARIABLES
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_VARIABLE
},
264 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsBold"), HANDLE_FONT_NUMBERS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
265 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsItalic"), HANDLE_FONT_NUMBERS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
266 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsBold"), HANDLE_CUSTOM_FONT_SANS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
267 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsItalic"), HANDLE_CUSTOM_FONT_SANS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
268 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsBold"), HANDLE_CUSTOM_FONT_SERIF_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
269 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsItalic"), HANDLE_CUSTOM_FONT_SERIF_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
270 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsBold"), HANDLE_FONT_TEXT_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
271 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsItalic"), HANDLE_FONT_TEXT_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
272 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsBold"), HANDLE_FONT_VARIABLES_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
273 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsItalic"), HANDLE_FONT_VARIABLES_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
274 { RTL_CONSTASCII_STRINGPARAM( "Formula" ), HANDLE_FORMULA
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0},
275 { RTL_CONSTASCII_STRINGPARAM( "IsScaleAllBrackets" ), HANDLE_IS_SCALE_ALL_BRACKETS
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
276 { RTL_CONSTASCII_STRINGPARAM( "IsTextMode" ), HANDLE_IS_TEXT_MODE
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
277 { RTL_CONSTASCII_STRINGPARAM( "GreekCharStyle" ), HANDLE_GREEK_CHAR_STYLE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
278 { RTL_CONSTASCII_STRINGPARAM( "LeftMargin" ), HANDLE_LEFT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LEFTSPACE
},
279 { RTL_CONSTASCII_STRINGPARAM( "PrinterName" ), HANDLE_PRINTER_NAME
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0 },
280 { RTL_CONSTASCII_STRINGPARAM( "PrinterSetup" ), HANDLE_PRINTER_SETUP
, &::getCppuType((const Sequence
< sal_Int8
>*)0), PROPERTY_NONE
, 0 },
281 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketDistance" ), HANDLE_RELATIVE_BRACKET_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSPACE
},
282 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketExcessSize" ), HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSIZE
},
283 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightFunctions" ), HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_FUNCTION
},
284 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightIndices" ), HANDLE_RELATIVE_FONT_HEIGHT_INDICES
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_INDEX
},
285 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightLimits" ), HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_LIMITS
},
286 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightOperators" ), HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_OPERATOR
},
287 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightText" ), HANDLE_RELATIVE_FONT_HEIGHT_TEXT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_TEXT
},
288 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarExcessLength"), HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_FRACTION
},
289 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarLineWeight" ), HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_STROKEWIDTH
},
290 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionDenominatorDepth"), HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_DENOMINATOR
},
291 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionNumeratorHeight" ), HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NUMERATOR
},
292 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSubscript" ), HANDLE_RELATIVE_INDEX_SUBSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUBSCRIPT
},
293 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSuperscript" ), HANDLE_RELATIVE_INDEX_SUPERSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUPERSCRIPT
},
294 { RTL_CONSTASCII_STRINGPARAM( "RelativeLineSpacing" ), HANDLE_RELATIVE_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_VERTICAL
},
295 { RTL_CONSTASCII_STRINGPARAM( "RelativeLowerLimitDistance" ), HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LOWERLIMIT
},
296 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixColumnSpacing" ), HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXCOL
},
297 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixLineSpacing" ), HANDLE_RELATIVE_MATRIX_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXROW
},
298 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorExcessSize" ), HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSIZE
},
299 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorSpacing" ), HANDLE_RELATIVE_OPERATOR_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSPACE
},
300 { RTL_CONSTASCII_STRINGPARAM( "RelativeRootSpacing" ), HANDLE_RELATIVE_ROOT_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ROOT
},
301 { RTL_CONSTASCII_STRINGPARAM( "RelativeScaleBracketExcessSize" ), HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NORMALBRACKETSIZE
},
302 { RTL_CONSTASCII_STRINGPARAM( "RelativeSpacing" ), HANDLE_RELATIVE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_HORIZONTAL
},
303 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolMinimumHeight" ), HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSPACE
},
304 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolPrimaryHeight" ), HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSIZE
},
305 { RTL_CONSTASCII_STRINGPARAM( "RelativeUpperLimitDistance" ), HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_UPPERLIMIT
},
306 { RTL_CONSTASCII_STRINGPARAM( "RightMargin" ), HANDLE_RIGHT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_RIGHTSPACE
},
307 { RTL_CONSTASCII_STRINGPARAM( "RuntimeUID" ), HANDLE_RUNTIME_UID
, &::getCppuType(static_cast< const rtl::OUString
* >(0)), PropertyAttribute::READONLY
, 0 },
308 { RTL_CONSTASCII_STRINGPARAM( "Symbols" ), HANDLE_SYMBOLS
, &::getCppuType((const Sequence
< SymbolDescriptor
> *)0), PROPERTY_NONE
, 0 },
309 { RTL_CONSTASCII_STRINGPARAM( "TopMargin" ), HANDLE_TOP_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_TOPSPACE
},
310 // --> PB 2004-08-25 #i33095# Security Options
311 { RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY
, &::getBooleanCppuType(), PROPERTY_NONE
, 0 },
313 { NULL
, 0, 0, NULL
, 0, 0 }
315 PropertySetInfo
*pInfo
= new PropertySetInfo ( aModelPropertyInfoMap
);
318 //-----------------------------------------------------------------------
319 SmModel::SmModel( SfxObjectShell
*pObjSh
)
320 : SfxBaseModel(pObjSh
)
321 , PropertySetHelper ( lcl_createModelPropertyInfo () )
322 , m_pPrintUIOptions( NULL
)
326 //-----------------------------------------------------------------------
327 SmModel::~SmModel() throw ()
329 delete m_pPrintUIOptions
;
331 /*-- 28.03.00 14:18:17---------------------------------------------------
333 -----------------------------------------------------------------------*/
334 uno::Any SAL_CALL
SmModel::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
336 uno::Any aRet
= ::cppu::queryInterface ( rType
,
337 // OWeakObject interfaces
338 dynamic_cast< XInterface
* > ( static_cast< XUnoTunnel
* > ( this )),
339 static_cast< XWeak
* > ( this ),
340 // PropertySetHelper interfaces
341 static_cast< XPropertySet
* > ( this ),
342 static_cast< XMultiPropertySet
* > ( this ),
343 //static_cast< XPropertyState* > ( this ),
345 static_cast< XServiceInfo
* > ( this ),
346 static_cast< XRenderable
* > ( this ) );
347 if (!aRet
.hasValue())
348 aRet
= SfxBaseModel::queryInterface ( rType
);
351 /*-- 28.03.00 14:18:18---------------------------------------------------
353 -----------------------------------------------------------------------*/
354 void SAL_CALL
SmModel::acquire() throw()
356 OWeakObject::acquire();
358 /*-- 28.03.00 14:18:18---------------------------------------------------
360 -----------------------------------------------------------------------*/
361 void SAL_CALL
SmModel::release() throw()
363 OWeakObject::release();
365 /*-- 28.03.00 14:18:19---------------------------------------------------
367 -----------------------------------------------------------------------*/
368 uno::Sequence
< uno::Type
> SAL_CALL
SmModel::getTypes( ) throw(uno::RuntimeException
)
370 ::vos::OGuard
aGuard(Application::GetSolarMutex());
371 uno::Sequence
< uno::Type
> aTypes
= SfxBaseModel::getTypes();
372 sal_Int32 nLen
= aTypes
.getLength();
373 aTypes
.realloc(nLen
+ 4);
374 uno::Type
* pTypes
= aTypes
.getArray();
375 pTypes
[nLen
++] = ::getCppuType((Reference
<XServiceInfo
>*)0);
376 pTypes
[nLen
++] = ::getCppuType((Reference
<XPropertySet
>*)0);
377 pTypes
[nLen
++] = ::getCppuType((Reference
<XMultiPropertySet
>*)0);
378 pTypes
[nLen
++] = ::getCppuType((Reference
<XRenderable
>*)0);
380 // XPropertyState not supported?? (respective virtual functions from
381 // PropertySetHelper not overloaded)
382 //pTypes[nLen++] = ::getCppuType((Reference<XPropertyState>*)0);
386 /* -----------------------------28.03.00 14:23--------------------------------
388 ---------------------------------------------------------------------------*/
389 const uno::Sequence
< sal_Int8
> & SmModel::getUnoTunnelId()
391 static osl::Mutex aCreateMutex
;
392 osl::Guard
<osl::Mutex
> aGuard( aCreateMutex
);
394 static uno::Sequence
< sal_Int8
> aSeq
;
395 if(!aSeq
.getLength())
398 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
401 } /* -----------------------------28.03.00 14:23--------------------------------
403 ---------------------------------------------------------------------------*/
404 sal_Int64 SAL_CALL
SmModel::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
405 throw(uno::RuntimeException
)
407 if( rId
.getLength() == 16
408 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
409 rId
.getConstArray(), 16 ) )
411 return sal::static_int_cast
< sal_Int64
>(reinterpret_cast< sal_uIntPtr
>(this));
414 return SfxBaseModel::getSomething( rId
);
416 /*-- 07.01.00 16:32:59---------------------------------------------------
418 -----------------------------------------------------------------------*/
419 /*-- 07.01.00 16:33:00---------------------------------------------------
421 -----------------------------------------------------------------------*/
422 sal_Int16
lcl_AnyToINT16(const uno::Any
& rAny
)
424 uno::TypeClass eType
= rAny
.getValueType().getTypeClass();
427 if( eType
== uno::TypeClass_DOUBLE
)
428 nRet
= (sal_Int16
)*(double*)rAny
.getValue();
429 else if( eType
== uno::TypeClass_FLOAT
)
430 nRet
= (sal_Int16
)*(float*)rAny
.getValue();
435 //-----------------------------------------------------------------------------
437 OUString
SmModel::getImplementationName(void) throw( uno::RuntimeException
)
439 return getImplementationName_Static();
443 ::rtl::OUString
SmModel::getImplementationName_Static()
445 return rtl::OUString::createFromAscii("com.sun.star.comp.math.FormulaDocument");
448 /*-- 20.01.04 11:21:00---------------------------------------------------
450 -----------------------------------------------------------------------*/
451 sal_Bool
SmModel::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
454 rServiceName
== A2OU("com.sun.star.document.OfficeDocument" ) ||
455 rServiceName
== A2OU("com.sun.star.formula.FormulaProperties")
458 /*-- 20.01.04 11:21:00---------------------------------------------------
460 -----------------------------------------------------------------------*/
461 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames(void) throw( uno::RuntimeException
)
463 return getSupportedServiceNames_Static();
466 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames_Static(void)
468 ::vos::OGuard
aGuard(Application::GetSolarMutex());
470 uno::Sequence
< OUString
> aRet(2);
471 OUString
* pArray
= aRet
.getArray();
472 pArray
[0] = A2OU("com.sun.star.document.OfficeDocument");
473 pArray
[1] = A2OU("com.sun.star.formula.FormulaProperties");
477 void SmModel::_setPropertyValues(const PropertyMapEntry
** ppEntries
, const Any
* pValues
)
478 throw( UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
)
480 ::vos::OGuard
aGuard(Application::GetSolarMutex());
482 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
484 if ( NULL
== pDocSh
)
485 throw UnknownPropertyException();
487 SmFormat aFormat
= pDocSh
->GetFormat();
489 for (; *ppEntries
; ppEntries
++, pValues
++ )
491 if ((*ppEntries
)->mnAttributes
& PropertyAttribute::READONLY
)
492 throw PropertyVetoException();
494 switch ( (*ppEntries
)->mnHandle
)
500 pDocSh
->SetText(aText
);
503 case HANDLE_FONT_NAME_VARIABLES
:
504 case HANDLE_FONT_NAME_FUNCTIONS
:
505 case HANDLE_FONT_NAME_NUMBERS
:
506 case HANDLE_FONT_NAME_TEXT
:
507 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
508 case HANDLE_CUSTOM_FONT_NAME_SANS
:
509 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
513 String sFontName
= aText
;
515 throw IllegalArgumentException();
517 if(aFormat
.GetFont((*ppEntries
)->mnMemberId
).GetName() != sFontName
)
519 const SmFace rOld
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
521 SmFace
aSet( sFontName
, rOld
.GetSize() );
522 aSet
.SetBorderWidth( rOld
.GetBorderWidth() );
523 aSet
.SetAlign( ALIGN_BASELINE
);
524 aFormat
.SetFont( (*ppEntries
)->mnMemberId
, aSet
);
528 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
529 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
530 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
531 case HANDLE_FONT_VARIABLES_POSTURE
:
532 case HANDLE_FONT_FUNCTIONS_POSTURE
:
533 case HANDLE_FONT_NUMBERS_POSTURE
:
534 case HANDLE_FONT_TEXT_POSTURE
:
536 if((*pValues
).getValueType() != ::getBooleanCppuType())
537 throw IllegalArgumentException();
538 BOOL bVal
= *(sal_Bool
*)(*pValues
).getValue();
539 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
540 aNewFont
.SetItalic((bVal
) ? ITALIC_NORMAL
: ITALIC_NONE
);
541 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
544 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
545 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
546 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
547 case HANDLE_FONT_VARIABLES_WEIGHT
:
548 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
549 case HANDLE_FONT_NUMBERS_WEIGHT
:
550 case HANDLE_FONT_TEXT_WEIGHT
:
552 if((*pValues
).getValueType() != ::getBooleanCppuType())
553 throw IllegalArgumentException();
554 BOOL bVal
= *(sal_Bool
*)(*pValues
).getValue();
555 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
556 aNewFont
.SetWeight((bVal
) ? WEIGHT_BOLD
: WEIGHT_NORMAL
);
557 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
560 case HANDLE_BASE_FONT_HEIGHT
:
563 sal_Int16 nVal
= lcl_AnyToINT16(*pValues
);
565 throw IllegalArgumentException();
566 Size aSize
= aFormat
.GetBaseSize();
568 nVal
= static_cast < sal_Int16
> ( TWIP_TO_MM100(nVal
) );
569 aSize
.Height() = nVal
;
570 aFormat
.SetBaseSize(aSize
);
572 // apply base size to fonts
573 const Size
aTmp( aFormat
.GetBaseSize() );
574 for (USHORT i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
575 aFormat
.SetFontSize(i
, aTmp
);
578 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
579 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
580 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
581 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
582 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
587 throw IllegalArgumentException();
588 aFormat
.SetRelSize((*ppEntries
)->mnMemberId
, nVal
);
592 case HANDLE_IS_TEXT_MODE
:
594 aFormat
.SetTextmode(*(sal_Bool
*)(*pValues
).getValue());
598 case HANDLE_GREEK_CHAR_STYLE
:
602 if (nVal
< 0 || nVal
> 2)
603 throw IllegalArgumentException();
604 aFormat
.SetGreekCharStyle( nVal
);
608 case HANDLE_ALIGNMENT
:
610 // SmHorAlign uses the same values as HorizontalAlignment
613 if(nVal
< 0 || nVal
> 2)
614 throw IllegalArgumentException();
615 aFormat
.SetHorAlign((SmHorAlign
)nVal
);
619 case HANDLE_RELATIVE_SPACING
:
620 case HANDLE_RELATIVE_LINE_SPACING
:
621 case HANDLE_RELATIVE_ROOT_SPACING
:
622 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
623 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
624 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
625 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
626 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
627 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
628 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
629 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
630 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
631 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
632 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
633 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
634 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
635 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
636 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
637 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
638 case HANDLE_RELATIVE_OPERATOR_SPACING
:
639 case HANDLE_LEFT_MARGIN
:
640 case HANDLE_RIGHT_MARGIN
:
641 case HANDLE_TOP_MARGIN
:
642 case HANDLE_BOTTOM_MARGIN
:
647 throw IllegalArgumentException();
648 aFormat
.SetDistance((*ppEntries
)->mnMemberId
, nVal
);
651 case HANDLE_IS_SCALE_ALL_BRACKETS
:
652 aFormat
.SetScaleNormalBrackets(*(sal_Bool
*)(*pValues
).getValue());
654 case HANDLE_PRINTER_NAME
:
656 // embedded documents just ignore this property for now
657 if ( pDocSh
->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
)
659 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
662 OUString sPrinterName
;
663 if (*pValues
>>= sPrinterName
)
665 if ( sPrinterName
.getLength() )
667 SfxPrinter
*pNewPrinter
= new SfxPrinter ( pPrinter
->GetOptions().Clone(), sPrinterName
);
668 if (pNewPrinter
->IsKnown())
669 pDocSh
->SetPrinter ( pNewPrinter
);
675 throw IllegalArgumentException();
680 case HANDLE_PRINTER_SETUP
:
682 Sequence
< sal_Int8
> aSequence
;
683 if ( *pValues
>>= aSequence
)
685 sal_uInt32 nSize
= aSequence
.getLength();
686 SvMemoryStream
aStream ( aSequence
.getArray(), nSize
, STREAM_READ
);
687 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
688 static sal_uInt16 __READONLY_DATA nRange
[] =
690 SID_PRINTSIZE
, SID_PRINTSIZE
,
691 SID_PRINTZOOM
, SID_PRINTZOOM
,
692 SID_PRINTTITLE
, SID_PRINTTITLE
,
693 SID_PRINTTEXT
, SID_PRINTTEXT
,
694 SID_PRINTFRAME
, SID_PRINTFRAME
,
695 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
698 SfxItemSet
*pItemSet
= new SfxItemSet( pDocSh
->GetPool(), nRange
);
699 SmModule
*pp
= SM_MOD();
700 pp
->GetConfig()->ConfigToItemSet(*pItemSet
);
701 SfxPrinter
*pPrinter
= SfxPrinter::Create ( aStream
, pItemSet
);
703 pDocSh
->SetPrinter( pPrinter
);
706 throw IllegalArgumentException();
712 Sequence
< SymbolDescriptor
> aSequence
;
713 if ( *pValues
>>= aSequence
)
715 sal_uInt32 nSize
= aSequence
.getLength();
716 SmModule
*pp
= SM_MOD();
717 SmSymbolManager
&rManager
= pp
->GetSymbolManager();
718 SymbolDescriptor
*pDescriptor
= aSequence
.getArray();
719 for (sal_uInt32 i
= 0; i
< nSize
; i
++, pDescriptor
++)
722 aFont
.SetName ( pDescriptor
->sFontName
);
723 aFont
.SetCharSet ( static_cast < rtl_TextEncoding
> (pDescriptor
->nCharSet
) );
724 aFont
.SetFamily ( static_cast < FontFamily
> (pDescriptor
->nFamily
) );
725 aFont
.SetPitch ( static_cast < FontPitch
> (pDescriptor
->nPitch
) );
726 aFont
.SetWeight ( static_cast < FontWeight
> (pDescriptor
->nWeight
) );
727 aFont
.SetItalic ( static_cast < FontItalic
> (pDescriptor
->nItalic
) );
728 SmSym
aSymbol ( pDescriptor
->sName
, aFont
, static_cast < sal_Unicode
> (pDescriptor
->nCharacter
),
729 pDescriptor
->sSymbolSet
);
730 aSymbol
.SetExportName ( pDescriptor
->sExportName
);
731 aSymbol
.SetDocSymbol( TRUE
);
732 rManager
.AddOrReplaceSymbol ( aSymbol
);
736 throw IllegalArgumentException();
739 // --> PB 2004-08-25 #i33095# Security Options
740 case HANDLE_LOAD_READONLY
:
742 if ( (*pValues
).getValueType() != ::getBooleanCppuType() )
743 throw IllegalArgumentException();
744 sal_Bool bReadonly
= FALSE
;
745 if ( *pValues
>>= bReadonly
)
746 pDocSh
->SetLoadReadonly( bReadonly
);
753 pDocSh
->SetFormat( aFormat
);
755 // #i67283# since about all of the above changes are likely to change
756 // the formula size we have to recalculate the vis-area now
757 pDocSh
->SetVisArea( Rectangle( Point(0, 0), pDocSh
->GetSize() ) );
760 void SmModel::_getPropertyValues( const PropertyMapEntry
**ppEntries
, Any
*pValue
)
761 throw( UnknownPropertyException
, WrappedTargetException
)
763 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
765 if ( NULL
== pDocSh
)
766 throw UnknownPropertyException();
768 const SmFormat
& aFormat
= pDocSh
->GetFormat();
770 for (; *ppEntries
; ppEntries
++, pValue
++ )
772 switch ( (*ppEntries
)->mnHandle
)
775 *pValue
<<= OUString(pDocSh
->GetText());
777 case HANDLE_FONT_NAME_VARIABLES
:
778 case HANDLE_FONT_NAME_FUNCTIONS
:
779 case HANDLE_FONT_NAME_NUMBERS
:
780 case HANDLE_FONT_NAME_TEXT
:
781 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
782 case HANDLE_CUSTOM_FONT_NAME_SANS
:
783 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
785 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
786 *pValue
<<= OUString(rFace
.GetName());
789 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
790 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
791 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
792 case HANDLE_FONT_VARIABLES_POSTURE
:
793 case HANDLE_FONT_FUNCTIONS_POSTURE
:
794 case HANDLE_FONT_NUMBERS_POSTURE
:
795 case HANDLE_FONT_TEXT_POSTURE
:
797 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
798 BOOL bVal
= IsItalic( rFace
);
799 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
802 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
803 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
804 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
805 case HANDLE_FONT_VARIABLES_WEIGHT
:
806 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
807 case HANDLE_FONT_NUMBERS_WEIGHT
:
808 case HANDLE_FONT_TEXT_WEIGHT
:
810 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
811 BOOL bVal
= IsBold( rFace
); // bold?
812 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
815 case HANDLE_BASE_FONT_HEIGHT
:
818 sal_Int16 nVal
= static_cast < sal_Int16
> (aFormat
.GetBaseSize().Height());
819 nVal
= static_cast < sal_Int16
> (MM100_TO_TWIP(nVal
));
820 nVal
= (nVal
+ 10) / 20;
824 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
825 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
826 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
827 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
828 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
829 *pValue
<<= (sal_Int16
) aFormat
.GetRelSize((*ppEntries
)->mnMemberId
);
832 case HANDLE_IS_TEXT_MODE
:
834 sal_Bool bVal
= aFormat
.IsTextmode();
835 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
839 case HANDLE_GREEK_CHAR_STYLE
:
840 *pValue
<<= (sal_Int16
)aFormat
.GetGreekCharStyle();
843 case HANDLE_ALIGNMENT
:
844 // SmHorAlign uses the same values as HorizontalAlignment
845 *pValue
<<= (sal_Int16
)aFormat
.GetHorAlign();
848 case HANDLE_RELATIVE_SPACING
:
849 case HANDLE_RELATIVE_LINE_SPACING
:
850 case HANDLE_RELATIVE_ROOT_SPACING
:
851 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
852 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
853 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
854 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
855 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
856 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
857 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
858 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
859 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
860 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
861 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
862 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
863 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
864 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
865 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
866 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
867 case HANDLE_RELATIVE_OPERATOR_SPACING
:
868 case HANDLE_LEFT_MARGIN
:
869 case HANDLE_RIGHT_MARGIN
:
870 case HANDLE_TOP_MARGIN
:
871 case HANDLE_BOTTOM_MARGIN
:
872 *pValue
<<= (sal_Int16
)aFormat
.GetDistance((*ppEntries
)->mnMemberId
);
874 case HANDLE_IS_SCALE_ALL_BRACKETS
:
876 sal_Bool bVal
= aFormat
.IsScaleNormalBrackets();
877 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
880 case HANDLE_PRINTER_NAME
:
882 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
883 *pValue
<<= pPrinter
? OUString ( pPrinter
->GetName()) : OUString();
886 case HANDLE_PRINTER_SETUP
:
888 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ();
891 SvMemoryStream aStream
;
892 pPrinter
->Store( aStream
);
893 aStream
.Seek ( STREAM_SEEK_TO_END
);
894 sal_uInt32 nSize
= aStream
.Tell();
895 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
896 Sequence
< sal_Int8
> aSequence ( nSize
);
897 aStream
.Read ( aSequence
.getArray(), nSize
);
898 *pValue
<<= aSequence
;
905 SmModule
*pp
= SM_MOD();
906 const SmSymbolManager
&rManager
= pp
->GetSymbolManager();
907 vector
< const SmSym
* > aVector
;
909 const SymbolPtrVec_t
aSymbols( rManager
.GetSymbols() );
911 for (size_t i
= 0; i
< aSymbols
.size(); ++i
)
913 const SmSym
* pSymbol
= aSymbols
[ i
];
914 if (pSymbol
&& !pSymbol
->IsPredefined () )
916 aVector
.push_back ( pSymbol
);
920 Sequence
< SymbolDescriptor
> aSequence ( nCount
);
921 SymbolDescriptor
* pDescriptor
= aSequence
.getArray();
923 vector
< const SmSym
* >::const_iterator aIter
= aVector
.begin(), aEnd
= aVector
.end();
924 for(; aIter
!= aEnd
; pDescriptor
++, aIter
++)
926 pDescriptor
->sName
= (*aIter
)->GetName();
927 pDescriptor
->sExportName
= (*aIter
)->GetExportName();
928 pDescriptor
->sSymbolSet
= (*aIter
)->GetSymbolSetName();
929 pDescriptor
->nCharacter
= static_cast < sal_Int32
> ((*aIter
)->GetCharacter());
931 Font rFont
= (*aIter
)->GetFace();
932 pDescriptor
->sFontName
= rFont
.GetName();
933 pDescriptor
->nCharSet
= sal::static_int_cast
< sal_Int16
>(rFont
.GetCharSet());
934 pDescriptor
->nFamily
= sal::static_int_cast
< sal_Int16
>(rFont
.GetFamily());
935 pDescriptor
->nPitch
= sal::static_int_cast
< sal_Int16
>(rFont
.GetPitch());
936 pDescriptor
->nWeight
= sal::static_int_cast
< sal_Int16
>(rFont
.GetWeight());
937 pDescriptor
->nItalic
= sal::static_int_cast
< sal_Int16
>(rFont
.GetItalic());
939 *pValue
<<= aSequence
;
942 case HANDLE_BASIC_LIBRARIES
:
943 *pValue
<<= pDocSh
->GetBasicContainer();
945 case HANDLE_DIALOG_LIBRARIES
:
946 *pValue
<<= pDocSh
->GetDialogContainer();
948 case HANDLE_RUNTIME_UID
:
949 *pValue
<<= getRuntimeUID();
951 // --> PB 2004-08-25 #i33095# Security Options
952 case HANDLE_LOAD_READONLY
:
954 *pValue
<<= pDocSh
->IsLoadReadonly();
962 //////////////////////////////////////////////////////////////////////
964 sal_Int32 SAL_CALL
SmModel::getRendererCount(
965 const uno::Any
& /*rSelection*/,
966 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
967 throw (IllegalArgumentException
, RuntimeException
)
969 ::vos::OGuard
aGuard(Application::GetSolarMutex());
974 static Size
lcl_GuessPaperSize()
977 Reference
< XMultiServiceFactory
> xMgr( getProcessServiceFactory() );
978 LocaleDataWrapper
aLocWrp( xMgr
, AllSettings().GetLocale() );
979 if( MEASURE_METRIC
== aLocWrp
.getMeasurementSystemEnum() )
982 PaperInfo
aInfo( PAPER_A4
);
983 aRes
.Width() = aInfo
.getWidth();
984 aRes
.Height() = aInfo
.getHeight();
989 PaperInfo
aInfo( PAPER_LETTER
);
990 aRes
.Width() = aInfo
.getWidth();
991 aRes
.Height() = aInfo
.getHeight();
996 uno::Sequence
< beans::PropertyValue
> SAL_CALL
SmModel::getRenderer(
998 const uno::Any
& /*rSelection*/,
999 const uno::Sequence
< beans::PropertyValue
>& /*rxOptions*/ )
1000 throw (IllegalArgumentException
, RuntimeException
)
1002 ::vos::OGuard
aGuard(Application::GetSolarMutex());
1005 throw IllegalArgumentException();
1007 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
1009 throw RuntimeException();
1011 SmPrinterAccess
aPrinterAccess( *pDocSh
);
1012 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
1013 //Point aPrtPageOffset( pPrinter->GetPageOffset() );
1014 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
1016 // if paper size is 0 (usually if no 'real' printer is found),
1017 // guess the paper size
1018 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
1019 aPrtPaperSize
= lcl_GuessPaperSize();
1020 awt::Size
aPageSize( aPrtPaperSize
.Width(), aPrtPaperSize
.Height() );
1022 uno::Sequence
< beans::PropertyValue
> aRenderer(1);
1023 PropertyValue
&rValue
= aRenderer
.getArray()[0];
1024 rValue
.Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
1025 rValue
.Value
<<= aPageSize
;
1027 if (!m_pPrintUIOptions
)
1028 m_pPrintUIOptions
= new SmPrintUIOptions();
1029 m_pPrintUIOptions
->appendPrintUIOptions( aRenderer
);
1034 void SAL_CALL
SmModel::render(
1035 sal_Int32 nRenderer
,
1036 const uno::Any
& rSelection
,
1037 const uno::Sequence
< beans::PropertyValue
>& rxOptions
)
1038 throw (IllegalArgumentException
, RuntimeException
)
1040 ::vos::OGuard
aGuard(Application::GetSolarMutex());
1043 throw IllegalArgumentException();
1045 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
1047 throw RuntimeException();
1049 // get device to be rendered in
1050 uno::Reference
< awt::XDevice
> xRenderDevice
;
1051 for (sal_Int32 i
= 0, nCount
= rxOptions
.getLength(); i
< nCount
; ++i
)
1053 if( rxOptions
[i
].Name
== OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
1054 rxOptions
[i
].Value
>>= xRenderDevice
;
1057 if (xRenderDevice
.is())
1059 VCLXDevice
* pDevice
= VCLXDevice::GetImplementation( xRenderDevice
);
1060 OutputDevice
* pOut
= pDevice
? pDevice
->GetOutputDevice() : NULL
;
1063 throw RuntimeException();
1065 pOut
->SetMapMode( MAP_100TH_MM
);
1067 uno::Reference
< frame::XModel
> xModel
;
1068 rSelection
>>= xModel
;
1069 if (xModel
== pDocSh
->GetModel())
1071 //!! when called via API we may not have an active view
1072 //!! thus we go and look for a view that can be used.
1073 const TypeId aTypeId
= TYPE( SmViewShell
);
1074 SfxViewShell
* pViewSh
= SfxViewShell::GetFirst( &aTypeId
, sal_False
/* search non-visible views as well*/ );
1075 while (pViewSh
&& pViewSh
->GetObjectShell() != pDocSh
)
1076 pViewSh
= SfxViewShell::GetNext( *pViewSh
, &aTypeId
, sal_False
/* search non-visible views as well*/ );
1077 SmViewShell
*pView
= PTR_CAST( SmViewShell
, pViewSh
);
1078 DBG_ASSERT( pView
, "SmModel::render : no SmViewShell found" );
1082 SmPrinterAccess
aPrinterAccess( *pDocSh
);
1083 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
1085 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
1086 Size
aOutputSize ( pPrinter
->GetOutputSize() );
1087 Point
aPrtPageOffset( pPrinter
->GetPageOffset() );
1089 // no real printer ??
1090 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
1092 aPrtPaperSize
= lcl_GuessPaperSize();
1093 // factors from Windows DIN A4
1094 aOutputSize
= Size( (long)(aPrtPaperSize
.Width() * 0.941),
1095 (long)(aPrtPaperSize
.Height() * 0.961));
1096 aPrtPageOffset
= Point( (long)(aPrtPaperSize
.Width() * 0.0250),
1097 (long)(aPrtPaperSize
.Height() * 0.0214));
1100 Rectangle
OutputRect( aZeroPoint
, aOutputSize
);
1103 // set minimum top and bottom border
1104 if (aPrtPageOffset
.Y() < 2000)
1105 OutputRect
.Top() += 2000 - aPrtPageOffset
.Y();
1106 if ((aPrtPaperSize
.Height() - (aPrtPageOffset
.Y() + OutputRect
.Bottom())) < 2000)
1107 OutputRect
.Bottom() -= 2000 - (aPrtPaperSize
.Height() -
1108 (aPrtPageOffset
.Y() + OutputRect
.Bottom()));
1110 // set minimum left and right border
1111 if (aPrtPageOffset
.X() < 2500)
1112 OutputRect
.Left() += 2500 - aPrtPageOffset
.X();
1113 if ((aPrtPaperSize
.Width() - (aPrtPageOffset
.X() + OutputRect
.Right())) < 1500)
1114 OutputRect
.Right() -= 1500 - (aPrtPaperSize
.Width() -
1115 (aPrtPageOffset
.X() + OutputRect
.Right()));
1117 if (!m_pPrintUIOptions
)
1118 m_pPrintUIOptions
= new SmPrintUIOptions();
1119 m_pPrintUIOptions
->processProperties( rxOptions
);
1121 pView
->Impl_Print( *pOut
, *m_pPrintUIOptions
, Rectangle( OutputRect
), Point() );
1123 // release SmPrintUIOptions when everything is done.
1124 // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
1125 if (m_pPrintUIOptions
->getBoolValue( "IsLastPage", sal_False
))
1127 delete m_pPrintUIOptions
; m_pPrintUIOptions
= 0;
1134 void SAL_CALL
SmModel::setParent( const uno::Reference
< uno::XInterface
>& xParent
)
1135 throw( lang::NoSupportException
, uno::RuntimeException
)
1137 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1138 SfxBaseModel::setParent( xParent
);
1139 uno::Reference
< lang::XUnoTunnel
> xParentTunnel( xParent
, uno::UNO_QUERY
);
1140 if ( xParentTunnel
.is() )
1142 SvGlobalName
aSfxIdent( SFX_GLOBAL_CLASSID
);
1143 SfxObjectShell
* pDoc
= reinterpret_cast<SfxObjectShell
*>(xParentTunnel
->getSomething(
1144 uno::Sequence
< sal_Int8
>( aSfxIdent
.GetByteSequence() ) ) );
1146 GetObjectShell()->OnDocumentPrinterChanged( pDoc
->GetDocumentPrinter() );