1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unomodel.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_starmath.hxx"
35 #include <vos/mutex.hxx>
36 #include <osl/mutex.hxx>
37 #include <sfx2/printer.hxx>
38 #include <vcl/svapp.hxx>
39 #include <svtools/ctrltool.hxx>
40 #include <svtools/itemprop.hxx>
41 #include <unotools/localedatawrapper.hxx>
42 #include <unotools/processfactory.hxx>
43 #include <svx/paperinf.hxx>
44 #include <vcl/settings.hxx>
45 #include <toolkit/awt/vclxdevice.hxx>
46 #include <com/sun/star/beans/PropertyState.hpp>
47 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 #include <com/sun/star/formula/SymbolDescriptor.hpp>
49 #include <com/sun/star/awt/Size.hpp>
50 #include <com/sun/star/script/XLibraryContainer.hpp>
51 #include <xmloff/xmluconv.hxx>
52 #include <rtl/ustrbuf.hxx>
53 #include <comphelper/propertysetinfo.hxx>
54 #include <unomodel.hxx>
55 #include <document.hxx>
59 #include <starmath.hrc>
65 using namespace ::vos
;
66 using namespace ::rtl
;
67 using namespace ::cppu
;
68 using namespace ::std
;
69 using namespace ::comphelper
;
70 using namespace ::com::sun::star
;
71 using namespace ::com::sun::star::uno
;
72 using namespace ::com::sun::star::beans
;
73 using namespace ::com::sun::star::lang
;
74 using namespace ::com::sun::star::formula
;
75 using namespace ::com::sun::star::view
;
76 using namespace ::com::sun::star::script
;
78 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
79 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
81 #define C2U(cChar) rtl::OUString::createFromAscii(cChar)
83 ////////////////////////////////////////
87 #define PROPERTY_NONE 0
88 enum SmModelPropertyHandles
91 HANDLE_FONT_NAME_VARIABLES
,
92 HANDLE_FONT_NAME_FUNCTIONS
,
93 HANDLE_FONT_NAME_NUMBERS
,
94 HANDLE_FONT_NAME_TEXT
,
95 HANDLE_CUSTOM_FONT_NAME_SERIF
,
96 HANDLE_CUSTOM_FONT_NAME_SANS
,
97 HANDLE_CUSTOM_FONT_NAME_FIXED
,
98 HANDLE_CUSTOM_FONT_FIXED_POSTURE
,
99 HANDLE_CUSTOM_FONT_FIXED_WEIGHT
,
100 HANDLE_CUSTOM_FONT_SANS_POSTURE
,
101 HANDLE_CUSTOM_FONT_SANS_WEIGHT
,
102 HANDLE_CUSTOM_FONT_SERIF_POSTURE
,
103 HANDLE_CUSTOM_FONT_SERIF_WEIGHT
,
104 HANDLE_FONT_VARIABLES_POSTURE
,
105 HANDLE_FONT_VARIABLES_WEIGHT
,
106 HANDLE_FONT_FUNCTIONS_POSTURE
,
107 HANDLE_FONT_FUNCTIONS_WEIGHT
,
108 HANDLE_FONT_NUMBERS_POSTURE
,
109 HANDLE_FONT_NUMBERS_WEIGHT
,
110 HANDLE_FONT_TEXT_POSTURE
,
111 HANDLE_FONT_TEXT_WEIGHT
,
112 HANDLE_BASE_FONT_HEIGHT
,
113 HANDLE_RELATIVE_FONT_HEIGHT_TEXT
,
114 HANDLE_RELATIVE_FONT_HEIGHT_INDICES
,
115 HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
,
116 HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
,
117 HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
,
120 HANDLE_RELATIVE_SPACING
,
121 HANDLE_RELATIVE_LINE_SPACING
,
122 HANDLE_RELATIVE_ROOT_SPACING
,
123 HANDLE_RELATIVE_INDEX_SUPERSCRIPT
,
124 HANDLE_RELATIVE_INDEX_SUBSCRIPT
,
125 HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
,
126 HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
,
127 HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
,
128 HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
,
129 HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
,
130 HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
,
131 HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
,
132 HANDLE_RELATIVE_BRACKET_DISTANCE
,
133 HANDLE_IS_SCALE_ALL_BRACKETS
,
134 HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
,
135 HANDLE_RELATIVE_MATRIX_LINE_SPACING
,
136 HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
,
137 HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
,
138 HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
,
139 HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
,
140 HANDLE_RELATIVE_OPERATOR_SPACING
,
144 HANDLE_BOTTOM_MARGIN
,
146 HANDLE_PRINTER_SETUP
,
148 HANDLE_BASIC_LIBRARIES
, /* #93295# */
150 // --> PB 2004-08-25 #i33095# Security Options
151 HANDLE_LOAD_READONLY
,
153 HANDLE_DIALOG_LIBRARIES
// #i73329#
156 PropertySetInfo
* lcl_createModelPropertyInfo ()
158 static PropertyMapEntry aModelPropertyInfoMap
[] =
160 { RTL_CONSTASCII_STRINGPARAM( "Alignment" ), HANDLE_ALIGNMENT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
161 { RTL_CONSTASCII_STRINGPARAM( "BaseFontHeight" ), HANDLE_BASE_FONT_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, 0},
162 { RTL_CONSTASCII_STRINGPARAM( "BasicLibraries" ), HANDLE_BASIC_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
163 { RTL_CONSTASCII_STRINGPARAM( "BottomMargin" ), HANDLE_BOTTOM_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BOTTOMSPACE
},
164 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameFixed" ), HANDLE_CUSTOM_FONT_NAME_FIXED
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FIXED
},
165 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSans" ), HANDLE_CUSTOM_FONT_NAME_SANS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SANS
},
166 { RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSerif" ), HANDLE_CUSTOM_FONT_NAME_SERIF
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_SERIF
},
167 { RTL_CONSTASCII_STRINGPARAM( "DialogLibraries" ), HANDLE_DIALOG_LIBRARIES
, &::getCppuType((const uno::Reference
< script::XLibraryContainer
> *)0), PropertyAttribute::READONLY
, 0},
168 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsBold"), HANDLE_CUSTOM_FONT_FIXED_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
169 { RTL_CONSTASCII_STRINGPARAM( "FontFixedIsItalic"), HANDLE_CUSTOM_FONT_FIXED_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FIXED
},
170 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsBold"), HANDLE_FONT_FUNCTIONS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
171 { RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsItalic"), HANDLE_FONT_FUNCTIONS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_FUNCTION
},
172 { RTL_CONSTASCII_STRINGPARAM( "FontNameFunctions" ), HANDLE_FONT_NAME_FUNCTIONS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_FUNCTION
},
173 { RTL_CONSTASCII_STRINGPARAM( "FontNameNumbers" ), HANDLE_FONT_NAME_NUMBERS
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_NUMBER
},
174 { RTL_CONSTASCII_STRINGPARAM( "FontNameText" ), HANDLE_FONT_NAME_TEXT
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_TEXT
},
175 { RTL_CONSTASCII_STRINGPARAM( "FontNameVariables" ), HANDLE_FONT_NAME_VARIABLES
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, FNT_VARIABLE
},
176 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsBold"), HANDLE_FONT_NUMBERS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
177 { RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsItalic"), HANDLE_FONT_NUMBERS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_NUMBER
},
178 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsBold"), HANDLE_CUSTOM_FONT_SANS_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
179 { RTL_CONSTASCII_STRINGPARAM( "FontSansIsItalic"), HANDLE_CUSTOM_FONT_SANS_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SANS
},
180 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsBold"), HANDLE_CUSTOM_FONT_SERIF_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
181 { RTL_CONSTASCII_STRINGPARAM( "FontSerifIsItalic"), HANDLE_CUSTOM_FONT_SERIF_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_SERIF
},
182 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsBold"), HANDLE_FONT_TEXT_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
183 { RTL_CONSTASCII_STRINGPARAM( "FontTextIsItalic"), HANDLE_FONT_TEXT_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_TEXT
},
184 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsBold"), HANDLE_FONT_VARIABLES_WEIGHT
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
185 { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsItalic"), HANDLE_FONT_VARIABLES_POSTURE
, &::getBooleanCppuType(), PROPERTY_NONE
, FNT_VARIABLE
},
186 { RTL_CONSTASCII_STRINGPARAM( "Formula" ), HANDLE_FORMULA
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0},
187 { RTL_CONSTASCII_STRINGPARAM( "IsScaleAllBrackets" ), HANDLE_IS_SCALE_ALL_BRACKETS
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
188 { RTL_CONSTASCII_STRINGPARAM( "IsTextMode" ), HANDLE_IS_TEXT_MODE
, &::getBooleanCppuType(), PROPERTY_NONE
, 0},
189 { RTL_CONSTASCII_STRINGPARAM( "LeftMargin" ), HANDLE_LEFT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LEFTSPACE
},
190 { RTL_CONSTASCII_STRINGPARAM( "PrinterName" ), HANDLE_PRINTER_NAME
, &::getCppuType((const OUString
*)0), PROPERTY_NONE
, 0 },
191 { RTL_CONSTASCII_STRINGPARAM( "PrinterSetup" ), HANDLE_PRINTER_SETUP
, &::getCppuType((const Sequence
< sal_Int8
>*)0), PROPERTY_NONE
, 0 },
192 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketDistance" ), HANDLE_RELATIVE_BRACKET_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSPACE
},
193 { RTL_CONSTASCII_STRINGPARAM( "RelativeBracketExcessSize" ), HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_BRACKETSIZE
},
194 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightFunctions" ), HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_FUNCTION
},
195 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightIndices" ), HANDLE_RELATIVE_FONT_HEIGHT_INDICES
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_INDEX
},
196 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightLimits" ), HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_LIMITS
},
197 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightOperators" ), HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_OPERATOR
},
198 { RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightText" ), HANDLE_RELATIVE_FONT_HEIGHT_TEXT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, SIZ_TEXT
},
199 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarExcessLength"), HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_FRACTION
},
200 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarLineWeight" ), HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_STROKEWIDTH
},
201 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionDenominatorDepth"), HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_DENOMINATOR
},
202 { RTL_CONSTASCII_STRINGPARAM( "RelativeFractionNumeratorHeight" ), HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NUMERATOR
},
203 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSubscript" ), HANDLE_RELATIVE_INDEX_SUBSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUBSCRIPT
},
204 { RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSuperscript" ), HANDLE_RELATIVE_INDEX_SUPERSCRIPT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_SUPERSCRIPT
},
205 { RTL_CONSTASCII_STRINGPARAM( "RelativeLineSpacing" ), HANDLE_RELATIVE_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_VERTICAL
},
206 { RTL_CONSTASCII_STRINGPARAM( "RelativeLowerLimitDistance" ), HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_LOWERLIMIT
},
207 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixColumnSpacing" ), HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXCOL
},
208 { RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixLineSpacing" ), HANDLE_RELATIVE_MATRIX_LINE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_MATRIXROW
},
209 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorExcessSize" ), HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSIZE
},
210 { RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorSpacing" ), HANDLE_RELATIVE_OPERATOR_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_OPERATORSPACE
},
211 { RTL_CONSTASCII_STRINGPARAM( "RelativeRootSpacing" ), HANDLE_RELATIVE_ROOT_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ROOT
},
212 { RTL_CONSTASCII_STRINGPARAM( "RelativeScaleBracketExcessSize" ), HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_NORMALBRACKETSIZE
},
213 { RTL_CONSTASCII_STRINGPARAM( "RelativeSpacing" ), HANDLE_RELATIVE_SPACING
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_HORIZONTAL
},
214 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolMinimumHeight" ), HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSPACE
},
215 { RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolPrimaryHeight" ), HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_ORNAMENTSIZE
},
216 { RTL_CONSTASCII_STRINGPARAM( "RelativeUpperLimitDistance" ), HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_UPPERLIMIT
},
217 { RTL_CONSTASCII_STRINGPARAM( "RightMargin" ), HANDLE_RIGHT_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_RIGHTSPACE
},
218 { RTL_CONSTASCII_STRINGPARAM( "RuntimeUID" ), HANDLE_RUNTIME_UID
, &::getCppuType(static_cast< const rtl::OUString
* >(0)), PropertyAttribute::READONLY
, 0 },
219 { RTL_CONSTASCII_STRINGPARAM( "Symbols" ), HANDLE_SYMBOLS
, &::getCppuType((const Sequence
< SymbolDescriptor
> *)0), PROPERTY_NONE
, 0 },
220 { RTL_CONSTASCII_STRINGPARAM( "TopMargin" ), HANDLE_TOP_MARGIN
, &::getCppuType((const sal_Int16
*)0), PROPERTY_NONE
, DIS_TOPSPACE
},
221 // --> PB 2004-08-25 #i33095# Security Options
222 { RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY
, &::getBooleanCppuType(), PROPERTY_NONE
, 0 },
224 { NULL
, 0, 0, NULL
, 0, 0 }
226 PropertySetInfo
*pInfo
= new PropertySetInfo ( aModelPropertyInfoMap
);
229 //-----------------------------------------------------------------------
230 SmModel::SmModel( SfxObjectShell
*pObjSh
)
231 : SfxBaseModel(pObjSh
)
232 , PropertySetHelper ( lcl_createModelPropertyInfo () )
235 //-----------------------------------------------------------------------
236 SmModel::~SmModel() throw ()
239 /*-- 28.03.00 14:18:17---------------------------------------------------
241 -----------------------------------------------------------------------*/
242 uno::Any SAL_CALL
SmModel::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
244 uno::Any aRet
= ::cppu::queryInterface ( rType
,
245 // OWeakObject interfaces
246 dynamic_cast< XInterface
* > ( static_cast< XUnoTunnel
* > ( this )),
247 static_cast< XWeak
* > ( this ),
248 // PropertySetHelper interfaces
249 static_cast< XPropertySet
* > ( this ),
250 static_cast< XMultiPropertySet
* > ( this ),
251 //static_cast< XPropertyState* > ( this ),
253 static_cast< XServiceInfo
* > ( this ),
254 static_cast< XRenderable
* > ( this ) );
255 if (!aRet
.hasValue())
256 aRet
= SfxBaseModel::queryInterface ( rType
);
259 /*-- 28.03.00 14:18:18---------------------------------------------------
261 -----------------------------------------------------------------------*/
262 void SAL_CALL
SmModel::acquire() throw()
264 OWeakObject::acquire();
266 /*-- 28.03.00 14:18:18---------------------------------------------------
268 -----------------------------------------------------------------------*/
269 void SAL_CALL
SmModel::release() throw()
271 OWeakObject::release();
273 /*-- 28.03.00 14:18:19---------------------------------------------------
275 -----------------------------------------------------------------------*/
276 uno::Sequence
< uno::Type
> SAL_CALL
SmModel::getTypes( ) throw(uno::RuntimeException
)
278 ::vos::OGuard
aGuard(Application::GetSolarMutex());
279 uno::Sequence
< uno::Type
> aTypes
= SfxBaseModel::getTypes();
280 sal_Int32 nLen
= aTypes
.getLength();
281 aTypes
.realloc(nLen
+ 4);
282 uno::Type
* pTypes
= aTypes
.getArray();
283 pTypes
[nLen
++] = ::getCppuType((Reference
<XServiceInfo
>*)0);
284 pTypes
[nLen
++] = ::getCppuType((Reference
<XPropertySet
>*)0);
285 pTypes
[nLen
++] = ::getCppuType((Reference
<XMultiPropertySet
>*)0);
286 pTypes
[nLen
++] = ::getCppuType((Reference
<XRenderable
>*)0);
288 // XPropertyState not supported?? (respective virtual functions from
289 // PropertySetHelper not overloaded)
290 //pTypes[nLen++] = ::getCppuType((Reference<XPropertyState>*)0);
294 /* -----------------------------28.03.00 14:23--------------------------------
296 ---------------------------------------------------------------------------*/
297 const uno::Sequence
< sal_Int8
> & SmModel::getUnoTunnelId()
299 static osl::Mutex aCreateMutex
;
300 osl::Guard
<osl::Mutex
> aGuard( aCreateMutex
);
302 static uno::Sequence
< sal_Int8
> aSeq
;
303 if(!aSeq
.getLength())
306 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
309 } /* -----------------------------28.03.00 14:23--------------------------------
311 ---------------------------------------------------------------------------*/
312 sal_Int64 SAL_CALL
SmModel::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
313 throw(uno::RuntimeException
)
315 if( rId
.getLength() == 16
316 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
317 rId
.getConstArray(), 16 ) )
319 return sal::static_int_cast
< sal_Int64
>(reinterpret_cast< sal_uIntPtr
>(this));
322 return SfxBaseModel::getSomething( rId
);
324 /*-- 07.01.00 16:32:59---------------------------------------------------
326 -----------------------------------------------------------------------*/
327 /*-- 07.01.00 16:33:00---------------------------------------------------
329 -----------------------------------------------------------------------*/
330 sal_Int16
lcl_AnyToINT16(const uno::Any
& rAny
)
332 uno::TypeClass eType
= rAny
.getValueType().getTypeClass();
335 if( eType
== uno::TypeClass_DOUBLE
)
336 nRet
= (sal_Int16
)*(double*)rAny
.getValue();
337 else if( eType
== uno::TypeClass_FLOAT
)
338 nRet
= (sal_Int16
)*(float*)rAny
.getValue();
343 //-----------------------------------------------------------------------------
345 OUString
SmModel::getImplementationName(void) throw( uno::RuntimeException
)
347 return getImplementationName_Static();
351 ::rtl::OUString
SmModel::getImplementationName_Static()
353 return rtl::OUString::createFromAscii("com.sun.star.comp.math.FormulaDocument");
356 /*-- 20.01.04 11:21:00---------------------------------------------------
358 -----------------------------------------------------------------------*/
359 sal_Bool
SmModel::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
362 rServiceName
== C2U("com.sun.star.document.OfficeDocument" ) ||
363 rServiceName
== C2U("com.sun.star.formula.FormulaProperties")
366 /*-- 20.01.04 11:21:00---------------------------------------------------
368 -----------------------------------------------------------------------*/
369 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames(void) throw( uno::RuntimeException
)
371 return getSupportedServiceNames_Static();
374 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames_Static(void)
376 ::vos::OGuard
aGuard(Application::GetSolarMutex());
378 uno::Sequence
< OUString
> aRet(2);
379 OUString
* pArray
= aRet
.getArray();
380 pArray
[0] = C2U("com.sun.star.document.OfficeDocument");
381 pArray
[1] = C2U("com.sun.star.formula.FormulaProperties");
385 void SmModel::_setPropertyValues(const PropertyMapEntry
** ppEntries
, const Any
* pValues
)
386 throw( UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
)
388 ::vos::OGuard
aGuard(Application::GetSolarMutex());
390 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
392 if ( NULL
== pDocSh
)
393 throw UnknownPropertyException();
395 SmFormat aFormat
= pDocSh
->GetFormat();
397 for (; *ppEntries
; ppEntries
++, pValues
++ )
399 if ((*ppEntries
)->mnAttributes
& PropertyAttribute::READONLY
)
400 throw PropertyVetoException();
402 switch ( (*ppEntries
)->mnHandle
)
408 pDocSh
->SetText(aText
);
411 case HANDLE_FONT_NAME_VARIABLES
:
412 case HANDLE_FONT_NAME_FUNCTIONS
:
413 case HANDLE_FONT_NAME_NUMBERS
:
414 case HANDLE_FONT_NAME_TEXT
:
415 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
416 case HANDLE_CUSTOM_FONT_NAME_SANS
:
417 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
421 String sFontName
= aText
;
423 throw IllegalArgumentException();
425 if(aFormat
.GetFont((*ppEntries
)->mnMemberId
).GetName() != sFontName
)
427 const SmFace rOld
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
429 SmFace
aSet( sFontName
, rOld
.GetSize() );
430 aSet
.SetBorderWidth( rOld
.GetBorderWidth() );
431 aSet
.SetAlign( ALIGN_BASELINE
);
432 aFormat
.SetFont( (*ppEntries
)->mnMemberId
, aSet
);
436 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
437 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
438 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
439 case HANDLE_FONT_VARIABLES_POSTURE
:
440 case HANDLE_FONT_FUNCTIONS_POSTURE
:
441 case HANDLE_FONT_NUMBERS_POSTURE
:
442 case HANDLE_FONT_TEXT_POSTURE
:
444 if((*pValues
).getValueType() != ::getBooleanCppuType())
445 throw IllegalArgumentException();
446 BOOL bVal
= *(sal_Bool
*)(*pValues
).getValue();
447 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
448 aNewFont
.SetItalic((bVal
) ? ITALIC_NORMAL
: ITALIC_NONE
);
449 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
452 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
453 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
454 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
455 case HANDLE_FONT_VARIABLES_WEIGHT
:
456 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
457 case HANDLE_FONT_NUMBERS_WEIGHT
:
458 case HANDLE_FONT_TEXT_WEIGHT
:
460 if((*pValues
).getValueType() != ::getBooleanCppuType())
461 throw IllegalArgumentException();
462 BOOL bVal
= *(sal_Bool
*)(*pValues
).getValue();
463 Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
464 aNewFont
.SetWeight((bVal
) ? WEIGHT_BOLD
: WEIGHT_NORMAL
);
465 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
468 case HANDLE_BASE_FONT_HEIGHT
:
471 sal_Int16 nVal
= lcl_AnyToINT16(*pValues
);
473 throw IllegalArgumentException();
474 Size aSize
= aFormat
.GetBaseSize();
476 nVal
= static_cast < sal_Int16
> ( TWIP_TO_MM100(nVal
) );
477 aSize
.Height() = nVal
;
478 aFormat
.SetBaseSize(aSize
);
480 // apply base size to fonts
481 const Size
aTmp( aFormat
.GetBaseSize() );
482 for (USHORT i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
483 aFormat
.SetFontSize(i
, aTmp
);
486 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
487 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
488 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
489 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
490 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
495 throw IllegalArgumentException();
496 aFormat
.SetRelSize((*ppEntries
)->mnMemberId
, nVal
);
500 case HANDLE_IS_TEXT_MODE
:
502 aFormat
.SetTextmode(*(sal_Bool
*)(*pValues
).getValue());
506 case HANDLE_ALIGNMENT
:
508 // SmHorAlign uses the same values as HorizontalAlignment
511 if(nVal
< 0 || nVal
> 2)
512 throw IllegalArgumentException();
513 aFormat
.SetHorAlign((SmHorAlign
)nVal
);
517 case HANDLE_RELATIVE_SPACING
:
518 case HANDLE_RELATIVE_LINE_SPACING
:
519 case HANDLE_RELATIVE_ROOT_SPACING
:
520 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
521 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
522 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
523 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
524 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
525 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
526 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
527 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
528 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
529 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
530 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
531 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
532 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
533 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
534 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
535 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
536 case HANDLE_RELATIVE_OPERATOR_SPACING
:
537 case HANDLE_LEFT_MARGIN
:
538 case HANDLE_RIGHT_MARGIN
:
539 case HANDLE_TOP_MARGIN
:
540 case HANDLE_BOTTOM_MARGIN
:
545 throw IllegalArgumentException();
546 aFormat
.SetDistance((*ppEntries
)->mnMemberId
, nVal
);
549 case HANDLE_IS_SCALE_ALL_BRACKETS
:
550 aFormat
.SetScaleNormalBrackets(*(sal_Bool
*)(*pValues
).getValue());
552 case HANDLE_PRINTER_NAME
:
554 // embedded documents just ignore this property for now
555 if ( pDocSh
->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
)
557 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
560 OUString sPrinterName
;
561 if (*pValues
>>= sPrinterName
)
563 if ( sPrinterName
.getLength() )
565 SfxPrinter
*pNewPrinter
= new SfxPrinter ( pPrinter
->GetOptions().Clone(), sPrinterName
);
566 if (pNewPrinter
->IsKnown())
567 pDocSh
->SetPrinter ( pNewPrinter
);
573 throw IllegalArgumentException();
578 case HANDLE_PRINTER_SETUP
:
580 Sequence
< sal_Int8
> aSequence
;
581 if ( *pValues
>>= aSequence
)
583 sal_uInt32 nSize
= aSequence
.getLength();
584 SvMemoryStream
aStream ( aSequence
.getArray(), nSize
, STREAM_READ
);
585 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
586 static sal_uInt16 __READONLY_DATA nRange
[] =
588 SID_PRINTSIZE
, SID_PRINTSIZE
,
589 SID_PRINTZOOM
, SID_PRINTZOOM
,
590 SID_PRINTTITLE
, SID_PRINTTITLE
,
591 SID_PRINTTEXT
, SID_PRINTTEXT
,
592 SID_PRINTFRAME
, SID_PRINTFRAME
,
593 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
596 SfxItemSet
*pItemSet
= new SfxItemSet( pDocSh
->GetPool(), nRange
);
597 SmModule
*pp
= SM_MOD1();
598 pp
->GetConfig()->ConfigToItemSet(*pItemSet
);
599 SfxPrinter
*pPrinter
= SfxPrinter::Create ( aStream
, pItemSet
);
601 pDocSh
->SetPrinter( pPrinter
);
604 throw IllegalArgumentException();
610 Sequence
< SymbolDescriptor
> aSequence
;
611 if ( *pValues
>>= aSequence
)
613 sal_uInt32 nSize
= aSequence
.getLength();
614 SmModule
*pp
= SM_MOD1();
615 SmSymSetManager
&rManager
= pp
->GetSymSetManager();
616 SymbolDescriptor
*pDescriptor
= aSequence
.getArray();
617 for (sal_uInt32 i
= 0; i
< nSize
; i
++, pDescriptor
++)
620 aFont
.SetName ( pDescriptor
->sFontName
);
621 aFont
.SetCharSet ( static_cast < rtl_TextEncoding
> (pDescriptor
->nCharSet
) );
622 aFont
.SetFamily ( static_cast < FontFamily
> (pDescriptor
->nFamily
) );
623 aFont
.SetPitch ( static_cast < FontPitch
> (pDescriptor
->nPitch
) );
624 aFont
.SetWeight ( static_cast < FontWeight
> (pDescriptor
->nWeight
) );
625 aFont
.SetItalic ( static_cast < FontItalic
> (pDescriptor
->nItalic
) );
626 SmSym
aSymbol ( pDescriptor
->sName
, aFont
, static_cast < sal_Unicode
> (pDescriptor
->nCharacter
),
627 pDescriptor
->sSymbolSet
);
628 aSymbol
.SetExportName ( pDescriptor
->sExportName
);
629 aSymbol
.SetDocSymbol( TRUE
);
630 rManager
.AddReplaceSymbol ( aSymbol
);
634 throw IllegalArgumentException();
637 // --> PB 2004-08-25 #i33095# Security Options
638 case HANDLE_LOAD_READONLY
:
640 if ( (*pValues
).getValueType() != ::getBooleanCppuType() )
641 throw IllegalArgumentException();
642 sal_Bool bReadonly
= FALSE
;
643 if ( *pValues
>>= bReadonly
)
644 pDocSh
->SetLoadReadonly( bReadonly
);
651 pDocSh
->SetFormat( aFormat
);
653 // #i67283# since about all of the above changes are likely to change
654 // the formula size we have to recalculate the vis-area now
655 pDocSh
->SetVisArea( Rectangle( Point(0, 0), pDocSh
->GetSize() ) );
658 void SmModel::_getPropertyValues( const PropertyMapEntry
**ppEntries
, Any
*pValue
)
659 throw( UnknownPropertyException
, WrappedTargetException
)
661 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
663 if ( NULL
== pDocSh
)
664 throw UnknownPropertyException();
666 const SmFormat
& aFormat
= pDocSh
->GetFormat();
668 for (; *ppEntries
; ppEntries
++, pValue
++ )
670 switch ( (*ppEntries
)->mnHandle
)
673 *pValue
<<= OUString(pDocSh
->GetText());
675 case HANDLE_FONT_NAME_VARIABLES
:
676 case HANDLE_FONT_NAME_FUNCTIONS
:
677 case HANDLE_FONT_NAME_NUMBERS
:
678 case HANDLE_FONT_NAME_TEXT
:
679 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
680 case HANDLE_CUSTOM_FONT_NAME_SANS
:
681 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
683 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
684 *pValue
<<= OUString(rFace
.GetName());
687 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
688 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
689 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
690 case HANDLE_FONT_VARIABLES_POSTURE
:
691 case HANDLE_FONT_FUNCTIONS_POSTURE
:
692 case HANDLE_FONT_NUMBERS_POSTURE
:
693 case HANDLE_FONT_TEXT_POSTURE
:
695 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
696 BOOL bVal
= IsItalic( rFace
);
697 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
700 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
701 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
702 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
703 case HANDLE_FONT_VARIABLES_WEIGHT
:
704 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
705 case HANDLE_FONT_NUMBERS_WEIGHT
:
706 case HANDLE_FONT_TEXT_WEIGHT
:
708 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
709 BOOL bVal
= IsBold( rFace
); // bold?
710 (*pValue
).setValue(&bVal
, *(*ppEntries
)->mpType
);
713 case HANDLE_BASE_FONT_HEIGHT
:
716 sal_Int16 nVal
= static_cast < sal_Int16
> (aFormat
.GetBaseSize().Height());
717 nVal
= static_cast < sal_Int16
> (MM100_TO_TWIP(nVal
));
718 nVal
= (nVal
+ 10) / 20;
722 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
723 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
724 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
725 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
726 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
727 *pValue
<<= (sal_Int16
) aFormat
.GetRelSize((*ppEntries
)->mnMemberId
);
730 case HANDLE_IS_TEXT_MODE
:
732 sal_Bool bVal
= aFormat
.IsTextmode();
733 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
737 case HANDLE_ALIGNMENT
:
738 // SmHorAlign uses the same values as HorizontalAlignment
739 *pValue
<<= (sal_Int16
)aFormat
.GetHorAlign();
742 case HANDLE_RELATIVE_SPACING
:
743 case HANDLE_RELATIVE_LINE_SPACING
:
744 case HANDLE_RELATIVE_ROOT_SPACING
:
745 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
746 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
747 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
748 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
749 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
750 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
751 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
752 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
753 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
754 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
755 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
756 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
757 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
758 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
759 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
760 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
761 case HANDLE_RELATIVE_OPERATOR_SPACING
:
762 case HANDLE_LEFT_MARGIN
:
763 case HANDLE_RIGHT_MARGIN
:
764 case HANDLE_TOP_MARGIN
:
765 case HANDLE_BOTTOM_MARGIN
:
766 *pValue
<<= (sal_Int16
)aFormat
.GetDistance((*ppEntries
)->mnMemberId
);
768 case HANDLE_IS_SCALE_ALL_BRACKETS
:
770 sal_Bool bVal
= aFormat
.IsScaleNormalBrackets();
771 (*pValue
).setValue(&bVal
, ::getBooleanCppuType());
774 case HANDLE_PRINTER_NAME
:
776 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
777 *pValue
<<= pPrinter
? OUString ( pPrinter
->GetName()) : OUString();
780 case HANDLE_PRINTER_SETUP
:
782 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ();
785 SvMemoryStream aStream
;
786 pPrinter
->Store( aStream
);
787 aStream
.Seek ( STREAM_SEEK_TO_END
);
788 sal_uInt32 nSize
= aStream
.Tell();
789 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
790 Sequence
< sal_Int8
> aSequence ( nSize
);
791 aStream
.Read ( aSequence
.getArray(), nSize
);
792 *pValue
<<= aSequence
;
799 SmModule
*pp
= SM_MOD1();
800 const SmSymSetManager
&rManager
= pp
->GetSymSetManager();
801 vector
< const SmSym
* > aVector
;
804 for (USHORT i
= 0, nEnd
= rManager
.GetSymbolCount(); i
< nEnd
; i
++)
806 const SmSym
* pSymbol
= rManager
.GetSymbolByPos( i
);
807 if (pSymbol
&& !pSymbol
->IsPredefined () )
809 aVector
.push_back ( pSymbol
);
813 Sequence
< SymbolDescriptor
> aSequence ( nCount
);
814 SymbolDescriptor
* pDescriptor
= aSequence
.getArray();
816 vector
<const SmSym
* >::const_iterator aIter
= aVector
.begin(), aEnd
= aVector
.end();
817 for(; aIter
!= aEnd
; pDescriptor
++, aIter
++)
819 pDescriptor
->sName
= (*aIter
)->GetName();
820 pDescriptor
->sExportName
= (*aIter
)->GetExportName();
821 pDescriptor
->sSymbolSet
= (*aIter
)->GetSetName();
822 pDescriptor
->nCharacter
= static_cast < sal_Int32
> ((*aIter
)->GetCharacter());
824 Font rFont
= (*aIter
)->GetFace();
825 pDescriptor
->sFontName
= rFont
.GetName();
826 pDescriptor
->nCharSet
= sal::static_int_cast
< sal_Int16
>(rFont
.GetCharSet());
827 pDescriptor
->nFamily
= sal::static_int_cast
< sal_Int16
>(rFont
.GetFamily());
828 pDescriptor
->nPitch
= sal::static_int_cast
< sal_Int16
>(rFont
.GetPitch());
829 pDescriptor
->nWeight
= sal::static_int_cast
< sal_Int16
>(rFont
.GetWeight());
830 pDescriptor
->nItalic
= sal::static_int_cast
< sal_Int16
>(rFont
.GetItalic());
832 *pValue
<<= aSequence
;
835 case HANDLE_BASIC_LIBRARIES
:
836 *pValue
<<= pDocSh
->GetBasicContainer();
838 case HANDLE_DIALOG_LIBRARIES
:
839 *pValue
<<= pDocSh
->GetDialogContainer();
841 case HANDLE_RUNTIME_UID
:
842 *pValue
<<= getRuntimeUID();
844 // --> PB 2004-08-25 #i33095# Security Options
845 case HANDLE_LOAD_READONLY
:
847 *pValue
<<= pDocSh
->IsLoadReadonly();
855 //////////////////////////////////////////////////////////////////////
857 sal_Int32 SAL_CALL
SmModel::getRendererCount(
858 const uno::Any
& /*rSelection*/,
859 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
860 throw (IllegalArgumentException
, RuntimeException
)
862 ::vos::OGuard
aGuard(Application::GetSolarMutex());
867 static Size
lcl_GuessPaperSize()
870 Reference
< XMultiServiceFactory
> xMgr( getProcessServiceFactory() );
871 LocaleDataWrapper
aLocWrp( xMgr
, AllSettings().GetLocale() );
872 if( MEASURE_METRIC
== aLocWrp
.getMeasurementSystemEnum() )
875 aRes
.Width() = lA4Width
;
876 aRes
.Height() = lA4Height
;
881 aRes
.Width() = lLetterWidth
;
882 aRes
.Height() = lLetterHeight
;
884 aRes
= OutputDevice::LogicToLogic( aRes
, MapMode(MAP_TWIP
),
885 MapMode(MAP_100TH_MM
) );
890 uno::Sequence
< beans::PropertyValue
> SAL_CALL
SmModel::getRenderer(
892 const uno::Any
& /*rSelection*/,
893 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
894 throw (IllegalArgumentException
, RuntimeException
)
896 ::vos::OGuard
aGuard(Application::GetSolarMutex());
899 throw IllegalArgumentException();
901 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
903 throw RuntimeException();
905 SmPrinterAccess
aPrinterAccess( *pDocSh
);
906 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
907 //Point aPrtPageOffset( pPrinter->GetPageOffset() );
908 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
910 // if paper size is 0 (usually if no 'real' printer is found),
911 // guess the paper size
912 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
913 aPrtPaperSize
= lcl_GuessPaperSize();
914 awt::Size
aPageSize( aPrtPaperSize
.Width(), aPrtPaperSize
.Height() );
916 uno::Sequence
< beans::PropertyValue
> aRenderer(1);
917 PropertyValue
&rValue
= aRenderer
.getArray()[0];
918 rValue
.Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
919 rValue
.Value
<<= aPageSize
;
924 void SAL_CALL
SmModel::render(
926 const uno::Any
& rSelection
,
927 const uno::Sequence
< beans::PropertyValue
>& rxOptions
)
928 throw (IllegalArgumentException
, RuntimeException
)
930 ::vos::OGuard
aGuard(Application::GetSolarMutex());
933 throw IllegalArgumentException();
935 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
937 throw RuntimeException();
939 // get device to be rendered in
940 uno::Reference
< awt::XDevice
> xRenderDevice
;
941 for (sal_Int32 i
= 0, nCount
= rxOptions
.getLength(); i
< nCount
; ++i
)
943 if( rxOptions
[i
].Name
== OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
944 rxOptions
[i
].Value
>>= xRenderDevice
;
947 if (xRenderDevice
.is())
949 VCLXDevice
* pDevice
= VCLXDevice::GetImplementation( xRenderDevice
);
950 OutputDevice
* pOut
= pDevice
? pDevice
->GetOutputDevice() : NULL
;
953 throw RuntimeException();
955 pOut
->SetMapMode( MAP_100TH_MM
);
957 uno::Reference
< frame::XModel
> xModel
;
958 rSelection
>>= xModel
;
959 if (xModel
== pDocSh
->GetModel())
961 //!! when called via API we may not have an active view
962 //!! thus we go and look for a view that can be used.
963 const TypeId aTypeId
= TYPE( SmViewShell
);
964 SfxViewShell
* pViewSh
= SfxViewShell::GetFirst( &aTypeId
, sal_False
/* search non-visible views as well*/ );
965 while (pViewSh
&& pViewSh
->GetObjectShell() != pDocSh
)
966 pViewSh
= SfxViewShell::GetNext( *pViewSh
, &aTypeId
, sal_False
/* search non-visible views as well*/ );
967 SmViewShell
*pView
= PTR_CAST( SmViewShell
, pViewSh
);
968 DBG_ASSERT( pView
, "SmModel::render : no SmViewShell found" );
972 SmPrinterAccess
aPrinterAccess( *pDocSh
);
973 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
975 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
976 Size
aOutputSize ( pPrinter
->GetOutputSize() );
977 Point
aPrtPageOffset( pPrinter
->GetPageOffset() );
979 // no real printer ??
980 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
982 aPrtPaperSize
= lcl_GuessPaperSize();
983 // factors from Windows DIN A4
984 aOutputSize
= Size( (long)(aPrtPaperSize
.Width() * 0.941),
985 (long)(aPrtPaperSize
.Height() * 0.961));
986 aPrtPageOffset
= Point( (long)(aPrtPaperSize
.Width() * 0.0250),
987 (long)(aPrtPaperSize
.Height() * 0.0214));
990 Rectangle
OutputRect( aZeroPoint
, aOutputSize
);
993 // set minimum top and bottom border
994 if (aPrtPageOffset
.Y() < 2000)
995 OutputRect
.Top() += 2000 - aPrtPageOffset
.Y();
996 if ((aPrtPaperSize
.Height() - (aPrtPageOffset
.Y() + OutputRect
.Bottom())) < 2000)
997 OutputRect
.Bottom() -= 2000 - (aPrtPaperSize
.Height() -
998 (aPrtPageOffset
.Y() + OutputRect
.Bottom()));
1000 // set minimum left and right border
1001 if (aPrtPageOffset
.X() < 2500)
1002 OutputRect
.Left() += 2500 - aPrtPageOffset
.X();
1003 if ((aPrtPaperSize
.Width() - (aPrtPageOffset
.X() + OutputRect
.Right())) < 1500)
1004 OutputRect
.Right() -= 1500 - (aPrtPaperSize
.Width() -
1005 (aPrtPageOffset
.X() + OutputRect
.Right()));
1007 pView
->Impl_Print( *pOut
, PRINT_SIZE_NORMAL
,
1008 Rectangle( OutputRect
), Point() );
1014 void SAL_CALL
SmModel::setParent( const uno::Reference
< uno::XInterface
>& xParent
)
1015 throw( lang::NoSupportException
, uno::RuntimeException
)
1017 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1018 SfxBaseModel::setParent( xParent
);
1019 uno::Reference
< lang::XUnoTunnel
> xParentTunnel( xParent
, uno::UNO_QUERY
);
1020 if ( xParentTunnel
.is() )
1022 SvGlobalName
aSfxIdent( SFX_GLOBAL_CLASSID
);
1023 SfxObjectShell
* pDoc
= reinterpret_cast<SfxObjectShell
*>(xParentTunnel
->getSomething(
1024 uno::Sequence
< sal_Int8
>( aSfxIdent
.GetByteSequence() ) ) );
1026 GetObjectShell()->OnDocumentPrinterChanged( pDoc
->GetDocumentPrinter() );