1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <o3tl/any.hxx>
23 #include <osl/mutex.hxx>
24 #include <sfx2/printer.hxx>
25 #include <vcl/svapp.hxx>
26 #include <svtools/ctrltool.hxx>
27 #include <svl/itemprop.hxx>
28 #include <unotools/localedatawrapper.hxx>
29 #include <editeng/paperinf.hxx>
30 #include <vcl/settings.hxx>
31 #include <vcl/print.hxx>
32 #include <toolkit/awt/vclxdevice.hxx>
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <com/sun/star/formula/SymbolDescriptor.hpp>
35 #include <com/sun/star/awt/Size.hpp>
36 #include <com/sun/star/script/XLibraryContainer.hpp>
37 #include <xmloff/xmluconv.hxx>
38 #include <rtl/ustrbuf.hxx>
39 #include <comphelper/propertysetinfo.hxx>
40 #include <comphelper/servicehelper.hxx>
41 #include <cppuhelper/supportsservice.hxx>
42 #include <unotools/moduleoptions.hxx>
43 #include <tools/mapunit.hxx>
45 #include <unomodel.hxx>
46 #include <document.hxx>
49 #include <starmath.hrc>
51 #include "cfgitem.hxx"
53 using namespace ::cppu
;
54 using namespace ::std
;
55 using namespace ::comphelper
;
56 using namespace ::com::sun::star
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::beans
;
59 using namespace ::com::sun::star::lang
;
60 using namespace ::com::sun::star::formula
;
61 using namespace ::com::sun::star::view
;
62 using namespace ::com::sun::star::script
;
64 SmPrintUIOptions::SmPrintUIOptions()
66 SmModule
*pp
= SM_MOD();
67 SmMathConfig
*pConfig
= pp
->GetConfig();
68 SAL_WARN_IF( !pConfig
, "starmath", "SmConfig not found" );
72 sal_Int32 nNumProps
= 10, nIdx
=0;
74 // create sequence of print UI options
75 // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
76 m_aUIProperties
.resize( nNumProps
);
78 // load the math PrinterOptions into the custom tab
79 m_aUIProperties
[nIdx
].Name
= "OptionsUIFile";
80 m_aUIProperties
[nIdx
++].Value
<<= OUString("modules/smath/ui/printeroptions.ui");
82 // create Section for formula (results in an extra tab page in dialog)
83 SvtModuleOptions aOpt
;
84 OUString
aAppGroupname(
85 SM_RESSTR( RID_PRINTUIOPT_PRODNAME
).
86 replaceFirst( "%s", aOpt
.GetModuleName( SvtModuleOptions::EModule::MATH
) ) );
87 m_aUIProperties
[nIdx
++].Value
= setGroupControlOpt("tabcontrol-page2", aAppGroupname
, ".HelpID:vcl:PrintDialog:TabPage:AppPage");
89 // create subgroup for print options
90 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("contents", SM_RESSTR( RID_PRINTUIOPT_CONTENTS
), OUString());
92 // create a bool option for title row (matches to SID_PRINTTITLE)
93 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("title", SM_RESSTR( RID_PRINTUIOPT_TITLE
),
94 ".HelpID:vcl:PrintDialog:TitleRow:CheckBox",
96 pConfig
->IsPrintTitle());
97 // create a bool option for formula text (matches to SID_PRINTTEXT)
98 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("formulatext", SM_RESSTR( RID_PRINTUIOPT_FRMLTXT
),
99 ".HelpID:vcl:PrintDialog:FormulaText:CheckBox",
100 PRTUIOPT_FORMULA_TEXT
,
101 pConfig
->IsPrintFormulaText());
102 // create a bool option for border (matches to SID_PRINTFRAME)
103 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("borders", SM_RESSTR( RID_PRINTUIOPT_BORDERS
),
104 ".HelpID:vcl:PrintDialog:Border:CheckBox",
106 pConfig
->IsPrintFrame());
108 // create subgroup for print format
109 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("size", SM_RESSTR( RID_PRINTUIOPT_SIZE
), OUString());
111 // create a radio button group for print format (matches to SID_PRINTSIZE)
112 Sequence
< OUString
> aChoices
{
113 SM_RESSTR( RID_PRINTUIOPT_ORIGSIZE
),
114 SM_RESSTR( RID_PRINTUIOPT_FITTOPAGE
),
115 SM_RESSTR( RID_PRINTUIOPT_SCALING
)
117 Sequence
< OUString
> aHelpIds
{
118 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0",
119 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1",
120 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2"
122 Sequence
< OUString
> aWidgetIds
{
127 OUString
aPrintFormatProp( PRTUIOPT_PRINT_FORMAT
);
128 m_aUIProperties
[nIdx
++].Value
= setChoiceRadiosControlOpt(aWidgetIds
, OUString(),
131 aChoices
, static_cast< sal_Int32
>(pConfig
->GetPrintSize())
134 // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
135 vcl::PrinterOptionsHelper::UIControlOptions
aRangeOpt( aPrintFormatProp
, 2, true );
136 m_aUIProperties
[nIdx
++].Value
= setRangeControlOpt("scalingspin", OUString(),
137 ".HelpID:vcl:PrintDialog:PrintScale:NumericField",
138 PRTUIOPT_PRINT_SCALE
,
139 pConfig
->GetPrintZoomFactor(), // initial value
144 Sequence
< PropertyValue
> aHintNoLayoutPage( 1 );
145 aHintNoLayoutPage
[0].Name
= "HintNoLayoutPage";
146 aHintNoLayoutPage
[0].Value
= makeAny( true );
147 m_aUIProperties
[nIdx
++].Value
<<= aHintNoLayoutPage
;
149 assert(nIdx
== nNumProps
);
156 // values from com/sun/star/beans/PropertyAttribute
157 #define PROPERTY_NONE 0
159 enum SmModelPropertyHandles
162 HANDLE_FONT_NAME_VARIABLES
,
163 HANDLE_FONT_NAME_FUNCTIONS
,
164 HANDLE_FONT_NAME_NUMBERS
,
165 HANDLE_FONT_NAME_TEXT
,
166 HANDLE_CUSTOM_FONT_NAME_SERIF
,
167 HANDLE_CUSTOM_FONT_NAME_SANS
,
168 HANDLE_CUSTOM_FONT_NAME_FIXED
,
169 HANDLE_CUSTOM_FONT_FIXED_POSTURE
,
170 HANDLE_CUSTOM_FONT_FIXED_WEIGHT
,
171 HANDLE_CUSTOM_FONT_SANS_POSTURE
,
172 HANDLE_CUSTOM_FONT_SANS_WEIGHT
,
173 HANDLE_CUSTOM_FONT_SERIF_POSTURE
,
174 HANDLE_CUSTOM_FONT_SERIF_WEIGHT
,
175 HANDLE_FONT_VARIABLES_POSTURE
,
176 HANDLE_FONT_VARIABLES_WEIGHT
,
177 HANDLE_FONT_FUNCTIONS_POSTURE
,
178 HANDLE_FONT_FUNCTIONS_WEIGHT
,
179 HANDLE_FONT_NUMBERS_POSTURE
,
180 HANDLE_FONT_NUMBERS_WEIGHT
,
181 HANDLE_FONT_TEXT_POSTURE
,
182 HANDLE_FONT_TEXT_WEIGHT
,
183 HANDLE_BASE_FONT_HEIGHT
,
184 HANDLE_RELATIVE_FONT_HEIGHT_TEXT
,
185 HANDLE_RELATIVE_FONT_HEIGHT_INDICES
,
186 HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
,
187 HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
,
188 HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
,
190 HANDLE_GREEK_CHAR_STYLE
,
192 HANDLE_RELATIVE_SPACING
,
193 HANDLE_RELATIVE_LINE_SPACING
,
194 HANDLE_RELATIVE_ROOT_SPACING
,
195 HANDLE_RELATIVE_INDEX_SUPERSCRIPT
,
196 HANDLE_RELATIVE_INDEX_SUBSCRIPT
,
197 HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
,
198 HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
,
199 HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
,
200 HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
,
201 HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
,
202 HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
,
203 HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
,
204 HANDLE_RELATIVE_BRACKET_DISTANCE
,
205 HANDLE_IS_SCALE_ALL_BRACKETS
,
206 HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
,
207 HANDLE_RELATIVE_MATRIX_LINE_SPACING
,
208 HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
,
209 HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
,
210 HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
,
211 HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
,
212 HANDLE_RELATIVE_OPERATOR_SPACING
,
216 HANDLE_BOTTOM_MARGIN
,
218 HANDLE_PRINTER_SETUP
,
221 HANDLE_BASIC_LIBRARIES
,
223 HANDLE_LOAD_READONLY
, // Security Options
224 HANDLE_DIALOG_LIBRARIES
, // #i73329#
226 HANDLE_INTEROP_GRAB_BAG
,
229 static PropertySetInfo
* lcl_createModelPropertyInfo ()
231 static PropertyMapEntry aModelPropertyInfoMap
[] =
233 { OUString("Alignment") , HANDLE_ALIGNMENT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
234 { OUString("BaseFontHeight") , HANDLE_BASE_FONT_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
235 { OUString("BasicLibraries") , HANDLE_BASIC_LIBRARIES
, cppu::UnoType
<script::XLibraryContainer
>::get(), PropertyAttribute::READONLY
, 0 },
236 { OUString("BottomMargin") , HANDLE_BOTTOM_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BOTTOMSPACE
},
237 { OUString("CustomFontNameFixed") , HANDLE_CUSTOM_FONT_NAME_FIXED
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_FIXED
},
238 { OUString("CustomFontNameSans") , HANDLE_CUSTOM_FONT_NAME_SANS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_SANS
},
239 { OUString("CustomFontNameSerif") , HANDLE_CUSTOM_FONT_NAME_SERIF
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_SERIF
},
240 { OUString("DialogLibraries") , HANDLE_DIALOG_LIBRARIES
, cppu::UnoType
<script::XLibraryContainer
>::get(), PropertyAttribute::READONLY
, 0 },
241 { OUString("FontFixedIsBold") , HANDLE_CUSTOM_FONT_FIXED_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FIXED
},
242 { OUString("FontFixedIsItalic") , HANDLE_CUSTOM_FONT_FIXED_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FIXED
},
243 { OUString("FontFunctionsIsBold") , HANDLE_FONT_FUNCTIONS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
244 { OUString("FontFunctionsIsItalic") , HANDLE_FONT_FUNCTIONS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
245 { OUString("FontNameFunctions") , HANDLE_FONT_NAME_FUNCTIONS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
246 { OUString("FontNameNumbers") , HANDLE_FONT_NAME_NUMBERS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_NUMBER
},
247 { OUString("FontNameText") , HANDLE_FONT_NAME_TEXT
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_TEXT
},
248 { OUString("FontNameVariables") , HANDLE_FONT_NAME_VARIABLES
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
249 { OUString("FontNumbersIsBold") , HANDLE_FONT_NUMBERS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_NUMBER
},
250 { OUString("FontNumbersIsItalic") , HANDLE_FONT_NUMBERS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_NUMBER
},
251 { OUString("FontSansIsBold") , HANDLE_CUSTOM_FONT_SANS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SANS
},
252 { OUString("FontSansIsItalic") , HANDLE_CUSTOM_FONT_SANS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SANS
},
253 { OUString("FontSerifIsBold") , HANDLE_CUSTOM_FONT_SERIF_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SERIF
},
254 { OUString("FontSerifIsItalic") , HANDLE_CUSTOM_FONT_SERIF_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SERIF
},
255 { OUString("FontTextIsBold") , HANDLE_FONT_TEXT_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_TEXT
},
256 { OUString("FontTextIsItalic") , HANDLE_FONT_TEXT_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_TEXT
},
257 { OUString("FontVariablesIsBold") , HANDLE_FONT_VARIABLES_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
258 { OUString("FontVariablesIsItalic") , HANDLE_FONT_VARIABLES_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
259 { OUString("Formula") , HANDLE_FORMULA
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0 },
260 { OUString("IsScaleAllBrackets") , HANDLE_IS_SCALE_ALL_BRACKETS
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
261 { OUString("IsTextMode") , HANDLE_IS_TEXT_MODE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
262 { OUString("GreekCharStyle") , HANDLE_GREEK_CHAR_STYLE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
263 { OUString("LeftMargin") , HANDLE_LEFT_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_LEFTSPACE
},
264 { OUString("PrinterName") , HANDLE_PRINTER_NAME
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0 },
265 { OUString("PrinterSetup") , HANDLE_PRINTER_SETUP
, cppu::UnoType
<const Sequence
< sal_Int8
>>::get(), PROPERTY_NONE
, 0 },
266 { OUString("RelativeBracketDistance") , HANDLE_RELATIVE_BRACKET_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BRACKETSPACE
},
267 { OUString("RelativeBracketExcessSize") , HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BRACKETSIZE
},
268 { OUString("RelativeFontHeightFunctions") , HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_FUNCTION
},
269 { OUString("RelativeFontHeightIndices") , HANDLE_RELATIVE_FONT_HEIGHT_INDICES
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_INDEX
},
270 { OUString("RelativeFontHeightLimits") , HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_LIMITS
},
271 { OUString("RelativeFontHeightOperators") , HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_OPERATOR
},
272 { OUString("RelativeFontHeightText") , HANDLE_RELATIVE_FONT_HEIGHT_TEXT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_TEXT
},
273 { OUString("RelativeFractionBarExcessLength") , HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_FRACTION
},
274 { OUString("RelativeFractionBarLineWeight") , HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_STROKEWIDTH
},
275 { OUString("RelativeFractionDenominatorDepth") , HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_DENOMINATOR
},
276 { OUString("RelativeFractionNumeratorHeight") , HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_NUMERATOR
},
277 { OUString("RelativeIndexSubscript") , HANDLE_RELATIVE_INDEX_SUBSCRIPT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_SUBSCRIPT
},
278 { OUString("RelativeIndexSuperscript") , HANDLE_RELATIVE_INDEX_SUPERSCRIPT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_SUPERSCRIPT
},
279 { OUString("RelativeLineSpacing") , HANDLE_RELATIVE_LINE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_VERTICAL
},
280 { OUString("RelativeLowerLimitDistance") , HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_LOWERLIMIT
},
281 { OUString("RelativeMatrixColumnSpacing") , HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_MATRIXCOL
},
282 { OUString("RelativeMatrixLineSpacing") , HANDLE_RELATIVE_MATRIX_LINE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_MATRIXROW
},
283 { OUString("RelativeOperatorExcessSize") , HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_OPERATORSIZE
},
284 { OUString("RelativeOperatorSpacing") , HANDLE_RELATIVE_OPERATOR_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_OPERATORSPACE
},
285 { OUString("RelativeRootSpacing") , HANDLE_RELATIVE_ROOT_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ROOT
},
286 { OUString("RelativeScaleBracketExcessSize") , HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_NORMALBRACKETSIZE
},
287 { OUString("RelativeSpacing") , HANDLE_RELATIVE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_HORIZONTAL
},
288 { OUString("RelativeSymbolMinimumHeight") , HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ORNAMENTSPACE
},
289 { OUString("RelativeSymbolPrimaryHeight") , HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ORNAMENTSIZE
},
290 { OUString("RelativeUpperLimitDistance") , HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_UPPERLIMIT
},
291 { OUString("RightMargin") , HANDLE_RIGHT_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_RIGHTSPACE
},
292 { OUString("RuntimeUID") , HANDLE_RUNTIME_UID
, cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
, 0 },
293 { OUString("Symbols") , HANDLE_SYMBOLS
, cppu::UnoType
<Sequence
< SymbolDescriptor
>>::get(), PROPERTY_NONE
, 0 },
294 { OUString("UserDefinedSymbolsInUse") , HANDLE_USED_SYMBOLS
, cppu::UnoType
<Sequence
< SymbolDescriptor
>>::get(), PropertyAttribute::READONLY
, 0 },
295 { OUString("TopMargin") , HANDLE_TOP_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_TOPSPACE
},
296 // #i33095# Security Options
297 { OUString("LoadReadonly") , HANDLE_LOAD_READONLY
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
299 { OUString("BaseLine") , HANDLE_BASELINE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
300 { OUString("InteropGrabBag") , HANDLE_INTEROP_GRAB_BAG
, cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get(), PROPERTY_NONE
, 0 },
301 { OUString(), 0, css::uno::Type(), 0, 0 }
303 PropertySetInfo
*pInfo
= new PropertySetInfo ( aModelPropertyInfoMap
);
307 SmModel::SmModel( SfxObjectShell
*pObjSh
)
308 : SfxBaseModel(pObjSh
)
309 , PropertySetHelper ( lcl_createModelPropertyInfo () )
313 SmModel::~SmModel() throw ()
317 uno::Any SAL_CALL
SmModel::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
319 uno::Any aRet
= ::cppu::queryInterface ( rType
,
320 // OWeakObject interfaces
321 dynamic_cast< XInterface
* > ( static_cast< XUnoTunnel
* > ( this )),
322 static_cast< XWeak
* > ( this ),
323 // PropertySetHelper interfaces
324 static_cast< XPropertySet
* > ( this ),
325 static_cast< XMultiPropertySet
* > ( this ),
327 static_cast< XServiceInfo
* > ( this ),
328 static_cast< XRenderable
* > ( this ) );
329 if (!aRet
.hasValue())
330 aRet
= SfxBaseModel::queryInterface ( rType
);
334 void SAL_CALL
SmModel::acquire() throw()
336 OWeakObject::acquire();
339 void SAL_CALL
SmModel::release() throw()
341 OWeakObject::release();
344 uno::Sequence
< uno::Type
> SAL_CALL
SmModel::getTypes( ) throw(uno::RuntimeException
, std::exception
)
346 SolarMutexGuard aGuard
;
347 uno::Sequence
< uno::Type
> aTypes
= SfxBaseModel::getTypes();
348 sal_Int32 nLen
= aTypes
.getLength();
349 aTypes
.realloc(nLen
+ 4);
350 uno::Type
* pTypes
= aTypes
.getArray();
351 pTypes
[nLen
++] = cppu::UnoType
<XServiceInfo
>::get();
352 pTypes
[nLen
++] = cppu::UnoType
<XPropertySet
>::get();
353 pTypes
[nLen
++] = cppu::UnoType
<XMultiPropertySet
>::get();
354 pTypes
[nLen
++] = cppu::UnoType
<XRenderable
>::get();
361 class theSmModelUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSmModelUnoTunnelId
> {};
364 const uno::Sequence
< sal_Int8
> & SmModel::getUnoTunnelId()
366 return theSmModelUnoTunnelId::get().getSeq();
369 sal_Int64 SAL_CALL
SmModel::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
370 throw(uno::RuntimeException
, std::exception
)
372 if( rId
.getLength() == 16
373 && 0 == memcmp( getUnoTunnelId().getConstArray(),
374 rId
.getConstArray(), 16 ) )
376 return sal::static_int_cast
< sal_Int64
>(reinterpret_cast< sal_uIntPtr
>(this));
379 return SfxBaseModel::getSomething( rId
);
382 static sal_Int16
lcl_AnyToINT16(const uno::Any
& rAny
)
385 if( auto x
= o3tl::tryAccess
<double>(rAny
) )
386 nRet
= static_cast<sal_Int16
>(*x
);
392 OUString
SmModel::getImplementationName() throw( uno::RuntimeException
, std::exception
)
394 return OUString("com.sun.star.comp.Math.FormulaDocument");
397 sal_Bool
SmModel::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
, std::exception
)
399 return cppu::supportsService(this, rServiceName
);
402 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames() throw( uno::RuntimeException
, std::exception
)
404 return uno::Sequence
<OUString
>{
405 "com.sun.star.document.OfficeDocument",
406 "com.sun.star.formula.FormulaProperties"
410 void SmModel::_setPropertyValues(const PropertyMapEntry
** ppEntries
, const Any
* pValues
)
411 throw (RuntimeException
, UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, std::exception
)
413 SolarMutexGuard aGuard
;
415 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
417 if ( nullptr == pDocSh
)
418 throw UnknownPropertyException();
420 SmFormat aFormat
= pDocSh
->GetFormat();
422 for (; *ppEntries
; ppEntries
++, pValues
++ )
424 if ((*ppEntries
)->mnAttributes
& PropertyAttribute::READONLY
)
425 throw PropertyVetoException();
427 switch ( (*ppEntries
)->mnHandle
)
433 pDocSh
->SetText(aText
);
436 case HANDLE_FONT_NAME_VARIABLES
:
437 case HANDLE_FONT_NAME_FUNCTIONS
:
438 case HANDLE_FONT_NAME_NUMBERS
:
439 case HANDLE_FONT_NAME_TEXT
:
440 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
441 case HANDLE_CUSTOM_FONT_NAME_SANS
:
442 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
445 *pValues
>>= sFontName
;
446 if(sFontName
.isEmpty())
447 throw IllegalArgumentException();
449 if(OUString(aFormat
.GetFont((*ppEntries
)->mnMemberId
).GetFamilyName()) != sFontName
)
451 const SmFace rOld
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
453 SmFace
aSet( sFontName
, rOld
.GetFontSize() );
454 aSet
.SetBorderWidth( rOld
.GetBorderWidth() );
455 aSet
.SetAlignment( ALIGN_BASELINE
);
456 aFormat
.SetFont( (*ppEntries
)->mnMemberId
, aSet
);
460 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
461 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
462 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
463 case HANDLE_FONT_VARIABLES_POSTURE
:
464 case HANDLE_FONT_FUNCTIONS_POSTURE
:
465 case HANDLE_FONT_NUMBERS_POSTURE
:
466 case HANDLE_FONT_TEXT_POSTURE
:
468 auto bVal
= o3tl::tryAccess
<bool>(*pValues
);
470 throw IllegalArgumentException();
471 vcl::Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
472 aNewFont
.SetItalic(*bVal
? ITALIC_NORMAL
: ITALIC_NONE
);
473 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
476 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
477 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
478 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
479 case HANDLE_FONT_VARIABLES_WEIGHT
:
480 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
481 case HANDLE_FONT_NUMBERS_WEIGHT
:
482 case HANDLE_FONT_TEXT_WEIGHT
:
484 auto bVal
= o3tl::tryAccess
<bool>(*pValues
);
486 throw IllegalArgumentException();
487 vcl::Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
488 aNewFont
.SetWeight(*bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
);
489 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
492 case HANDLE_BASE_FONT_HEIGHT
:
495 sal_Int16 nVal
= lcl_AnyToINT16(*pValues
);
497 throw IllegalArgumentException();
498 Size aSize
= aFormat
.GetBaseSize();
499 aSize
.Height() = SmPtsTo100th_mm(nVal
);
500 aFormat
.SetBaseSize(aSize
);
502 // apply base size to fonts
503 const Size
aTmp( aFormat
.GetBaseSize() );
504 for (sal_uInt16 i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
505 aFormat
.SetFontSize(i
, aTmp
);
508 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
509 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
510 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
511 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
512 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
517 throw IllegalArgumentException();
518 aFormat
.SetRelSize((*ppEntries
)->mnMemberId
, nVal
);
522 case HANDLE_IS_TEXT_MODE
:
524 aFormat
.SetTextmode(*o3tl::doAccess
<bool>(*pValues
));
528 case HANDLE_GREEK_CHAR_STYLE
:
532 if (nVal
< 0 || nVal
> 2)
533 throw IllegalArgumentException();
534 aFormat
.SetGreekCharStyle( nVal
);
538 case HANDLE_ALIGNMENT
:
540 // SmHorAlign uses the same values as HorizontalAlignment
543 if(nVal
< 0 || nVal
> 2)
544 throw IllegalArgumentException();
545 aFormat
.SetHorAlign(static_cast<SmHorAlign
>(nVal
));
549 case HANDLE_RELATIVE_SPACING
:
550 case HANDLE_RELATIVE_LINE_SPACING
:
551 case HANDLE_RELATIVE_ROOT_SPACING
:
552 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
553 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
554 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
555 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
556 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
557 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
558 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
559 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
560 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
561 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
562 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
563 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
564 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
565 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
566 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
567 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
568 case HANDLE_RELATIVE_OPERATOR_SPACING
:
569 case HANDLE_LEFT_MARGIN
:
570 case HANDLE_RIGHT_MARGIN
:
571 case HANDLE_TOP_MARGIN
:
572 case HANDLE_BOTTOM_MARGIN
:
577 throw IllegalArgumentException();
578 aFormat
.SetDistance((*ppEntries
)->mnMemberId
, nVal
);
581 case HANDLE_IS_SCALE_ALL_BRACKETS
:
582 aFormat
.SetScaleNormalBrackets(*o3tl::doAccess
<bool>(*pValues
));
584 case HANDLE_PRINTER_NAME
:
586 // embedded documents just ignore this property for now
587 if ( pDocSh
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
)
589 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
592 OUString sPrinterName
;
593 if (*pValues
>>= sPrinterName
)
595 if ( !sPrinterName
.isEmpty() )
597 VclPtrInstance
<SfxPrinter
> pNewPrinter( pPrinter
->GetOptions().Clone(), sPrinterName
);
598 if (pNewPrinter
->IsKnown())
599 pDocSh
->SetPrinter ( pNewPrinter
);
601 pNewPrinter
.disposeAndClear();
605 throw IllegalArgumentException();
610 case HANDLE_PRINTER_SETUP
:
612 Sequence
< sal_Int8
> aSequence
;
613 if ( *pValues
>>= aSequence
)
615 sal_uInt32 nSize
= aSequence
.getLength();
616 SvMemoryStream
aStream ( aSequence
.getArray(), nSize
, StreamMode::READ
);
617 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
618 static sal_uInt16
const nRange
[] =
620 SID_PRINTSIZE
, SID_PRINTSIZE
,
621 SID_PRINTZOOM
, SID_PRINTZOOM
,
622 SID_PRINTTITLE
, SID_PRINTTITLE
,
623 SID_PRINTTEXT
, SID_PRINTTEXT
,
624 SID_PRINTFRAME
, SID_PRINTFRAME
,
625 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
626 SID_SAVE_ONLY_USED_SYMBOLS
, SID_SAVE_ONLY_USED_SYMBOLS
,
627 SID_AUTO_CLOSE_BRACKETS
, SID_AUTO_CLOSE_BRACKETS
,
630 SfxItemSet
*pItemSet
= new SfxItemSet( SmDocShell::GetPool(), nRange
);
631 SmModule
*pp
= SM_MOD();
632 pp
->GetConfig()->ConfigToItemSet(*pItemSet
);
633 VclPtr
<SfxPrinter
> pPrinter
= SfxPrinter::Create ( aStream
, pItemSet
);
635 pDocSh
->SetPrinter( pPrinter
);
638 throw IllegalArgumentException();
644 Sequence
< SymbolDescriptor
> aSequence
;
645 if ( *pValues
>>= aSequence
)
647 sal_uInt32 nSize
= aSequence
.getLength();
648 SmModule
*pp
= SM_MOD();
649 SmSymbolManager
&rManager
= pp
->GetSymbolManager();
650 SymbolDescriptor
*pDescriptor
= aSequence
.getArray();
651 for (sal_uInt32 i
= 0; i
< nSize
; i
++, pDescriptor
++)
654 aFont
.SetFamilyName ( pDescriptor
->sFontName
);
655 aFont
.SetCharSet ( static_cast < rtl_TextEncoding
> (pDescriptor
->nCharSet
) );
656 aFont
.SetFamily ( static_cast < FontFamily
> (pDescriptor
->nFamily
) );
657 aFont
.SetPitch ( static_cast < FontPitch
> (pDescriptor
->nPitch
) );
658 aFont
.SetWeight ( static_cast < FontWeight
> (pDescriptor
->nWeight
) );
659 aFont
.SetItalic ( static_cast < FontItalic
> (pDescriptor
->nItalic
) );
660 SmSym
aSymbol ( pDescriptor
->sName
, aFont
, static_cast < sal_Unicode
> (pDescriptor
->nCharacter
),
661 pDescriptor
->sSymbolSet
);
662 aSymbol
.SetExportName ( pDescriptor
->sExportName
);
663 aSymbol
.SetDocSymbol( true );
664 rManager
.AddOrReplaceSymbol ( aSymbol
);
668 throw IllegalArgumentException();
671 // #i33095# Security Options
672 case HANDLE_LOAD_READONLY
:
674 if ( (*pValues
).getValueType() != cppu::UnoType
<bool>::get() )
675 throw IllegalArgumentException();
676 bool bReadonly
= false;
677 if ( *pValues
>>= bReadonly
)
678 pDocSh
->SetLoadReadonly( bReadonly
);
681 case HANDLE_INTEROP_GRAB_BAG
:
682 setGrabBagItem(*pValues
);
687 pDocSh
->SetFormat( aFormat
);
689 // #i67283# since about all of the above changes are likely to change
690 // the formula size we have to recalculate the vis-area now
691 pDocSh
->SetVisArea( Rectangle( Point(0, 0), pDocSh
->GetSize() ) );
694 void SmModel::_getPropertyValues( const PropertyMapEntry
**ppEntries
, Any
*pValue
)
695 throw (RuntimeException
, UnknownPropertyException
, WrappedTargetException
, std::exception
)
697 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
699 if ( nullptr == pDocSh
)
700 throw UnknownPropertyException();
702 const SmFormat
& aFormat
= pDocSh
->GetFormat();
704 for (; *ppEntries
; ppEntries
++, pValue
++ )
706 switch ( (*ppEntries
)->mnHandle
)
709 *pValue
<<= OUString(pDocSh
->GetText());
711 case HANDLE_FONT_NAME_VARIABLES
:
712 case HANDLE_FONT_NAME_FUNCTIONS
:
713 case HANDLE_FONT_NAME_NUMBERS
:
714 case HANDLE_FONT_NAME_TEXT
:
715 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
716 case HANDLE_CUSTOM_FONT_NAME_SANS
:
717 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
719 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
720 *pValue
<<= OUString(rFace
.GetFamilyName());
723 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
724 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
725 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
726 case HANDLE_FONT_VARIABLES_POSTURE
:
727 case HANDLE_FONT_FUNCTIONS_POSTURE
:
728 case HANDLE_FONT_NUMBERS_POSTURE
:
729 case HANDLE_FONT_TEXT_POSTURE
:
731 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
732 *pValue
<<= IsItalic( rFace
);
735 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
736 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
737 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
738 case HANDLE_FONT_VARIABLES_WEIGHT
:
739 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
740 case HANDLE_FONT_NUMBERS_WEIGHT
:
741 case HANDLE_FONT_TEXT_WEIGHT
:
743 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
744 *pValue
<<= IsBold( rFace
);
747 case HANDLE_BASE_FONT_HEIGHT
:
750 *pValue
<<= sal_Int16(
752 Sm100th_mmToPts(aFormat
.GetBaseSize().Height())));
755 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
756 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
757 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
758 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
759 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
760 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetRelSize((*ppEntries
)->mnMemberId
));
763 case HANDLE_IS_TEXT_MODE
:
764 *pValue
<<= aFormat
.IsTextmode();
767 case HANDLE_GREEK_CHAR_STYLE
:
768 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetGreekCharStyle());
771 case HANDLE_ALIGNMENT
:
772 // SmHorAlign uses the same values as HorizontalAlignment
773 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetHorAlign());
776 case HANDLE_RELATIVE_SPACING
:
777 case HANDLE_RELATIVE_LINE_SPACING
:
778 case HANDLE_RELATIVE_ROOT_SPACING
:
779 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
780 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
781 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
782 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
783 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
784 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
785 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
786 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
787 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
788 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
789 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
790 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
791 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
792 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
793 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
794 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
795 case HANDLE_RELATIVE_OPERATOR_SPACING
:
796 case HANDLE_LEFT_MARGIN
:
797 case HANDLE_RIGHT_MARGIN
:
798 case HANDLE_TOP_MARGIN
:
799 case HANDLE_BOTTOM_MARGIN
:
800 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetDistance((*ppEntries
)->mnMemberId
));
802 case HANDLE_IS_SCALE_ALL_BRACKETS
:
803 *pValue
<<= aFormat
.IsScaleNormalBrackets();
805 case HANDLE_PRINTER_NAME
:
807 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
808 *pValue
<<= pPrinter
? OUString ( pPrinter
->GetName()) : OUString();
811 case HANDLE_PRINTER_SETUP
:
813 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ();
816 SvMemoryStream aStream
;
817 pPrinter
->Store( aStream
);
818 aStream
.Seek ( STREAM_SEEK_TO_END
);
819 sal_uInt32 nSize
= aStream
.Tell();
820 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
821 Sequence
< sal_Int8
> aSequence ( nSize
);
822 aStream
.ReadBytes(aSequence
.getArray(), nSize
);
823 *pValue
<<= aSequence
;
828 case HANDLE_USED_SYMBOLS
:
830 const bool bUsedSymbolsOnly
= (*ppEntries
)->mnHandle
== HANDLE_USED_SYMBOLS
;
831 const std::set
< OUString
> &rUsedSymbols
= pDocSh
->GetUsedSymbols();
834 SmModule
*pp
= SM_MOD();
835 const SmSymbolManager
&rManager
= pp
->GetSymbolManager();
836 vector
< const SmSym
* > aVector
;
838 const SymbolPtrVec_t
aSymbols( rManager
.GetSymbols() );
839 for (const SmSym
* pSymbol
: aSymbols
)
841 if (pSymbol
&& !pSymbol
->IsPredefined() &&
842 (!bUsedSymbolsOnly
||
843 rUsedSymbols
.find( pSymbol
->GetName() ) != rUsedSymbols
.end()))
844 aVector
.push_back ( pSymbol
);
846 Sequence
< SymbolDescriptor
> aSequence ( aVector
.size() );
847 SymbolDescriptor
* pDescriptor
= aSequence
.getArray();
849 vector
< const SmSym
* >::const_iterator aIter
= aVector
.begin(), aEnd
= aVector
.end();
850 for(; aIter
!= aEnd
; pDescriptor
++, ++aIter
)
852 pDescriptor
->sName
= (*aIter
)->GetName();
853 pDescriptor
->sExportName
= (*aIter
)->GetExportName();
854 pDescriptor
->sSymbolSet
= (*aIter
)->GetSymbolSetName();
855 pDescriptor
->nCharacter
= static_cast < sal_Int32
> ((*aIter
)->GetCharacter());
857 vcl::Font rFont
= (*aIter
)->GetFace();
858 pDescriptor
->sFontName
= rFont
.GetFamilyName();
859 pDescriptor
->nCharSet
= sal::static_int_cast
< sal_Int16
>(rFont
.GetCharSet());
860 pDescriptor
->nFamily
= sal::static_int_cast
< sal_Int16
>(rFont
.GetFamilyType());
861 pDescriptor
->nPitch
= sal::static_int_cast
< sal_Int16
>(rFont
.GetPitch());
862 pDescriptor
->nWeight
= sal::static_int_cast
< sal_Int16
>(rFont
.GetWeight());
863 pDescriptor
->nItalic
= sal::static_int_cast
< sal_Int16
>(rFont
.GetItalic());
865 *pValue
<<= aSequence
;
868 case HANDLE_BASIC_LIBRARIES
:
869 *pValue
<<= pDocSh
->GetBasicContainer();
871 case HANDLE_DIALOG_LIBRARIES
:
872 *pValue
<<= pDocSh
->GetDialogContainer();
874 case HANDLE_RUNTIME_UID
:
875 *pValue
<<= getRuntimeUID();
877 // #i33095# Security Options
878 case HANDLE_LOAD_READONLY
:
880 *pValue
<<= pDocSh
->IsLoadReadonly();
884 case HANDLE_BASELINE
:
886 if ( !pDocSh
->GetFormulaTree() )
888 if ( pDocSh
->GetFormulaTree() )
890 pDocSh
->ArrangeFormula();
892 *pValue
<<= static_cast<sal_Int32
>( pDocSh
->GetFormulaTree()->GetFormulaBaseline() );
896 case HANDLE_INTEROP_GRAB_BAG
:
897 getGrabBagItem(*pValue
);
904 sal_Int32 SAL_CALL
SmModel::getRendererCount(
905 const uno::Any
& /*rSelection*/,
906 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
907 throw (IllegalArgumentException
, RuntimeException
, std::exception
)
909 SolarMutexGuard aGuard
;
914 static Size
lcl_GuessPaperSize()
917 const LocaleDataWrapper
& rLocWrp( AllSettings().GetLocaleDataWrapper() );
918 if( MEASURE_METRIC
== rLocWrp
.getMeasurementSystemEnum() )
921 PaperInfo
aInfo( PAPER_A4
);
922 aRes
.Width() = aInfo
.getWidth();
923 aRes
.Height() = aInfo
.getHeight();
928 PaperInfo
aInfo( PAPER_LETTER
);
929 aRes
.Width() = aInfo
.getWidth();
930 aRes
.Height() = aInfo
.getHeight();
935 uno::Sequence
< beans::PropertyValue
> SAL_CALL
SmModel::getRenderer(
937 const uno::Any
& /*rSelection*/,
938 const uno::Sequence
< beans::PropertyValue
>& /*rxOptions*/ )
939 throw (IllegalArgumentException
, RuntimeException
, std::exception
)
941 SolarMutexGuard aGuard
;
944 throw IllegalArgumentException();
946 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
948 throw RuntimeException();
950 SmPrinterAccess
aPrinterAccess( *pDocSh
);
951 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
952 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
954 // if paper size is 0 (usually if no 'real' printer is found),
955 // guess the paper size
956 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
957 aPrtPaperSize
= lcl_GuessPaperSize();
958 awt::Size
aPageSize( aPrtPaperSize
.Width(), aPrtPaperSize
.Height() );
960 uno::Sequence
< beans::PropertyValue
> aRenderer(1);
961 PropertyValue
&rValue
= aRenderer
.getArray()[0];
962 rValue
.Name
= "PageSize";
963 rValue
.Value
<<= aPageSize
;
965 if (!m_pPrintUIOptions
)
966 m_pPrintUIOptions
.reset(new SmPrintUIOptions
);
967 m_pPrintUIOptions
->appendPrintUIOptions( aRenderer
);
972 void SAL_CALL
SmModel::render(
974 const uno::Any
& rSelection
,
975 const uno::Sequence
< beans::PropertyValue
>& rxOptions
)
976 throw (IllegalArgumentException
, RuntimeException
, std::exception
)
978 SolarMutexGuard aGuard
;
981 throw IllegalArgumentException();
983 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
985 throw RuntimeException();
987 // get device to be rendered in
988 uno::Reference
< awt::XDevice
> xRenderDevice
;
989 for (sal_Int32 i
= 0, nCount
= rxOptions
.getLength(); i
< nCount
; ++i
)
991 if( rxOptions
[i
].Name
== "RenderDevice" )
992 rxOptions
[i
].Value
>>= xRenderDevice
;
995 if (xRenderDevice
.is())
997 VCLXDevice
* pDevice
= VCLXDevice::GetImplementation( xRenderDevice
);
998 VclPtr
< OutputDevice
> pOut
= pDevice
? pDevice
->GetOutputDevice()
999 : VclPtr
< OutputDevice
>();
1001 throw RuntimeException();
1003 pOut
->SetMapMode( MapUnit::Map100thMM
);
1005 uno::Reference
< frame::XModel
> xModel
;
1006 rSelection
>>= xModel
;
1007 if (xModel
== pDocSh
->GetModel())
1009 //!! when called via API we may not have an active view
1010 //!! thus we go and look for a view that can be used.
1011 SfxViewShell
* pViewSh
= SfxViewShell::GetFirst( false /* search non-visible views as well*/, checkSfxViewShell
<SmViewShell
> );
1012 while (pViewSh
&& pViewSh
->GetObjectShell() != pDocSh
)
1013 pViewSh
= SfxViewShell::GetNext( *pViewSh
, false /* search non-visible views as well*/, checkSfxViewShell
<SmViewShell
> );
1014 SmViewShell
*pView
= dynamic_cast< SmViewShell
*>( pViewSh
);
1015 SAL_WARN_IF( !pView
, "starmath", "SmModel::render : no SmViewShell found" );
1019 SmPrinterAccess
aPrinterAccess( *pDocSh
);
1020 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
1022 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
1023 Size
aOutputSize ( pPrinter
->GetOutputSize() );
1024 Point
aPrtPageOffset( pPrinter
->GetPageOffset() );
1026 // no real printer ??
1027 if (aPrtPaperSize
.Height() == 0 || aPrtPaperSize
.Width() == 0)
1029 aPrtPaperSize
= lcl_GuessPaperSize();
1030 // factors from Windows DIN A4
1031 aOutputSize
= Size( static_cast<long>(aPrtPaperSize
.Width() * 0.941),
1032 static_cast<long>(aPrtPaperSize
.Height() * 0.961));
1033 aPrtPageOffset
= Point( static_cast<long>(aPrtPaperSize
.Width() * 0.0250),
1034 static_cast<long>(aPrtPaperSize
.Height() * 0.0214));
1037 Rectangle
OutputRect( aZeroPoint
, aOutputSize
);
1040 // set minimum top and bottom border
1041 if (aPrtPageOffset
.Y() < 2000)
1042 OutputRect
.Top() += 2000 - aPrtPageOffset
.Y();
1043 if ((aPrtPaperSize
.Height() - (aPrtPageOffset
.Y() + OutputRect
.Bottom())) < 2000)
1044 OutputRect
.Bottom() -= 2000 - (aPrtPaperSize
.Height() -
1045 (aPrtPageOffset
.Y() + OutputRect
.Bottom()));
1047 // set minimum left and right border
1048 if (aPrtPageOffset
.X() < 2500)
1049 OutputRect
.Left() += 2500 - aPrtPageOffset
.X();
1050 if ((aPrtPaperSize
.Width() - (aPrtPageOffset
.X() + OutputRect
.Right())) < 1500)
1051 OutputRect
.Right() -= 1500 - (aPrtPaperSize
.Width() -
1052 (aPrtPageOffset
.X() + OutputRect
.Right()));
1054 if (!m_pPrintUIOptions
)
1055 m_pPrintUIOptions
.reset(new SmPrintUIOptions
);
1056 m_pPrintUIOptions
->processProperties( rxOptions
);
1058 pView
->Impl_Print( *pOut
, *m_pPrintUIOptions
, Rectangle( OutputRect
), Point() );
1060 // release SmPrintUIOptions when everything is done.
1061 // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
1062 if (m_pPrintUIOptions
->getBoolValue( "IsLastPage" ))
1064 m_pPrintUIOptions
.reset();
1071 void SAL_CALL
SmModel::setParent( const uno::Reference
< uno::XInterface
>& xParent
)
1072 throw( lang::NoSupportException
, uno::RuntimeException
, std::exception
)
1074 SolarMutexGuard aGuard
;
1075 SfxBaseModel::setParent( xParent
);
1076 uno::Reference
< lang::XUnoTunnel
> xParentTunnel( xParent
, uno::UNO_QUERY
);
1077 if ( xParentTunnel
.is() )
1079 SvGlobalName
aSfxIdent( SFX_GLOBAL_CLASSID
);
1080 SfxObjectShell
* pDoc
= reinterpret_cast<SfxObjectShell
*>(xParentTunnel
->getSomething(
1081 uno::Sequence
< sal_Int8
>( aSfxIdent
.GetByteSequence() ) ) );
1083 GetObjectShell()->OnDocumentPrinterChanged( pDoc
->GetDocumentPrinter() );
1087 void SmModel::writeFormulaOoxml(
1088 ::sax_fastparser::FSHelperPtr
const pSerializer
,
1089 oox::core::OoxmlVersion
const version
,
1090 oox::drawingml::DocumentType
const documentType
)
1092 static_cast<SmDocShell
*>(GetObjectShell())->writeFormulaOoxml(pSerializer
, version
, documentType
);
1095 void SmModel::writeFormulaRtf(OStringBuffer
& rBuffer
, rtl_TextEncoding nEncoding
)
1097 static_cast<SmDocShell
*>(GetObjectShell())->writeFormulaRtf(rBuffer
, nEncoding
);
1100 void SmModel::readFormulaOoxml( oox::formulaimport::XmlStream
& stream
)
1102 static_cast< SmDocShell
* >( GetObjectShell())->readFormulaOoxml( stream
);
1105 Size
SmModel::getFormulaSize() const
1107 return static_cast< SmDocShell
* >( GetObjectShell())->GetSize();
1110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */