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>
21 #include <sal/log.hxx>
25 #include <o3tl/any.hxx>
26 #include <sfx2/printer.hxx>
27 #include <svl/itemprop.hxx>
28 #include <svl/itemset.hxx>
29 #include <vcl/svapp.hxx>
30 #include <unotools/localedatawrapper.hxx>
31 #include <vcl/settings.hxx>
32 #include <vcl/print.hxx>
33 #include <toolkit/awt/vclxdevice.hxx>
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <com/sun/star/formula/SymbolDescriptor.hpp>
36 #include <com/sun/star/awt/Size.hpp>
37 #include <comphelper/propertysetinfo.hxx>
38 #include <comphelper/propertyvalue.hxx>
39 #include <comphelper/sequence.hxx>
40 #include <comphelper/servicehelper.hxx>
41 #include <cppuhelper/queryinterface.hxx>
42 #include <cppuhelper/supportsservice.hxx>
43 #include <editeng/paperinf.hxx>
44 #include <unotools/moduleoptions.hxx>
45 #include <tools/mapunit.hxx>
46 #include <tools/stream.hxx>
48 #include <unomodel.hxx>
49 #include <document.hxx>
52 #include <starmath.hrc>
53 #include <strings.hrc>
55 #include <cfgitem.hxx>
57 using namespace ::cppu
;
58 using namespace ::comphelper
;
59 using namespace ::com::sun::star
;
60 using namespace ::com::sun::star::uno
;
61 using namespace ::com::sun::star::beans
;
62 using namespace ::com::sun::star::lang
;
63 using namespace ::com::sun::star::formula
;
64 using namespace ::com::sun::star::view
;
65 using namespace ::com::sun::star::script
;
67 SmPrintUIOptions::SmPrintUIOptions()
69 SmModule
*pp
= SM_MOD();
70 SmMathConfig
*pConfig
= pp
->GetConfig();
71 SAL_WARN_IF( !pConfig
, "starmath", "SmConfig not found" );
75 sal_Int32 nNumProps
= 10, nIdx
=0;
77 // create sequence of print UI options
78 // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
79 m_aUIProperties
.resize( nNumProps
);
81 // load the math PrinterOptions into the custom tab
82 m_aUIProperties
[nIdx
].Name
= "OptionsUIFile";
83 m_aUIProperties
[nIdx
++].Value
<<= OUString("modules/smath/ui/printeroptions.ui");
85 // create Section for formula (results in an extra tab page in dialog)
86 SvtModuleOptions aOpt
;
87 OUString
aAppGroupname(
88 SmResId( RID_PRINTUIOPT_PRODNAME
).
89 replaceFirst( "%s", aOpt
.GetModuleName( SvtModuleOptions::EModule::MATH
) ) );
90 m_aUIProperties
[nIdx
++].Value
= setGroupControlOpt("tabcontrol-page2", aAppGroupname
, ".HelpID:vcl:PrintDialog:TabPage:AppPage");
92 // create subgroup for print options
93 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("contents", SmResId( RID_PRINTUIOPT_CONTENTS
), OUString());
95 // create a bool option for title row (matches to SID_PRINTTITLE)
96 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("title", SmResId( RID_PRINTUIOPT_TITLE
),
97 ".HelpID:vcl:PrintDialog:TitleRow:CheckBox",
99 pConfig
->IsPrintTitle());
100 // create a bool option for formula text (matches to SID_PRINTTEXT)
101 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("formulatext", SmResId( RID_PRINTUIOPT_FRMLTXT
),
102 ".HelpID:vcl:PrintDialog:FormulaText:CheckBox",
103 PRTUIOPT_FORMULA_TEXT
,
104 pConfig
->IsPrintFormulaText());
105 // create a bool option for border (matches to SID_PRINTFRAME)
106 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("borders", SmResId( RID_PRINTUIOPT_BORDERS
),
107 ".HelpID:vcl:PrintDialog:Border:CheckBox",
109 pConfig
->IsPrintFrame());
111 // create subgroup for print format
112 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("size", SmResId( RID_PRINTUIOPT_SIZE
), OUString());
114 // create a radio button group for print format (matches to SID_PRINTSIZE)
115 Sequence
< OUString
> aChoices
{
116 SmResId( RID_PRINTUIOPT_ORIGSIZE
),
117 SmResId( RID_PRINTUIOPT_FITTOPAGE
),
118 SmResId( RID_PRINTUIOPT_SCALING
)
120 Sequence
< OUString
> aHelpIds
{
121 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0",
122 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1",
123 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2"
125 Sequence
< OUString
> aWidgetIds
{
130 OUString
aPrintFormatProp( PRTUIOPT_PRINT_FORMAT
);
131 m_aUIProperties
[nIdx
++].Value
= setChoiceRadiosControlOpt(aWidgetIds
, OUString(),
134 aChoices
, static_cast< sal_Int32
>(pConfig
->GetPrintSize())
137 // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
138 vcl::PrinterOptionsHelper::UIControlOptions
aRangeOpt( aPrintFormatProp
, 2, true );
139 m_aUIProperties
[nIdx
++].Value
= setRangeControlOpt("scalingspin", OUString(),
140 ".HelpID:vcl:PrintDialog:PrintScale:NumericField",
141 PRTUIOPT_PRINT_SCALE
,
142 pConfig
->GetPrintZoomFactor(), // initial value
147 Sequence aHintNoLayoutPage
{ comphelper::makePropertyValue("HintNoLayoutPage", true) };
148 m_aUIProperties
[nIdx
++].Value
<<= aHintNoLayoutPage
;
150 assert(nIdx
== nNumProps
);
157 enum SmModelPropertyHandles
160 HANDLE_FONT_NAME_VARIABLES
,
161 HANDLE_FONT_NAME_FUNCTIONS
,
162 HANDLE_FONT_NAME_NUMBERS
,
163 HANDLE_FONT_NAME_TEXT
,
164 HANDLE_CUSTOM_FONT_NAME_SERIF
,
165 HANDLE_CUSTOM_FONT_NAME_SANS
,
166 HANDLE_CUSTOM_FONT_NAME_FIXED
,
167 HANDLE_CUSTOM_FONT_FIXED_POSTURE
,
168 HANDLE_CUSTOM_FONT_FIXED_WEIGHT
,
169 HANDLE_CUSTOM_FONT_SANS_POSTURE
,
170 HANDLE_CUSTOM_FONT_SANS_WEIGHT
,
171 HANDLE_CUSTOM_FONT_SERIF_POSTURE
,
172 HANDLE_CUSTOM_FONT_SERIF_WEIGHT
,
173 HANDLE_FONT_VARIABLES_POSTURE
,
174 HANDLE_FONT_VARIABLES_WEIGHT
,
175 HANDLE_FONT_FUNCTIONS_POSTURE
,
176 HANDLE_FONT_FUNCTIONS_WEIGHT
,
177 HANDLE_FONT_NUMBERS_POSTURE
,
178 HANDLE_FONT_NUMBERS_WEIGHT
,
179 HANDLE_FONT_TEXT_POSTURE
,
180 HANDLE_FONT_TEXT_WEIGHT
,
181 HANDLE_BASE_FONT_HEIGHT
,
182 HANDLE_RELATIVE_FONT_HEIGHT_TEXT
,
183 HANDLE_RELATIVE_FONT_HEIGHT_INDICES
,
184 HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
,
185 HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
,
186 HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
,
188 HANDLE_GREEK_CHAR_STYLE
,
190 HANDLE_RELATIVE_SPACING
,
191 HANDLE_RELATIVE_LINE_SPACING
,
192 HANDLE_RELATIVE_ROOT_SPACING
,
193 HANDLE_RELATIVE_INDEX_SUPERSCRIPT
,
194 HANDLE_RELATIVE_INDEX_SUBSCRIPT
,
195 HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
,
196 HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
,
197 HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
,
198 HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
,
199 HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
,
200 HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
,
201 HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
,
202 HANDLE_RELATIVE_BRACKET_DISTANCE
,
203 HANDLE_IS_SCALE_ALL_BRACKETS
,
204 HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
,
205 HANDLE_RELATIVE_MATRIX_LINE_SPACING
,
206 HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
,
207 HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
,
208 HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
,
209 HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
,
210 HANDLE_RELATIVE_OPERATOR_SPACING
,
214 HANDLE_BOTTOM_MARGIN
,
216 HANDLE_PRINTER_SETUP
,
218 HANDLE_SAVE_THUMBNAIL
,
220 HANDLE_BASIC_LIBRARIES
,
222 HANDLE_LOAD_READONLY
, // Security Options
223 HANDLE_DIALOG_LIBRARIES
, // #i73329#
225 HANDLE_INTEROP_GRAB_BAG
,
226 HANDLE_STARMATH_VERSION
231 static const rtl::Reference
<PropertySetInfo
> & lcl_createModelPropertyInfo ()
233 static const PropertyMapEntry aModelPropertyInfoMap
[] =
235 { OUString("Alignment") , HANDLE_ALIGNMENT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
236 { OUString("BaseFontHeight") , HANDLE_BASE_FONT_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
237 { OUString("BasicLibraries") , HANDLE_BASIC_LIBRARIES
, cppu::UnoType
<script::XLibraryContainer
>::get(), PropertyAttribute::READONLY
, 0 },
238 { OUString("BottomMargin") , HANDLE_BOTTOM_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BOTTOMSPACE
},
239 { OUString("CustomFontNameFixed") , HANDLE_CUSTOM_FONT_NAME_FIXED
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_FIXED
},
240 { OUString("CustomFontNameSans") , HANDLE_CUSTOM_FONT_NAME_SANS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_SANS
},
241 { OUString("CustomFontNameSerif") , HANDLE_CUSTOM_FONT_NAME_SERIF
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_SERIF
},
242 { OUString("DialogLibraries") , HANDLE_DIALOG_LIBRARIES
, cppu::UnoType
<script::XLibraryContainer
>::get(), PropertyAttribute::READONLY
, 0 },
243 { OUString("FontFixedIsBold") , HANDLE_CUSTOM_FONT_FIXED_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FIXED
},
244 { OUString("FontFixedIsItalic") , HANDLE_CUSTOM_FONT_FIXED_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FIXED
},
245 { OUString("FontFunctionsIsBold") , HANDLE_FONT_FUNCTIONS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
246 { OUString("FontFunctionsIsItalic") , HANDLE_FONT_FUNCTIONS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
247 { OUString("FontNameFunctions") , HANDLE_FONT_NAME_FUNCTIONS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
248 { OUString("FontNameNumbers") , HANDLE_FONT_NAME_NUMBERS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_NUMBER
},
249 { OUString("FontNameText") , HANDLE_FONT_NAME_TEXT
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_TEXT
},
250 { OUString("FontNameVariables") , HANDLE_FONT_NAME_VARIABLES
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
251 { OUString("FontNumbersIsBold") , HANDLE_FONT_NUMBERS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_NUMBER
},
252 { OUString("FontNumbersIsItalic") , HANDLE_FONT_NUMBERS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_NUMBER
},
253 { OUString("FontSansIsBold") , HANDLE_CUSTOM_FONT_SANS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SANS
},
254 { OUString("FontSansIsItalic") , HANDLE_CUSTOM_FONT_SANS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SANS
},
255 { OUString("FontSerifIsBold") , HANDLE_CUSTOM_FONT_SERIF_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SERIF
},
256 { OUString("FontSerifIsItalic") , HANDLE_CUSTOM_FONT_SERIF_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SERIF
},
257 { OUString("FontTextIsBold") , HANDLE_FONT_TEXT_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_TEXT
},
258 { OUString("FontTextIsItalic") , HANDLE_FONT_TEXT_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_TEXT
},
259 { OUString("FontVariablesIsBold") , HANDLE_FONT_VARIABLES_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
260 { OUString("FontVariablesIsItalic") , HANDLE_FONT_VARIABLES_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
261 { OUString("Formula") , HANDLE_FORMULA
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0 },
262 { OUString("IsScaleAllBrackets") , HANDLE_IS_SCALE_ALL_BRACKETS
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
263 { OUString("IsTextMode") , HANDLE_IS_TEXT_MODE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
264 { OUString("GreekCharStyle") , HANDLE_GREEK_CHAR_STYLE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
265 { OUString("LeftMargin") , HANDLE_LEFT_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_LEFTSPACE
},
266 { OUString("PrinterName") , HANDLE_PRINTER_NAME
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0 },
267 { OUString("PrinterSetup") , HANDLE_PRINTER_SETUP
, cppu::UnoType
<const Sequence
< sal_Int8
>>::get(), PROPERTY_NONE
, 0 },
268 { OUString("RelativeBracketDistance") , HANDLE_RELATIVE_BRACKET_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BRACKETSPACE
},
269 { OUString("RelativeBracketExcessSize") , HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BRACKETSIZE
},
270 { OUString("RelativeFontHeightFunctions") , HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_FUNCTION
},
271 { OUString("RelativeFontHeightIndices") , HANDLE_RELATIVE_FONT_HEIGHT_INDICES
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_INDEX
},
272 { OUString("RelativeFontHeightLimits") , HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_LIMITS
},
273 { OUString("RelativeFontHeightOperators") , HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_OPERATOR
},
274 { OUString("RelativeFontHeightText") , HANDLE_RELATIVE_FONT_HEIGHT_TEXT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_TEXT
},
275 { OUString("RelativeFractionBarExcessLength") , HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_FRACTION
},
276 { OUString("RelativeFractionBarLineWeight") , HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_STROKEWIDTH
},
277 { OUString("RelativeFractionDenominatorDepth") , HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_DENOMINATOR
},
278 { OUString("RelativeFractionNumeratorHeight") , HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_NUMERATOR
},
279 { OUString("RelativeIndexSubscript") , HANDLE_RELATIVE_INDEX_SUBSCRIPT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_SUBSCRIPT
},
280 { OUString("RelativeIndexSuperscript") , HANDLE_RELATIVE_INDEX_SUPERSCRIPT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_SUPERSCRIPT
},
281 { OUString("RelativeLineSpacing") , HANDLE_RELATIVE_LINE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_VERTICAL
},
282 { OUString("RelativeLowerLimitDistance") , HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_LOWERLIMIT
},
283 { OUString("RelativeMatrixColumnSpacing") , HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_MATRIXCOL
},
284 { OUString("RelativeMatrixLineSpacing") , HANDLE_RELATIVE_MATRIX_LINE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_MATRIXROW
},
285 { OUString("RelativeOperatorExcessSize") , HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_OPERATORSIZE
},
286 { OUString("RelativeOperatorSpacing") , HANDLE_RELATIVE_OPERATOR_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_OPERATORSPACE
},
287 { OUString("RelativeRootSpacing") , HANDLE_RELATIVE_ROOT_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ROOT
},
288 { OUString("RelativeScaleBracketExcessSize") , HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_NORMALBRACKETSIZE
},
289 { OUString("RelativeSpacing") , HANDLE_RELATIVE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_HORIZONTAL
},
290 { OUString("RelativeSymbolMinimumHeight") , HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ORNAMENTSPACE
},
291 { OUString("RelativeSymbolPrimaryHeight") , HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ORNAMENTSIZE
},
292 { OUString("RelativeUpperLimitDistance") , HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_UPPERLIMIT
},
293 { OUString("RightMargin") , HANDLE_RIGHT_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_RIGHTSPACE
},
294 { OUString("RuntimeUID") , HANDLE_RUNTIME_UID
, cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
, 0 },
295 { OUString("SaveThumbnail") , HANDLE_SAVE_THUMBNAIL
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
296 { OUString("Symbols") , HANDLE_SYMBOLS
, cppu::UnoType
<Sequence
< SymbolDescriptor
>>::get(), PROPERTY_NONE
, 0 },
297 { OUString("UserDefinedSymbolsInUse") , HANDLE_USED_SYMBOLS
, cppu::UnoType
<Sequence
< SymbolDescriptor
>>::get(), PropertyAttribute::READONLY
, 0 },
298 { OUString("TopMargin") , HANDLE_TOP_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_TOPSPACE
},
299 // #i33095# Security Options
300 { OUString("LoadReadonly") , HANDLE_LOAD_READONLY
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
302 { OUString("BaseLine") , HANDLE_BASELINE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
303 { OUString("InteropGrabBag") , HANDLE_INTEROP_GRAB_BAG
, cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get(), PROPERTY_NONE
, 0 },
304 { OUString("SyntaxVersion") , HANDLE_STARMATH_VERSION
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
306 static const rtl::Reference
<PropertySetInfo
> PROPS_INFO
= new PropertySetInfo ( aModelPropertyInfoMap
);
310 SmModel::SmModel( SfxObjectShell
*pObjSh
)
311 : SfxBaseModel(pObjSh
)
312 , PropertySetHelper ( lcl_createModelPropertyInfo () )
316 SmModel::~SmModel() noexcept
320 uno::Any SAL_CALL
SmModel::queryInterface( const uno::Type
& rType
)
322 uno::Any aRet
= ::cppu::queryInterface ( rType
,
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() noexcept
336 OWeakObject::acquire();
339 void SAL_CALL
SmModel::release() noexcept
341 OWeakObject::release();
344 uno::Sequence
< uno::Type
> SAL_CALL
SmModel::getTypes( )
346 return comphelper::concatSequences(SfxBaseModel::getTypes(),
348 cppu::UnoType
<XServiceInfo
>::get(),
349 cppu::UnoType
<XPropertySet
>::get(),
350 cppu::UnoType
<XMultiPropertySet
>::get(),
351 cppu::UnoType
<XRenderable
>::get() });
354 const uno::Sequence
< sal_Int8
> & SmModel::getUnoTunnelId()
356 static const comphelper::UnoIdInit theSmModelUnoTunnelId
;
357 return theSmModelUnoTunnelId
.getSeq();
360 sal_Int64 SAL_CALL
SmModel::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
362 return comphelper::getSomethingImpl(rId
, this,
363 comphelper::FallbackToGetSomethingOf
<SfxBaseModel
>{});
366 static sal_Int16
lcl_AnyToINT16(const uno::Any
& rAny
)
369 if( auto x
= o3tl::tryAccess
<double>(rAny
) )
370 nRet
= static_cast<sal_Int16
>(*x
);
376 OUString
SmModel::getImplementationName()
378 return "com.sun.star.comp.Math.FormulaDocument";
381 sal_Bool
SmModel::supportsService(const OUString
& rServiceName
)
383 return cppu::supportsService(this, rServiceName
);
386 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames()
388 static constexpr OUStringLiteral service1
= u
"com.sun.star.document.OfficeDocument";
389 static constexpr OUStringLiteral service2
= u
"com.sun.star.formula.FormulaProperties";
390 return uno::Sequence
<OUString
>{ service1
, service2
};
393 void SmModel::_setPropertyValues(const PropertyMapEntry
** ppEntries
, const Any
* pValues
)
395 SolarMutexGuard aGuard
;
397 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
399 if ( nullptr == pDocSh
)
400 throw UnknownPropertyException();
402 SmFormat aFormat
= pDocSh
->GetFormat();
404 for (; *ppEntries
; ppEntries
++, pValues
++ )
406 if ((*ppEntries
)->mnAttributes
& PropertyAttribute::READONLY
)
407 throw PropertyVetoException();
409 switch ( (*ppEntries
)->mnHandle
)
415 pDocSh
->SetText(aText
);
418 case HANDLE_FONT_NAME_VARIABLES
:
419 case HANDLE_FONT_NAME_FUNCTIONS
:
420 case HANDLE_FONT_NAME_NUMBERS
:
421 case HANDLE_FONT_NAME_TEXT
:
422 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
423 case HANDLE_CUSTOM_FONT_NAME_SANS
:
424 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
427 *pValues
>>= sFontName
;
428 if(sFontName
.isEmpty())
429 throw IllegalArgumentException();
431 if(aFormat
.GetFont((*ppEntries
)->mnMemberId
).GetFamilyName() != sFontName
)
433 const SmFace rOld
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
435 SmFace
aSet( sFontName
, rOld
.GetFontSize() );
436 aSet
.SetBorderWidth( rOld
.GetBorderWidth() );
437 aSet
.SetAlignment( ALIGN_BASELINE
);
438 aFormat
.SetFont( (*ppEntries
)->mnMemberId
, aSet
);
442 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
443 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
444 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
445 case HANDLE_FONT_VARIABLES_POSTURE
:
446 case HANDLE_FONT_FUNCTIONS_POSTURE
:
447 case HANDLE_FONT_NUMBERS_POSTURE
:
448 case HANDLE_FONT_TEXT_POSTURE
:
450 auto bVal
= o3tl::tryAccess
<bool>(*pValues
);
452 throw IllegalArgumentException();
453 vcl::Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
454 aNewFont
.SetItalic(*bVal
? ITALIC_NORMAL
: ITALIC_NONE
);
455 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
458 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
459 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
460 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
461 case HANDLE_FONT_VARIABLES_WEIGHT
:
462 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
463 case HANDLE_FONT_NUMBERS_WEIGHT
:
464 case HANDLE_FONT_TEXT_WEIGHT
:
466 auto bVal
= o3tl::tryAccess
<bool>(*pValues
);
468 throw IllegalArgumentException();
469 vcl::Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
470 aNewFont
.SetWeight(*bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
);
471 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
474 case HANDLE_BASE_FONT_HEIGHT
:
477 sal_Int16 nVal
= lcl_AnyToINT16(*pValues
);
479 throw IllegalArgumentException();
480 Size aSize
= aFormat
.GetBaseSize();
481 aSize
.setHeight(o3tl::convert(nVal
, o3tl::Length::pt
, SmO3tlLengthUnit()));
482 aFormat
.SetBaseSize(aSize
);
484 // apply base size to fonts
485 const Size
aTmp( aFormat
.GetBaseSize() );
486 for (sal_uInt16 i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
487 aFormat
.SetFontSize(i
, aTmp
);
490 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
491 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
492 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
493 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
494 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
499 throw IllegalArgumentException();
500 aFormat
.SetRelSize((*ppEntries
)->mnMemberId
, nVal
);
504 case HANDLE_IS_TEXT_MODE
:
506 aFormat
.SetTextmode(*o3tl::doAccess
<bool>(*pValues
));
510 case HANDLE_GREEK_CHAR_STYLE
:
514 if (nVal
< 0 || nVal
> 2)
515 throw IllegalArgumentException();
516 aFormat
.SetGreekCharStyle( nVal
);
520 case HANDLE_ALIGNMENT
:
522 // SmHorAlign uses the same values as HorizontalAlignment
525 if(nVal
< 0 || nVal
> 2)
526 throw IllegalArgumentException();
527 aFormat
.SetHorAlign(static_cast<SmHorAlign
>(nVal
));
531 case HANDLE_RELATIVE_SPACING
:
532 case HANDLE_RELATIVE_LINE_SPACING
:
533 case HANDLE_RELATIVE_ROOT_SPACING
:
534 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
535 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
536 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
537 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
538 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
539 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
540 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
541 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
542 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
543 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
544 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
545 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
546 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
547 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
548 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
549 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
550 case HANDLE_RELATIVE_OPERATOR_SPACING
:
551 case HANDLE_LEFT_MARGIN
:
552 case HANDLE_RIGHT_MARGIN
:
553 case HANDLE_TOP_MARGIN
:
554 case HANDLE_BOTTOM_MARGIN
:
559 throw IllegalArgumentException();
560 aFormat
.SetDistance((*ppEntries
)->mnMemberId
, nVal
);
563 case HANDLE_IS_SCALE_ALL_BRACKETS
:
564 aFormat
.SetScaleNormalBrackets(*o3tl::doAccess
<bool>(*pValues
));
566 case HANDLE_PRINTER_NAME
:
568 // embedded documents just ignore this property for now
569 if ( pDocSh
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
)
571 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
574 OUString sPrinterName
;
575 if ( !(*pValues
>>= sPrinterName
) )
576 throw IllegalArgumentException();
578 if ( !sPrinterName
.isEmpty() )
580 VclPtrInstance
<SfxPrinter
> pNewPrinter( pPrinter
->GetOptions().Clone(), sPrinterName
);
581 if (pNewPrinter
->IsKnown())
582 pDocSh
->SetPrinter ( pNewPrinter
);
584 pNewPrinter
.disposeAndClear();
590 case HANDLE_PRINTER_SETUP
:
592 Sequence
< sal_Int8
> aSequence
;
593 if ( !(*pValues
>>= aSequence
) )
594 throw IllegalArgumentException();
596 sal_uInt32 nSize
= aSequence
.getLength();
597 SvMemoryStream
aStream ( aSequence
.getArray(), nSize
, StreamMode::READ
);
598 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
599 auto pItemSet
= std::make_unique
<SfxItemSetFixed
<
600 SID_PRINTTITLE
, SID_PRINTTITLE
,
601 SID_PRINTTEXT
, SID_PRINTTEXT
,
602 SID_PRINTFRAME
, SID_PRINTFRAME
,
603 SID_PRINTSIZE
, SID_PRINTSIZE
,
604 SID_PRINTZOOM
, SID_PRINTZOOM
,
605 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
606 SID_SAVE_ONLY_USED_SYMBOLS
, SID_SAVE_ONLY_USED_SYMBOLS
,
607 SID_AUTO_CLOSE_BRACKETS
, SID_SMEDITWINDOWZOOM
>> ( SmDocShell::GetPool() );
608 SmModule
*pp
= SM_MOD();
609 pp
->GetConfig()->ConfigToItemSet(*pItemSet
);
610 VclPtr
<SfxPrinter
> pPrinter
= SfxPrinter::Create ( aStream
, std::move(pItemSet
) );
612 pDocSh
->SetPrinter( pPrinter
);
618 Sequence
< SymbolDescriptor
> aSequence
;
619 if ( !(*pValues
>>= aSequence
) )
620 throw IllegalArgumentException();
622 SmModule
*pp
= SM_MOD();
623 SmSymbolManager
&rManager
= pp
->GetSymbolManager();
624 for (const SymbolDescriptor
& rDescriptor
: std::as_const(aSequence
))
627 aFont
.SetFamilyName ( rDescriptor
.sFontName
);
628 aFont
.SetCharSet ( static_cast < rtl_TextEncoding
> (rDescriptor
.nCharSet
) );
629 aFont
.SetFamily ( static_cast < FontFamily
> (rDescriptor
.nFamily
) );
630 aFont
.SetPitch ( static_cast < FontPitch
> (rDescriptor
.nPitch
) );
631 aFont
.SetWeight ( static_cast < FontWeight
> (rDescriptor
.nWeight
) );
632 aFont
.SetItalic ( static_cast < FontItalic
> (rDescriptor
.nItalic
) );
633 SmSym
aSymbol ( rDescriptor
.sName
, aFont
, static_cast < sal_Unicode
> (rDescriptor
.nCharacter
),
634 rDescriptor
.sSymbolSet
);
635 aSymbol
.SetExportName ( rDescriptor
.sExportName
);
636 rManager
.AddOrReplaceSymbol ( aSymbol
);
640 // #i33095# Security Options
641 case HANDLE_LOAD_READONLY
:
643 if ( (*pValues
).getValueType() != cppu::UnoType
<bool>::get() )
644 throw IllegalArgumentException();
645 bool bReadonly
= false;
646 if ( *pValues
>>= bReadonly
)
647 pDocSh
->SetLoadReadonly( bReadonly
);
650 case HANDLE_INTEROP_GRAB_BAG
:
651 setGrabBagItem(*pValues
);
653 case HANDLE_SAVE_THUMBNAIL
:
655 if ((*pValues
).getValueType() != cppu::UnoType
<bool>::get())
656 throw IllegalArgumentException();
657 bool bThumbnail
= false;
658 if (*pValues
>>= bThumbnail
)
659 pDocSh
->SetUseThumbnailSave(bThumbnail
);
662 case HANDLE_STARMATH_VERSION
:
663 pDocSh
->SetSmSyntaxVersion(pValues
->get
<sal_uInt16
>());
668 pDocSh
->SetFormat( aFormat
);
670 // #i67283# since about all of the above changes are likely to change
671 // the formula size we have to recalculate the vis-area now
672 pDocSh
->SetVisArea( tools::Rectangle( Point(0, 0), pDocSh
->GetSize() ) );
675 void SmModel::_getPropertyValues( const PropertyMapEntry
**ppEntries
, Any
*pValue
)
677 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
679 if ( nullptr == pDocSh
)
680 throw UnknownPropertyException();
682 const SmFormat
& aFormat
= pDocSh
->GetFormat();
684 for (; *ppEntries
; ppEntries
++, pValue
++ )
686 switch ( (*ppEntries
)->mnHandle
)
689 *pValue
<<= pDocSh
->GetText();
691 case HANDLE_FONT_NAME_VARIABLES
:
692 case HANDLE_FONT_NAME_FUNCTIONS
:
693 case HANDLE_FONT_NAME_NUMBERS
:
694 case HANDLE_FONT_NAME_TEXT
:
695 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
696 case HANDLE_CUSTOM_FONT_NAME_SANS
:
697 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
699 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
700 *pValue
<<= rFace
.GetFamilyName();
703 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
704 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
705 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
706 case HANDLE_FONT_VARIABLES_POSTURE
:
707 case HANDLE_FONT_FUNCTIONS_POSTURE
:
708 case HANDLE_FONT_NUMBERS_POSTURE
:
709 case HANDLE_FONT_TEXT_POSTURE
:
711 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
712 *pValue
<<= IsItalic( rFace
);
715 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
716 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
717 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
718 case HANDLE_FONT_VARIABLES_WEIGHT
:
719 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
720 case HANDLE_FONT_NUMBERS_WEIGHT
:
721 case HANDLE_FONT_TEXT_WEIGHT
:
723 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
724 *pValue
<<= IsBold( rFace
);
727 case HANDLE_BASE_FONT_HEIGHT
:
730 *pValue
<<= sal_Int16(o3tl::convert(aFormat
.GetBaseSize().Height(),
731 SmO3tlLengthUnit(), o3tl::Length::pt
));
734 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
735 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
736 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
737 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
738 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
739 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetRelSize((*ppEntries
)->mnMemberId
));
742 case HANDLE_IS_TEXT_MODE
:
743 *pValue
<<= aFormat
.IsTextmode();
746 case HANDLE_GREEK_CHAR_STYLE
:
747 *pValue
<<= aFormat
.GetGreekCharStyle();
750 case HANDLE_ALIGNMENT
:
751 // SmHorAlign uses the same values as HorizontalAlignment
752 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetHorAlign());
755 case HANDLE_RELATIVE_SPACING
:
756 case HANDLE_RELATIVE_LINE_SPACING
:
757 case HANDLE_RELATIVE_ROOT_SPACING
:
758 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
759 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
760 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
761 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
762 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
763 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
764 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
765 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
766 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
767 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
768 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
769 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
770 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
771 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
772 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
773 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
774 case HANDLE_RELATIVE_OPERATOR_SPACING
:
775 case HANDLE_LEFT_MARGIN
:
776 case HANDLE_RIGHT_MARGIN
:
777 case HANDLE_TOP_MARGIN
:
778 case HANDLE_BOTTOM_MARGIN
:
779 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetDistance((*ppEntries
)->mnMemberId
));
781 case HANDLE_IS_SCALE_ALL_BRACKETS
:
782 *pValue
<<= aFormat
.IsScaleNormalBrackets();
784 case HANDLE_PRINTER_NAME
:
786 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
787 *pValue
<<= pPrinter
? pPrinter
->GetName() : OUString();
790 case HANDLE_PRINTER_SETUP
:
792 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ();
795 SvMemoryStream aStream
;
796 pPrinter
->Store( aStream
);
797 sal_uInt32 nSize
= aStream
.TellEnd();
798 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
799 Sequence
< sal_Int8
> aSequence ( nSize
);
800 aStream
.ReadBytes(aSequence
.getArray(), nSize
);
801 *pValue
<<= aSequence
;
806 case HANDLE_USED_SYMBOLS
:
808 const bool bUsedSymbolsOnly
= (*ppEntries
)->mnHandle
== HANDLE_USED_SYMBOLS
;
809 const std::set
< OUString
> &rUsedSymbols
= pDocSh
->GetUsedSymbols();
812 SmModule
*pp
= SM_MOD();
813 const SmSymbolManager
&rManager
= pp
->GetSymbolManager();
814 std::vector
< const SmSym
* > aVector
;
816 const SymbolPtrVec_t
aSymbols( rManager
.GetSymbols() );
817 for (const SmSym
* pSymbol
: aSymbols
)
819 if (pSymbol
&& !pSymbol
->IsPredefined() &&
820 (!bUsedSymbolsOnly
||
821 rUsedSymbols
.find( pSymbol
->GetName() ) != rUsedSymbols
.end()))
822 aVector
.push_back ( pSymbol
);
824 Sequence
< SymbolDescriptor
> aSequence ( aVector
.size() );
825 SymbolDescriptor
* pDescriptor
= aSequence
.getArray();
827 for (const SmSym
* pSymbol
: aVector
)
829 pDescriptor
->sName
= pSymbol
->GetName();
830 pDescriptor
->sExportName
= pSymbol
->GetExportName();
831 pDescriptor
->sSymbolSet
= pSymbol
->GetSymbolSetName();
832 pDescriptor
->nCharacter
= static_cast < sal_Int32
> (pSymbol
->GetCharacter());
834 vcl::Font rFont
= pSymbol
->GetFace();
835 pDescriptor
->sFontName
= rFont
.GetFamilyName();
836 pDescriptor
->nCharSet
= sal::static_int_cast
< sal_Int16
>(rFont
.GetCharSet());
837 pDescriptor
->nFamily
= sal::static_int_cast
< sal_Int16
>(rFont
.GetFamilyType());
838 pDescriptor
->nPitch
= sal::static_int_cast
< sal_Int16
>(rFont
.GetPitch());
839 pDescriptor
->nWeight
= sal::static_int_cast
< sal_Int16
>(rFont
.GetWeight());
840 pDescriptor
->nItalic
= sal::static_int_cast
< sal_Int16
>(rFont
.GetItalic());
843 *pValue
<<= aSequence
;
846 case HANDLE_BASIC_LIBRARIES
:
847 *pValue
<<= pDocSh
->GetBasicContainer();
849 case HANDLE_DIALOG_LIBRARIES
:
850 *pValue
<<= pDocSh
->GetDialogContainer();
852 case HANDLE_RUNTIME_UID
:
853 *pValue
<<= getRuntimeUID();
855 // #i33095# Security Options
856 case HANDLE_LOAD_READONLY
:
858 *pValue
<<= pDocSh
->IsLoadReadonly();
862 case HANDLE_BASELINE
:
864 if ( !pDocSh
->GetFormulaTree() )
866 if ( pDocSh
->GetFormulaTree() )
868 pDocSh
->ArrangeFormula();
870 *pValue
<<= static_cast<sal_Int32
>( pDocSh
->GetFormulaTree()->GetFormulaBaseline() );
874 case HANDLE_INTEROP_GRAB_BAG
:
875 getGrabBagItem(*pValue
);
877 case HANDLE_SAVE_THUMBNAIL
:
879 *pValue
<<= pDocSh
->IsUseThumbnailSave();
882 case HANDLE_STARMATH_VERSION
:
883 *pValue
<<= pDocSh
->GetSmSyntaxVersion();
890 sal_Int32 SAL_CALL
SmModel::getRendererCount(
891 const uno::Any
& /*rSelection*/,
892 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
897 uno::Sequence
< beans::PropertyValue
> SAL_CALL
SmModel::getRenderer(
899 const uno::Any
& /*rSelection*/,
900 const uno::Sequence
< beans::PropertyValue
>& /*rxOptions*/ )
902 SolarMutexGuard aGuard
;
905 throw IllegalArgumentException();
907 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
909 throw RuntimeException();
911 SmPrinterAccess
aPrinterAccess( *pDocSh
);
913 if (Printer
*pPrinter
= aPrinterAccess
.GetPrinter())
914 aPrtPaperSize
= pPrinter
->GetPaperSize();
916 // if paper size is 0 (usually if no 'real' printer is found),
917 // guess the paper size
918 if (aPrtPaperSize
.IsEmpty())
919 aPrtPaperSize
= SvxPaperInfo::GetDefaultPaperSize(SmMapUnit());
920 awt::Size
aPageSize( aPrtPaperSize
.Width(), aPrtPaperSize
.Height() );
922 uno::Sequence
< beans::PropertyValue
> aRenderer(1);
923 PropertyValue
&rValue
= aRenderer
.getArray()[0];
924 rValue
.Name
= "PageSize";
925 rValue
.Value
<<= aPageSize
;
927 if (!m_pPrintUIOptions
)
928 m_pPrintUIOptions
.reset(new SmPrintUIOptions
);
929 m_pPrintUIOptions
->appendPrintUIOptions( aRenderer
);
934 void SAL_CALL
SmModel::render(
936 const uno::Any
& rSelection
,
937 const uno::Sequence
< beans::PropertyValue
>& rxOptions
)
939 SolarMutexGuard aGuard
;
942 throw IllegalArgumentException();
944 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
946 throw RuntimeException();
948 // get device to be rendered in
949 uno::Reference
< awt::XDevice
> xRenderDevice
;
950 for (const auto& rxOption
: rxOptions
)
952 if( rxOption
.Name
== "RenderDevice" )
953 rxOption
.Value
>>= xRenderDevice
;
956 if (!xRenderDevice
.is())
959 VCLXDevice
* pDevice
= dynamic_cast<VCLXDevice
*>( xRenderDevice
.get() );
960 VclPtr
< OutputDevice
> pOut
= pDevice
? pDevice
->GetOutputDevice()
961 : VclPtr
< OutputDevice
>();
963 throw RuntimeException();
965 pOut
->SetMapMode(MapMode(SmMapUnit()));
967 uno::Reference
< frame::XModel
> xModel
;
968 rSelection
>>= xModel
;
969 if (xModel
!= pDocSh
->GetModel())
972 //!! when called via API we may not have an active view
973 //!! thus we go and look for a view that can be used.
974 SfxViewShell
* pViewSh
= SfxViewShell::GetFirst( false /* search non-visible views as well*/, checkSfxViewShell
<SmViewShell
> );
975 while (pViewSh
&& pViewSh
->GetObjectShell() != pDocSh
)
976 pViewSh
= SfxViewShell::GetNext( *pViewSh
, false /* search non-visible views as well*/, checkSfxViewShell
<SmViewShell
> );
977 SmViewShell
*pView
= dynamic_cast< SmViewShell
*>( pViewSh
);
978 SAL_WARN_IF( !pView
, "starmath", "SmModel::render : no SmViewShell found" );
983 SmPrinterAccess
aPrinterAccess( *pDocSh
);
987 Point aPrtPageOffset
;
988 if (Printer
*pPrinter
= aPrinterAccess
.GetPrinter())
990 aPrtPaperSize
= pPrinter
->GetPaperSize();
991 aOutputSize
= pPrinter
->GetOutputSize();
992 aPrtPageOffset
= pPrinter
->GetPageOffset();
995 // no real printer ??
996 if (aPrtPaperSize
.IsEmpty())
998 aPrtPaperSize
= SvxPaperInfo::GetDefaultPaperSize(SmMapUnit());
999 // factors from Windows DIN A4
1000 aOutputSize
= Size( static_cast<tools::Long
>(aPrtPaperSize
.Width() * 0.941),
1001 static_cast<tools::Long
>(aPrtPaperSize
.Height() * 0.961));
1002 aPrtPageOffset
= Point( static_cast<tools::Long
>(aPrtPaperSize
.Width() * 0.0250),
1003 static_cast<tools::Long
>(aPrtPaperSize
.Height() * 0.0214));
1005 tools::Rectangle
OutputRect( Point(), aOutputSize
);
1008 // set minimum top and bottom border
1009 if (aPrtPageOffset
.Y() < 2000)
1010 OutputRect
.AdjustTop(2000 - aPrtPageOffset
.Y() );
1011 if ((aPrtPaperSize
.Height() - (aPrtPageOffset
.Y() + OutputRect
.Bottom())) < 2000)
1012 OutputRect
.AdjustBottom( -(2000 - (aPrtPaperSize
.Height() -
1013 (aPrtPageOffset
.Y() + OutputRect
.Bottom()))) );
1015 // set minimum left and right border
1016 if (aPrtPageOffset
.X() < 2500)
1017 OutputRect
.AdjustLeft(2500 - aPrtPageOffset
.X() );
1018 if ((aPrtPaperSize
.Width() - (aPrtPageOffset
.X() + OutputRect
.Right())) < 1500)
1019 OutputRect
.AdjustRight( -(1500 - (aPrtPaperSize
.Width() -
1020 (aPrtPageOffset
.X() + OutputRect
.Right()))) );
1022 if (!m_pPrintUIOptions
)
1023 m_pPrintUIOptions
.reset(new SmPrintUIOptions
);
1024 m_pPrintUIOptions
->processProperties( rxOptions
);
1026 pView
->Impl_Print( *pOut
, *m_pPrintUIOptions
, OutputRect
);
1028 // release SmPrintUIOptions when everything is done.
1029 // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
1030 if (m_pPrintUIOptions
->getBoolValue( "IsLastPage" ))
1032 m_pPrintUIOptions
.reset();
1036 void SAL_CALL
SmModel::setParent( const uno::Reference
< uno::XInterface
>& xParent
)
1038 SolarMutexGuard aGuard
;
1039 SfxBaseModel::setParent( xParent
);
1040 if (SfxObjectShell
* pDoc
= SfxObjectShell::GetShellFromComponent(xParent
))
1041 GetObjectShell()->OnDocumentPrinterChanged(pDoc
->GetDocumentPrinter());
1044 void SmModel::writeFormulaOoxml(
1045 ::sax_fastparser::FSHelperPtr
const pSerializer
,
1046 oox::core::OoxmlVersion
const version
,
1047 oox::drawingml::DocumentType
const documentType
, sal_Int8 nAlign
)
1049 static_cast<SmDocShell
*>(GetObjectShell())->writeFormulaOoxml(pSerializer
, version
, documentType
, nAlign
);
1052 void SmModel::writeFormulaRtf(OStringBuffer
& rBuffer
, rtl_TextEncoding nEncoding
)
1054 static_cast<SmDocShell
*>(GetObjectShell())->writeFormulaRtf(rBuffer
, nEncoding
);
1057 void SmModel::readFormulaOoxml( oox::formulaimport::XmlStream
& stream
)
1059 static_cast< SmDocShell
* >( GetObjectShell())->readFormulaOoxml( stream
);
1062 Size
SmModel::getFormulaSize() const
1064 return static_cast< SmDocShell
* >( GetObjectShell())->GetSize();
1067 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */