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 ::std
;
59 using namespace ::comphelper
;
60 using namespace ::com::sun::star
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::beans
;
63 using namespace ::com::sun::star::lang
;
64 using namespace ::com::sun::star::formula
;
65 using namespace ::com::sun::star::view
;
66 using namespace ::com::sun::star::script
;
68 SmPrintUIOptions::SmPrintUIOptions()
70 SmModule
*pp
= SM_MOD();
71 SmMathConfig
*pConfig
= pp
->GetConfig();
72 SAL_WARN_IF( !pConfig
, "starmath", "SmConfig not found" );
76 sal_Int32 nNumProps
= 10, nIdx
=0;
78 // create sequence of print UI options
79 // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
80 m_aUIProperties
.resize( nNumProps
);
82 // load the math PrinterOptions into the custom tab
83 m_aUIProperties
[nIdx
].Name
= "OptionsUIFile";
84 m_aUIProperties
[nIdx
++].Value
<<= OUString("modules/smath/ui/printeroptions.ui");
86 // create Section for formula (results in an extra tab page in dialog)
87 SvtModuleOptions aOpt
;
88 OUString
aAppGroupname(
89 SmResId( RID_PRINTUIOPT_PRODNAME
).
90 replaceFirst( "%s", aOpt
.GetModuleName( SvtModuleOptions::EModule::MATH
) ) );
91 m_aUIProperties
[nIdx
++].Value
= setGroupControlOpt("tabcontrol-page2", aAppGroupname
, ".HelpID:vcl:PrintDialog:TabPage:AppPage");
93 // create subgroup for print options
94 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("contents", SmResId( RID_PRINTUIOPT_CONTENTS
), OUString());
96 // create a bool option for title row (matches to SID_PRINTTITLE)
97 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("title", SmResId( RID_PRINTUIOPT_TITLE
),
98 ".HelpID:vcl:PrintDialog:TitleRow:CheckBox",
100 pConfig
->IsPrintTitle());
101 // create a bool option for formula text (matches to SID_PRINTTEXT)
102 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("formulatext", SmResId( RID_PRINTUIOPT_FRMLTXT
),
103 ".HelpID:vcl:PrintDialog:FormulaText:CheckBox",
104 PRTUIOPT_FORMULA_TEXT
,
105 pConfig
->IsPrintFormulaText());
106 // create a bool option for border (matches to SID_PRINTFRAME)
107 m_aUIProperties
[nIdx
++].Value
= setBoolControlOpt("borders", SmResId( RID_PRINTUIOPT_BORDERS
),
108 ".HelpID:vcl:PrintDialog:Border:CheckBox",
110 pConfig
->IsPrintFrame());
112 // create subgroup for print format
113 m_aUIProperties
[nIdx
++].Value
= setSubgroupControlOpt("size", SmResId( RID_PRINTUIOPT_SIZE
), OUString());
115 // create a radio button group for print format (matches to SID_PRINTSIZE)
116 Sequence
< OUString
> aChoices
{
117 SmResId( RID_PRINTUIOPT_ORIGSIZE
),
118 SmResId( RID_PRINTUIOPT_FITTOPAGE
),
119 SmResId( RID_PRINTUIOPT_SCALING
)
121 Sequence
< OUString
> aHelpIds
{
122 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0",
123 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1",
124 ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2"
126 Sequence
< OUString
> aWidgetIds
{
131 OUString
aPrintFormatProp( PRTUIOPT_PRINT_FORMAT
);
132 m_aUIProperties
[nIdx
++].Value
= setChoiceRadiosControlOpt(aWidgetIds
, OUString(),
135 aChoices
, static_cast< sal_Int32
>(pConfig
->GetPrintSize())
138 // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
139 vcl::PrinterOptionsHelper::UIControlOptions
aRangeOpt( aPrintFormatProp
, 2, true );
140 m_aUIProperties
[nIdx
++].Value
= setRangeControlOpt("scalingspin", OUString(),
141 ".HelpID:vcl:PrintDialog:PrintScale:NumericField",
142 PRTUIOPT_PRINT_SCALE
,
143 pConfig
->GetPrintZoomFactor(), // initial value
148 Sequence aHintNoLayoutPage
{ comphelper::makePropertyValue("HintNoLayoutPage", true) };
149 m_aUIProperties
[nIdx
++].Value
<<= aHintNoLayoutPage
;
151 assert(nIdx
== nNumProps
);
158 enum SmModelPropertyHandles
161 HANDLE_FONT_NAME_VARIABLES
,
162 HANDLE_FONT_NAME_FUNCTIONS
,
163 HANDLE_FONT_NAME_NUMBERS
,
164 HANDLE_FONT_NAME_TEXT
,
165 HANDLE_CUSTOM_FONT_NAME_SERIF
,
166 HANDLE_CUSTOM_FONT_NAME_SANS
,
167 HANDLE_CUSTOM_FONT_NAME_FIXED
,
168 HANDLE_CUSTOM_FONT_FIXED_POSTURE
,
169 HANDLE_CUSTOM_FONT_FIXED_WEIGHT
,
170 HANDLE_CUSTOM_FONT_SANS_POSTURE
,
171 HANDLE_CUSTOM_FONT_SANS_WEIGHT
,
172 HANDLE_CUSTOM_FONT_SERIF_POSTURE
,
173 HANDLE_CUSTOM_FONT_SERIF_WEIGHT
,
174 HANDLE_FONT_VARIABLES_POSTURE
,
175 HANDLE_FONT_VARIABLES_WEIGHT
,
176 HANDLE_FONT_FUNCTIONS_POSTURE
,
177 HANDLE_FONT_FUNCTIONS_WEIGHT
,
178 HANDLE_FONT_NUMBERS_POSTURE
,
179 HANDLE_FONT_NUMBERS_WEIGHT
,
180 HANDLE_FONT_TEXT_POSTURE
,
181 HANDLE_FONT_TEXT_WEIGHT
,
182 HANDLE_BASE_FONT_HEIGHT
,
183 HANDLE_RELATIVE_FONT_HEIGHT_TEXT
,
184 HANDLE_RELATIVE_FONT_HEIGHT_INDICES
,
185 HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
,
186 HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
,
187 HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
,
189 HANDLE_GREEK_CHAR_STYLE
,
191 HANDLE_RELATIVE_SPACING
,
192 HANDLE_RELATIVE_LINE_SPACING
,
193 HANDLE_RELATIVE_ROOT_SPACING
,
194 HANDLE_RELATIVE_INDEX_SUPERSCRIPT
,
195 HANDLE_RELATIVE_INDEX_SUBSCRIPT
,
196 HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
,
197 HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
,
198 HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
,
199 HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
,
200 HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
,
201 HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
,
202 HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
,
203 HANDLE_RELATIVE_BRACKET_DISTANCE
,
204 HANDLE_IS_SCALE_ALL_BRACKETS
,
205 HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
,
206 HANDLE_RELATIVE_MATRIX_LINE_SPACING
,
207 HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
,
208 HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
,
209 HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
,
210 HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
,
211 HANDLE_RELATIVE_OPERATOR_SPACING
,
215 HANDLE_BOTTOM_MARGIN
,
217 HANDLE_PRINTER_SETUP
,
219 HANDLE_SAVE_THUMBNAIL
,
221 HANDLE_BASIC_LIBRARIES
,
223 HANDLE_LOAD_READONLY
, // Security Options
224 HANDLE_DIALOG_LIBRARIES
, // #i73329#
226 HANDLE_INTEROP_GRAB_BAG
,
227 HANDLE_STARMATH_VERSION
232 static const rtl::Reference
<PropertySetInfo
> & lcl_createModelPropertyInfo ()
234 static const PropertyMapEntry aModelPropertyInfoMap
[] =
236 { OUString("Alignment") , HANDLE_ALIGNMENT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
237 { OUString("BaseFontHeight") , HANDLE_BASE_FONT_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
238 { OUString("BasicLibraries") , HANDLE_BASIC_LIBRARIES
, cppu::UnoType
<script::XLibraryContainer
>::get(), PropertyAttribute::READONLY
, 0 },
239 { OUString("BottomMargin") , HANDLE_BOTTOM_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BOTTOMSPACE
},
240 { OUString("CustomFontNameFixed") , HANDLE_CUSTOM_FONT_NAME_FIXED
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_FIXED
},
241 { OUString("CustomFontNameSans") , HANDLE_CUSTOM_FONT_NAME_SANS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_SANS
},
242 { OUString("CustomFontNameSerif") , HANDLE_CUSTOM_FONT_NAME_SERIF
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_SERIF
},
243 { OUString("DialogLibraries") , HANDLE_DIALOG_LIBRARIES
, cppu::UnoType
<script::XLibraryContainer
>::get(), PropertyAttribute::READONLY
, 0 },
244 { OUString("FontFixedIsBold") , HANDLE_CUSTOM_FONT_FIXED_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FIXED
},
245 { OUString("FontFixedIsItalic") , HANDLE_CUSTOM_FONT_FIXED_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FIXED
},
246 { OUString("FontFunctionsIsBold") , HANDLE_FONT_FUNCTIONS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
247 { OUString("FontFunctionsIsItalic") , HANDLE_FONT_FUNCTIONS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
248 { OUString("FontNameFunctions") , HANDLE_FONT_NAME_FUNCTIONS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_FUNCTION
},
249 { OUString("FontNameNumbers") , HANDLE_FONT_NAME_NUMBERS
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_NUMBER
},
250 { OUString("FontNameText") , HANDLE_FONT_NAME_TEXT
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_TEXT
},
251 { OUString("FontNameVariables") , HANDLE_FONT_NAME_VARIABLES
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
252 { OUString("FontNumbersIsBold") , HANDLE_FONT_NUMBERS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_NUMBER
},
253 { OUString("FontNumbersIsItalic") , HANDLE_FONT_NUMBERS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_NUMBER
},
254 { OUString("FontSansIsBold") , HANDLE_CUSTOM_FONT_SANS_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SANS
},
255 { OUString("FontSansIsItalic") , HANDLE_CUSTOM_FONT_SANS_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SANS
},
256 { OUString("FontSerifIsBold") , HANDLE_CUSTOM_FONT_SERIF_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SERIF
},
257 { OUString("FontSerifIsItalic") , HANDLE_CUSTOM_FONT_SERIF_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_SERIF
},
258 { OUString("FontTextIsBold") , HANDLE_FONT_TEXT_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_TEXT
},
259 { OUString("FontTextIsItalic") , HANDLE_FONT_TEXT_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_TEXT
},
260 { OUString("FontVariablesIsBold") , HANDLE_FONT_VARIABLES_WEIGHT
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
261 { OUString("FontVariablesIsItalic") , HANDLE_FONT_VARIABLES_POSTURE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, FNT_VARIABLE
},
262 { OUString("Formula") , HANDLE_FORMULA
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0 },
263 { OUString("IsScaleAllBrackets") , HANDLE_IS_SCALE_ALL_BRACKETS
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
264 { OUString("IsTextMode") , HANDLE_IS_TEXT_MODE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
265 { OUString("GreekCharStyle") , HANDLE_GREEK_CHAR_STYLE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
266 { OUString("LeftMargin") , HANDLE_LEFT_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_LEFTSPACE
},
267 { OUString("PrinterName") , HANDLE_PRINTER_NAME
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0 },
268 { OUString("PrinterSetup") , HANDLE_PRINTER_SETUP
, cppu::UnoType
<const Sequence
< sal_Int8
>>::get(), PROPERTY_NONE
, 0 },
269 { OUString("RelativeBracketDistance") , HANDLE_RELATIVE_BRACKET_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BRACKETSPACE
},
270 { OUString("RelativeBracketExcessSize") , HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_BRACKETSIZE
},
271 { OUString("RelativeFontHeightFunctions") , HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_FUNCTION
},
272 { OUString("RelativeFontHeightIndices") , HANDLE_RELATIVE_FONT_HEIGHT_INDICES
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_INDEX
},
273 { OUString("RelativeFontHeightLimits") , HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_LIMITS
},
274 { OUString("RelativeFontHeightOperators") , HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_OPERATOR
},
275 { OUString("RelativeFontHeightText") , HANDLE_RELATIVE_FONT_HEIGHT_TEXT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, SIZ_TEXT
},
276 { OUString("RelativeFractionBarExcessLength") , HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_FRACTION
},
277 { OUString("RelativeFractionBarLineWeight") , HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_STROKEWIDTH
},
278 { OUString("RelativeFractionDenominatorDepth") , HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_DENOMINATOR
},
279 { OUString("RelativeFractionNumeratorHeight") , HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_NUMERATOR
},
280 { OUString("RelativeIndexSubscript") , HANDLE_RELATIVE_INDEX_SUBSCRIPT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_SUBSCRIPT
},
281 { OUString("RelativeIndexSuperscript") , HANDLE_RELATIVE_INDEX_SUPERSCRIPT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_SUPERSCRIPT
},
282 { OUString("RelativeLineSpacing") , HANDLE_RELATIVE_LINE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_VERTICAL
},
283 { OUString("RelativeLowerLimitDistance") , HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_LOWERLIMIT
},
284 { OUString("RelativeMatrixColumnSpacing") , HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_MATRIXCOL
},
285 { OUString("RelativeMatrixLineSpacing") , HANDLE_RELATIVE_MATRIX_LINE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_MATRIXROW
},
286 { OUString("RelativeOperatorExcessSize") , HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_OPERATORSIZE
},
287 { OUString("RelativeOperatorSpacing") , HANDLE_RELATIVE_OPERATOR_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_OPERATORSPACE
},
288 { OUString("RelativeRootSpacing") , HANDLE_RELATIVE_ROOT_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ROOT
},
289 { OUString("RelativeScaleBracketExcessSize") , HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_NORMALBRACKETSIZE
},
290 { OUString("RelativeSpacing") , HANDLE_RELATIVE_SPACING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_HORIZONTAL
},
291 { OUString("RelativeSymbolMinimumHeight") , HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ORNAMENTSPACE
},
292 { OUString("RelativeSymbolPrimaryHeight") , HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_ORNAMENTSIZE
},
293 { OUString("RelativeUpperLimitDistance") , HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_UPPERLIMIT
},
294 { OUString("RightMargin") , HANDLE_RIGHT_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_RIGHTSPACE
},
295 { OUString("RuntimeUID") , HANDLE_RUNTIME_UID
, cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
, 0 },
296 { OUString("SaveThumbnail") , HANDLE_SAVE_THUMBNAIL
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
297 { OUString("Symbols") , HANDLE_SYMBOLS
, cppu::UnoType
<Sequence
< SymbolDescriptor
>>::get(), PROPERTY_NONE
, 0 },
298 { OUString("UserDefinedSymbolsInUse") , HANDLE_USED_SYMBOLS
, cppu::UnoType
<Sequence
< SymbolDescriptor
>>::get(), PropertyAttribute::READONLY
, 0 },
299 { OUString("TopMargin") , HANDLE_TOP_MARGIN
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, DIS_TOPSPACE
},
300 // #i33095# Security Options
301 { OUString("LoadReadonly") , HANDLE_LOAD_READONLY
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0 },
303 { OUString("BaseLine") , HANDLE_BASELINE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
304 { OUString("InteropGrabBag") , HANDLE_INTEROP_GRAB_BAG
, cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get(), PROPERTY_NONE
, 0 },
305 { OUString("SyntaxVersion") , HANDLE_STARMATH_VERSION
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0 },
307 static const rtl::Reference
<PropertySetInfo
> PROPS_INFO
= new PropertySetInfo ( aModelPropertyInfoMap
);
311 SmModel::SmModel( SfxObjectShell
*pObjSh
)
312 : SfxBaseModel(pObjSh
)
313 , PropertySetHelper ( lcl_createModelPropertyInfo () )
317 SmModel::~SmModel() noexcept
321 uno::Any SAL_CALL
SmModel::queryInterface( const uno::Type
& rType
)
323 uno::Any aRet
= ::cppu::queryInterface ( rType
,
324 // PropertySetHelper interfaces
325 static_cast< XPropertySet
* > ( this ),
326 static_cast< XMultiPropertySet
* > ( this ),
328 static_cast< XServiceInfo
* > ( this ),
329 static_cast< XRenderable
* > ( this ) );
330 if (!aRet
.hasValue())
331 aRet
= SfxBaseModel::queryInterface ( rType
);
335 void SAL_CALL
SmModel::acquire() noexcept
337 OWeakObject::acquire();
340 void SAL_CALL
SmModel::release() noexcept
342 OWeakObject::release();
345 uno::Sequence
< uno::Type
> SAL_CALL
SmModel::getTypes( )
347 return comphelper::concatSequences(SfxBaseModel::getTypes(),
349 cppu::UnoType
<XServiceInfo
>::get(),
350 cppu::UnoType
<XPropertySet
>::get(),
351 cppu::UnoType
<XMultiPropertySet
>::get(),
352 cppu::UnoType
<XRenderable
>::get() });
355 const uno::Sequence
< sal_Int8
> & SmModel::getUnoTunnelId()
357 static const comphelper::UnoIdInit theSmModelUnoTunnelId
;
358 return theSmModelUnoTunnelId
.getSeq();
361 sal_Int64 SAL_CALL
SmModel::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
363 return comphelper::getSomethingImpl(rId
, this,
364 comphelper::FallbackToGetSomethingOf
<SfxBaseModel
>{});
367 static sal_Int16
lcl_AnyToINT16(const uno::Any
& rAny
)
370 if( auto x
= o3tl::tryAccess
<double>(rAny
) )
371 nRet
= static_cast<sal_Int16
>(*x
);
377 OUString
SmModel::getImplementationName()
379 return "com.sun.star.comp.Math.FormulaDocument";
382 sal_Bool
SmModel::supportsService(const OUString
& rServiceName
)
384 return cppu::supportsService(this, rServiceName
);
387 uno::Sequence
< OUString
> SmModel::getSupportedServiceNames()
389 static constexpr OUStringLiteral service1
= u
"com.sun.star.document.OfficeDocument";
390 static constexpr OUStringLiteral service2
= u
"com.sun.star.formula.FormulaProperties";
391 return uno::Sequence
<OUString
>{ service1
, service2
};
394 void SmModel::_setPropertyValues(const PropertyMapEntry
** ppEntries
, const Any
* pValues
)
396 SolarMutexGuard aGuard
;
398 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
400 if ( nullptr == pDocSh
)
401 throw UnknownPropertyException();
403 SmFormat aFormat
= pDocSh
->GetFormat();
405 for (; *ppEntries
; ppEntries
++, pValues
++ )
407 if ((*ppEntries
)->mnAttributes
& PropertyAttribute::READONLY
)
408 throw PropertyVetoException();
410 switch ( (*ppEntries
)->mnHandle
)
416 pDocSh
->SetText(aText
);
419 case HANDLE_FONT_NAME_VARIABLES
:
420 case HANDLE_FONT_NAME_FUNCTIONS
:
421 case HANDLE_FONT_NAME_NUMBERS
:
422 case HANDLE_FONT_NAME_TEXT
:
423 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
424 case HANDLE_CUSTOM_FONT_NAME_SANS
:
425 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
428 *pValues
>>= sFontName
;
429 if(sFontName
.isEmpty())
430 throw IllegalArgumentException();
432 if(aFormat
.GetFont((*ppEntries
)->mnMemberId
).GetFamilyName() != sFontName
)
434 const SmFace rOld
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
436 SmFace
aSet( sFontName
, rOld
.GetFontSize() );
437 aSet
.SetBorderWidth( rOld
.GetBorderWidth() );
438 aSet
.SetAlignment( ALIGN_BASELINE
);
439 aFormat
.SetFont( (*ppEntries
)->mnMemberId
, aSet
);
443 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
444 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
445 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
446 case HANDLE_FONT_VARIABLES_POSTURE
:
447 case HANDLE_FONT_FUNCTIONS_POSTURE
:
448 case HANDLE_FONT_NUMBERS_POSTURE
:
449 case HANDLE_FONT_TEXT_POSTURE
:
451 auto bVal
= o3tl::tryAccess
<bool>(*pValues
);
453 throw IllegalArgumentException();
454 vcl::Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
455 aNewFont
.SetItalic(*bVal
? ITALIC_NORMAL
: ITALIC_NONE
);
456 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
459 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
460 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
461 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
462 case HANDLE_FONT_VARIABLES_WEIGHT
:
463 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
464 case HANDLE_FONT_NUMBERS_WEIGHT
:
465 case HANDLE_FONT_TEXT_WEIGHT
:
467 auto bVal
= o3tl::tryAccess
<bool>(*pValues
);
469 throw IllegalArgumentException();
470 vcl::Font
aNewFont(aFormat
.GetFont((*ppEntries
)->mnMemberId
));
471 aNewFont
.SetWeight(*bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
);
472 aFormat
.SetFont((*ppEntries
)->mnMemberId
, aNewFont
);
475 case HANDLE_BASE_FONT_HEIGHT
:
478 sal_Int16 nVal
= lcl_AnyToINT16(*pValues
);
480 throw IllegalArgumentException();
481 Size aSize
= aFormat
.GetBaseSize();
482 aSize
.setHeight(o3tl::convert(nVal
, o3tl::Length::pt
, SmO3tlLengthUnit()));
483 aFormat
.SetBaseSize(aSize
);
485 // apply base size to fonts
486 const Size
aTmp( aFormat
.GetBaseSize() );
487 for (sal_uInt16 i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
488 aFormat
.SetFontSize(i
, aTmp
);
491 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
492 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
493 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
494 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
495 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
500 throw IllegalArgumentException();
501 aFormat
.SetRelSize((*ppEntries
)->mnMemberId
, nVal
);
505 case HANDLE_IS_TEXT_MODE
:
507 aFormat
.SetTextmode(*o3tl::doAccess
<bool>(*pValues
));
511 case HANDLE_GREEK_CHAR_STYLE
:
515 if (nVal
< 0 || nVal
> 2)
516 throw IllegalArgumentException();
517 aFormat
.SetGreekCharStyle( nVal
);
521 case HANDLE_ALIGNMENT
:
523 // SmHorAlign uses the same values as HorizontalAlignment
526 if(nVal
< 0 || nVal
> 2)
527 throw IllegalArgumentException();
528 aFormat
.SetHorAlign(static_cast<SmHorAlign
>(nVal
));
532 case HANDLE_RELATIVE_SPACING
:
533 case HANDLE_RELATIVE_LINE_SPACING
:
534 case HANDLE_RELATIVE_ROOT_SPACING
:
535 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
536 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
537 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
538 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
539 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
540 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
541 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
542 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
543 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
544 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
545 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
546 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
547 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
548 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
549 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
550 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
551 case HANDLE_RELATIVE_OPERATOR_SPACING
:
552 case HANDLE_LEFT_MARGIN
:
553 case HANDLE_RIGHT_MARGIN
:
554 case HANDLE_TOP_MARGIN
:
555 case HANDLE_BOTTOM_MARGIN
:
560 throw IllegalArgumentException();
561 aFormat
.SetDistance((*ppEntries
)->mnMemberId
, nVal
);
564 case HANDLE_IS_SCALE_ALL_BRACKETS
:
565 aFormat
.SetScaleNormalBrackets(*o3tl::doAccess
<bool>(*pValues
));
567 case HANDLE_PRINTER_NAME
:
569 // embedded documents just ignore this property for now
570 if ( pDocSh
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
)
572 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
575 OUString sPrinterName
;
576 if ( !(*pValues
>>= sPrinterName
) )
577 throw IllegalArgumentException();
579 if ( !sPrinterName
.isEmpty() )
581 VclPtrInstance
<SfxPrinter
> pNewPrinter( pPrinter
->GetOptions().Clone(), sPrinterName
);
582 if (pNewPrinter
->IsKnown())
583 pDocSh
->SetPrinter ( pNewPrinter
);
585 pNewPrinter
.disposeAndClear();
591 case HANDLE_PRINTER_SETUP
:
593 Sequence
< sal_Int8
> aSequence
;
594 if ( !(*pValues
>>= aSequence
) )
595 throw IllegalArgumentException();
597 sal_uInt32 nSize
= aSequence
.getLength();
598 SvMemoryStream
aStream ( aSequence
.getArray(), nSize
, StreamMode::READ
);
599 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
600 auto pItemSet
= std::make_unique
<SfxItemSetFixed
<
601 SID_PRINTTITLE
, SID_PRINTTITLE
,
602 SID_PRINTTEXT
, SID_PRINTTEXT
,
603 SID_PRINTFRAME
, SID_PRINTFRAME
,
604 SID_PRINTSIZE
, SID_PRINTSIZE
,
605 SID_PRINTZOOM
, SID_PRINTZOOM
,
606 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
607 SID_SAVE_ONLY_USED_SYMBOLS
, SID_SAVE_ONLY_USED_SYMBOLS
,
608 SID_AUTO_CLOSE_BRACKETS
, SID_SMEDITWINDOWZOOM
>> ( SmDocShell::GetPool() );
609 SmModule
*pp
= SM_MOD();
610 pp
->GetConfig()->ConfigToItemSet(*pItemSet
);
611 VclPtr
<SfxPrinter
> pPrinter
= SfxPrinter::Create ( aStream
, std::move(pItemSet
) );
613 pDocSh
->SetPrinter( pPrinter
);
619 Sequence
< SymbolDescriptor
> aSequence
;
620 if ( !(*pValues
>>= aSequence
) )
621 throw IllegalArgumentException();
623 SmModule
*pp
= SM_MOD();
624 SmSymbolManager
&rManager
= pp
->GetSymbolManager();
625 for (const SymbolDescriptor
& rDescriptor
: std::as_const(aSequence
))
628 aFont
.SetFamilyName ( rDescriptor
.sFontName
);
629 aFont
.SetCharSet ( static_cast < rtl_TextEncoding
> (rDescriptor
.nCharSet
) );
630 aFont
.SetFamily ( static_cast < FontFamily
> (rDescriptor
.nFamily
) );
631 aFont
.SetPitch ( static_cast < FontPitch
> (rDescriptor
.nPitch
) );
632 aFont
.SetWeight ( static_cast < FontWeight
> (rDescriptor
.nWeight
) );
633 aFont
.SetItalic ( static_cast < FontItalic
> (rDescriptor
.nItalic
) );
634 SmSym
aSymbol ( rDescriptor
.sName
, aFont
, static_cast < sal_Unicode
> (rDescriptor
.nCharacter
),
635 rDescriptor
.sSymbolSet
);
636 aSymbol
.SetExportName ( rDescriptor
.sExportName
);
637 rManager
.AddOrReplaceSymbol ( aSymbol
);
641 // #i33095# Security Options
642 case HANDLE_LOAD_READONLY
:
644 if ( (*pValues
).getValueType() != cppu::UnoType
<bool>::get() )
645 throw IllegalArgumentException();
646 bool bReadonly
= false;
647 if ( *pValues
>>= bReadonly
)
648 pDocSh
->SetLoadReadonly( bReadonly
);
651 case HANDLE_INTEROP_GRAB_BAG
:
652 setGrabBagItem(*pValues
);
654 case HANDLE_SAVE_THUMBNAIL
:
656 if ((*pValues
).getValueType() != cppu::UnoType
<bool>::get())
657 throw IllegalArgumentException();
658 bool bThumbnail
= false;
659 if (*pValues
>>= bThumbnail
)
660 pDocSh
->SetUseThumbnailSave(bThumbnail
);
663 case HANDLE_STARMATH_VERSION
:
664 pDocSh
->SetSmSyntaxVersion(pValues
->get
<sal_uInt16
>());
669 pDocSh
->SetFormat( aFormat
);
671 // #i67283# since about all of the above changes are likely to change
672 // the formula size we have to recalculate the vis-area now
673 pDocSh
->SetVisArea( tools::Rectangle( Point(0, 0), pDocSh
->GetSize() ) );
676 void SmModel::_getPropertyValues( const PropertyMapEntry
**ppEntries
, Any
*pValue
)
678 SmDocShell
*pDocSh
= static_cast < SmDocShell
* > (GetObjectShell());
680 if ( nullptr == pDocSh
)
681 throw UnknownPropertyException();
683 const SmFormat
& aFormat
= pDocSh
->GetFormat();
685 for (; *ppEntries
; ppEntries
++, pValue
++ )
687 switch ( (*ppEntries
)->mnHandle
)
690 *pValue
<<= pDocSh
->GetText();
692 case HANDLE_FONT_NAME_VARIABLES
:
693 case HANDLE_FONT_NAME_FUNCTIONS
:
694 case HANDLE_FONT_NAME_NUMBERS
:
695 case HANDLE_FONT_NAME_TEXT
:
696 case HANDLE_CUSTOM_FONT_NAME_SERIF
:
697 case HANDLE_CUSTOM_FONT_NAME_SANS
:
698 case HANDLE_CUSTOM_FONT_NAME_FIXED
:
700 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
701 *pValue
<<= rFace
.GetFamilyName();
704 case HANDLE_CUSTOM_FONT_FIXED_POSTURE
:
705 case HANDLE_CUSTOM_FONT_SANS_POSTURE
:
706 case HANDLE_CUSTOM_FONT_SERIF_POSTURE
:
707 case HANDLE_FONT_VARIABLES_POSTURE
:
708 case HANDLE_FONT_FUNCTIONS_POSTURE
:
709 case HANDLE_FONT_NUMBERS_POSTURE
:
710 case HANDLE_FONT_TEXT_POSTURE
:
712 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
713 *pValue
<<= IsItalic( rFace
);
716 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT
:
717 case HANDLE_CUSTOM_FONT_SANS_WEIGHT
:
718 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT
:
719 case HANDLE_FONT_VARIABLES_WEIGHT
:
720 case HANDLE_FONT_FUNCTIONS_WEIGHT
:
721 case HANDLE_FONT_NUMBERS_WEIGHT
:
722 case HANDLE_FONT_TEXT_WEIGHT
:
724 const SmFace
& rFace
= aFormat
.GetFont((*ppEntries
)->mnMemberId
);
725 *pValue
<<= IsBold( rFace
);
728 case HANDLE_BASE_FONT_HEIGHT
:
731 *pValue
<<= sal_Int16(o3tl::convert(aFormat
.GetBaseSize().Height(),
732 SmO3tlLengthUnit(), o3tl::Length::pt
));
735 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT
:
736 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES
:
737 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS
:
738 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS
:
739 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS
:
740 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetRelSize((*ppEntries
)->mnMemberId
));
743 case HANDLE_IS_TEXT_MODE
:
744 *pValue
<<= aFormat
.IsTextmode();
747 case HANDLE_GREEK_CHAR_STYLE
:
748 *pValue
<<= aFormat
.GetGreekCharStyle();
751 case HANDLE_ALIGNMENT
:
752 // SmHorAlign uses the same values as HorizontalAlignment
753 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetHorAlign());
756 case HANDLE_RELATIVE_SPACING
:
757 case HANDLE_RELATIVE_LINE_SPACING
:
758 case HANDLE_RELATIVE_ROOT_SPACING
:
759 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT
:
760 case HANDLE_RELATIVE_INDEX_SUBSCRIPT
:
761 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT
:
762 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH
:
763 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH
:
764 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT
:
765 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE
:
766 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE
:
767 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE
:
768 case HANDLE_RELATIVE_BRACKET_DISTANCE
:
769 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE
:
770 case HANDLE_RELATIVE_MATRIX_LINE_SPACING
:
771 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING
:
772 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT
:
773 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT
:
774 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE
:
775 case HANDLE_RELATIVE_OPERATOR_SPACING
:
776 case HANDLE_LEFT_MARGIN
:
777 case HANDLE_RIGHT_MARGIN
:
778 case HANDLE_TOP_MARGIN
:
779 case HANDLE_BOTTOM_MARGIN
:
780 *pValue
<<= static_cast<sal_Int16
>(aFormat
.GetDistance((*ppEntries
)->mnMemberId
));
782 case HANDLE_IS_SCALE_ALL_BRACKETS
:
783 *pValue
<<= aFormat
.IsScaleNormalBrackets();
785 case HANDLE_PRINTER_NAME
:
787 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ( );
788 *pValue
<<= pPrinter
? pPrinter
->GetName() : OUString();
791 case HANDLE_PRINTER_SETUP
:
793 SfxPrinter
*pPrinter
= pDocSh
->GetPrinter ();
796 SvMemoryStream aStream
;
797 pPrinter
->Store( aStream
);
798 sal_uInt32 nSize
= aStream
.TellEnd();
799 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
800 Sequence
< sal_Int8
> aSequence ( nSize
);
801 aStream
.ReadBytes(aSequence
.getArray(), nSize
);
802 *pValue
<<= aSequence
;
807 case HANDLE_USED_SYMBOLS
:
809 const bool bUsedSymbolsOnly
= (*ppEntries
)->mnHandle
== HANDLE_USED_SYMBOLS
;
810 const std::set
< OUString
> &rUsedSymbols
= pDocSh
->GetUsedSymbols();
813 SmModule
*pp
= SM_MOD();
814 const SmSymbolManager
&rManager
= pp
->GetSymbolManager();
815 vector
< const SmSym
* > aVector
;
817 const SymbolPtrVec_t
aSymbols( rManager
.GetSymbols() );
818 for (const SmSym
* pSymbol
: aSymbols
)
820 if (pSymbol
&& !pSymbol
->IsPredefined() &&
821 (!bUsedSymbolsOnly
||
822 rUsedSymbols
.find( pSymbol
->GetName() ) != rUsedSymbols
.end()))
823 aVector
.push_back ( pSymbol
);
825 Sequence
< SymbolDescriptor
> aSequence ( aVector
.size() );
826 SymbolDescriptor
* pDescriptor
= aSequence
.getArray();
828 for (const SmSym
* pSymbol
: aVector
)
830 pDescriptor
->sName
= pSymbol
->GetName();
831 pDescriptor
->sExportName
= pSymbol
->GetExportName();
832 pDescriptor
->sSymbolSet
= pSymbol
->GetSymbolSetName();
833 pDescriptor
->nCharacter
= static_cast < sal_Int32
> (pSymbol
->GetCharacter());
835 vcl::Font rFont
= pSymbol
->GetFace();
836 pDescriptor
->sFontName
= rFont
.GetFamilyName();
837 pDescriptor
->nCharSet
= sal::static_int_cast
< sal_Int16
>(rFont
.GetCharSet());
838 pDescriptor
->nFamily
= sal::static_int_cast
< sal_Int16
>(rFont
.GetFamilyType());
839 pDescriptor
->nPitch
= sal::static_int_cast
< sal_Int16
>(rFont
.GetPitch());
840 pDescriptor
->nWeight
= sal::static_int_cast
< sal_Int16
>(rFont
.GetWeight());
841 pDescriptor
->nItalic
= sal::static_int_cast
< sal_Int16
>(rFont
.GetItalic());
844 *pValue
<<= aSequence
;
847 case HANDLE_BASIC_LIBRARIES
:
848 *pValue
<<= pDocSh
->GetBasicContainer();
850 case HANDLE_DIALOG_LIBRARIES
:
851 *pValue
<<= pDocSh
->GetDialogContainer();
853 case HANDLE_RUNTIME_UID
:
854 *pValue
<<= getRuntimeUID();
856 // #i33095# Security Options
857 case HANDLE_LOAD_READONLY
:
859 *pValue
<<= pDocSh
->IsLoadReadonly();
863 case HANDLE_BASELINE
:
865 if ( !pDocSh
->GetFormulaTree() )
867 if ( pDocSh
->GetFormulaTree() )
869 pDocSh
->ArrangeFormula();
871 *pValue
<<= static_cast<sal_Int32
>( pDocSh
->GetFormulaTree()->GetFormulaBaseline() );
875 case HANDLE_INTEROP_GRAB_BAG
:
876 getGrabBagItem(*pValue
);
878 case HANDLE_SAVE_THUMBNAIL
:
880 *pValue
<<= pDocSh
->IsUseThumbnailSave();
883 case HANDLE_STARMATH_VERSION
:
884 *pValue
<<= pDocSh
->GetSmSyntaxVersion();
891 sal_Int32 SAL_CALL
SmModel::getRendererCount(
892 const uno::Any
& /*rSelection*/,
893 const uno::Sequence
< beans::PropertyValue
>& /*xOptions*/ )
898 uno::Sequence
< beans::PropertyValue
> SAL_CALL
SmModel::getRenderer(
900 const uno::Any
& /*rSelection*/,
901 const uno::Sequence
< beans::PropertyValue
>& /*rxOptions*/ )
903 SolarMutexGuard aGuard
;
906 throw IllegalArgumentException();
908 SmDocShell
*pDocSh
= static_cast < SmDocShell
* >( GetObjectShell() );
910 throw RuntimeException();
912 SmPrinterAccess
aPrinterAccess( *pDocSh
);
913 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
914 Size
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
= comphelper::getFromUnoTunnel
<VCLXDevice
>( xRenderDevice
);
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
);
984 Printer
*pPrinter
= aPrinterAccess
.GetPrinter();
986 Size
aPrtPaperSize ( pPrinter
->GetPaperSize() );
987 Size
aOutputSize ( pPrinter
->GetOutputSize() );
988 Point
aPrtPageOffset( pPrinter
->GetPageOffset() );
990 // no real printer ??
991 if (aPrtPaperSize
.IsEmpty())
993 aPrtPaperSize
= SvxPaperInfo::GetDefaultPaperSize(SmMapUnit());
994 // factors from Windows DIN A4
995 aOutputSize
= Size( static_cast<tools::Long
>(aPrtPaperSize
.Width() * 0.941),
996 static_cast<tools::Long
>(aPrtPaperSize
.Height() * 0.961));
997 aPrtPageOffset
= Point( static_cast<tools::Long
>(aPrtPaperSize
.Width() * 0.0250),
998 static_cast<tools::Long
>(aPrtPaperSize
.Height() * 0.0214));
1000 tools::Rectangle
OutputRect( Point(), aOutputSize
);
1003 // set minimum top and bottom border
1004 if (aPrtPageOffset
.Y() < 2000)
1005 OutputRect
.AdjustTop(2000 - aPrtPageOffset
.Y() );
1006 if ((aPrtPaperSize
.Height() - (aPrtPageOffset
.Y() + OutputRect
.Bottom())) < 2000)
1007 OutputRect
.AdjustBottom( -(2000 - (aPrtPaperSize
.Height() -
1008 (aPrtPageOffset
.Y() + OutputRect
.Bottom()))) );
1010 // set minimum left and right border
1011 if (aPrtPageOffset
.X() < 2500)
1012 OutputRect
.AdjustLeft(2500 - aPrtPageOffset
.X() );
1013 if ((aPrtPaperSize
.Width() - (aPrtPageOffset
.X() + OutputRect
.Right())) < 1500)
1014 OutputRect
.AdjustRight( -(1500 - (aPrtPaperSize
.Width() -
1015 (aPrtPageOffset
.X() + OutputRect
.Right()))) );
1017 if (!m_pPrintUIOptions
)
1018 m_pPrintUIOptions
.reset(new SmPrintUIOptions
);
1019 m_pPrintUIOptions
->processProperties( rxOptions
);
1021 pView
->Impl_Print( *pOut
, *m_pPrintUIOptions
, OutputRect
);
1023 // release SmPrintUIOptions when everything is done.
1024 // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
1025 if (m_pPrintUIOptions
->getBoolValue( "IsLastPage" ))
1027 m_pPrintUIOptions
.reset();
1031 void SAL_CALL
SmModel::setParent( const uno::Reference
< uno::XInterface
>& xParent
)
1033 SolarMutexGuard aGuard
;
1034 SfxBaseModel::setParent( xParent
);
1035 if (SfxObjectShell
* pDoc
= SfxObjectShell::GetShellFromComponent(xParent
))
1036 GetObjectShell()->OnDocumentPrinterChanged(pDoc
->GetDocumentPrinter());
1039 void SmModel::writeFormulaOoxml(
1040 ::sax_fastparser::FSHelperPtr
const pSerializer
,
1041 oox::core::OoxmlVersion
const version
,
1042 oox::drawingml::DocumentType
const documentType
, sal_Int8 nAlign
)
1044 static_cast<SmDocShell
*>(GetObjectShell())->writeFormulaOoxml(pSerializer
, version
, documentType
, nAlign
);
1047 void SmModel::writeFormulaRtf(OStringBuffer
& rBuffer
, rtl_TextEncoding nEncoding
)
1049 static_cast<SmDocShell
*>(GetObjectShell())->writeFormulaRtf(rBuffer
, nEncoding
);
1052 void SmModel::readFormulaOoxml( oox::formulaimport::XmlStream
& stream
)
1054 static_cast< SmDocShell
* >( GetObjectShell())->readFormulaOoxml( stream
);
1057 Size
SmModel::getFormulaSize() const
1059 return static_cast< SmDocShell
* >( GetObjectShell())->GetSize();
1062 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */