xref: /aoo4110/main/starmath/source/unomodel.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_starmath.hxx"
26 
27 
28 #include <vos/mutex.hxx>
29 #include <osl/mutex.hxx>
30 #include <sfx2/printer.hxx>
31 #include <vcl/svapp.hxx>
32 #include <svtools/ctrltool.hxx>
33 #include <svl/itemprop.hxx>
34 #include <unotools/localedatawrapper.hxx>
35 #include <unotools/processfactory.hxx>
36 #include <editeng/paperinf.hxx>
37 #include <vcl/settings.hxx>
38 #include <vcl/print.hxx>
39 #include <toolkit/awt/vclxdevice.hxx>
40 #include <com/sun/star/beans/PropertyState.hpp>
41 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <com/sun/star/formula/SymbolDescriptor.hpp>
43 #include <com/sun/star/awt/Size.hpp>
44 #include <com/sun/star/script/XLibraryContainer.hpp>
45 #include <xmloff/xmluconv.hxx>
46 #include <rtl/ustrbuf.hxx>
47 #include <comphelper/propertysetinfo.hxx>
48 #include <unotools/moduleoptions.hxx>
49 
50 #include <unomodel.hxx>
51 #include <document.hxx>
52 #include <view.hxx>
53 #include <symbol.hxx>
54 #include <starmath.hrc>
55 #include <config.hxx>
56 #include <smdll.hxx>
57 
58 using namespace ::vos;
59 using namespace ::rtl;
60 using namespace ::cppu;
61 using namespace ::std;
62 using namespace ::comphelper;
63 using namespace ::com::sun::star;
64 using namespace ::com::sun::star::uno;
65 using namespace ::com::sun::star::beans;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::formula;
68 using namespace ::com::sun::star::view;
69 using namespace ::com::sun::star::script;
70 
71 
72 #define TWIP_TO_MM100(TWIP) 	((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
73 #define MM100_TO_TWIP(MM100)	((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
74 
75 ////////////////////////////////////////////////////////////
76 
SmPrintUIOptions()77 SmPrintUIOptions::SmPrintUIOptions()
78 {
79     ResStringArray      aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS ) );
80     DBG_ASSERT( aLocalizedStrings.Count() >= 9, "resource incomplete" );
81     if( aLocalizedStrings.Count() < 9 ) // bad resource ?
82         return;
83 
84     SmModule *pp = SM_MOD();
85     SmConfig *pConfig = pp->GetConfig();
86     DBG_ASSERT( pConfig, "SmConfig not found" );
87     if (!pConfig)
88         return;
89 
90     // create sequence of print UI options
91     // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
92     m_aUIProperties.realloc( 9 );
93 
94     // create Section for formula (results in an extra tab page in dialog)
95     SvtModuleOptions aOpt;
96     String aAppGroupname( aLocalizedStrings.GetString( 0 ) );
97     aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
98                                     aOpt.GetModuleName( SvtModuleOptions::E_SMATH ) );
99     m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TabPage:AppPage" ) ) );
100 
101     // create subgroup for print options
102     m_aUIProperties[1].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() );
103 
104     // create a bool option for title row (matches to SID_PRINTTITLE)
105     m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ),
106                                                   rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TitleRow:CheckBox" ) ),
107                                                   rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_TITLE_ROW ) ),
108                                                   pConfig->IsPrintTitle() );
109     // create a bool option for formula text (matches to SID_PRINTTEXT)
110     m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ),
111                                                   rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:FormulaText:CheckBox" ) ),
112                                                   rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_FORMULA_TEXT ) ),
113                                                   pConfig->IsPrintFormulaText() );
114     // create a bool option for border (matches to SID_PRINTFRAME)
115     m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ),
116                                                   rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:Border:CheckBox" ) ),
117                                                   rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_BORDER ) ),
118                                                   pConfig->IsPrintFrame() );
119 
120     // create subgroup for print format
121     m_aUIProperties[5].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 5 ), rtl::OUString() );
122 
123     // create a radio button group for print format (matches to SID_PRINTSIZE)
124     Sequence< rtl::OUString > aChoices( 3 );
125     aChoices[0] = aLocalizedStrings.GetString( 6 );
126     aChoices[1] = aLocalizedStrings.GetString( 7 );
127     aChoices[2] = aLocalizedStrings.GetString( 8 );
128     Sequence< rtl::OUString > aHelpIds( 3 );
129     aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0" ) );
130     aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1" ) );
131     aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2" ) );
132     OUString aPrintFormatProp( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_FORMAT ) );
133     m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(),
134                                                     aHelpIds,
135                                                     aPrintFormatProp,
136                                                     aChoices, static_cast< sal_Int32 >(pConfig->GetPrintSize())
137                                                     );
138 
139     // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
140     vcl::PrinterOptionsHelper::UIControlOptions aRangeOpt( aPrintFormatProp, 2, sal_True );
141     m_aUIProperties[ 7 ].Value = getRangeControlOpt( rtl::OUString(),
142                                                      rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintScale:NumericField" ) ),
143                                                      rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_SCALE ) ),
144                                                      pConfig->GetPrintZoomFactor(),    // initial value
145                                                      10,     // min value
146                                                      1000,   // max value
147                                                      aRangeOpt );
148 
149     Sequence< PropertyValue > aHintNoLayoutPage( 1 );
150     aHintNoLayoutPage[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HintNoLayoutPage" ) );
151     aHintNoLayoutPage[0].Value = makeAny( sal_True );
152     m_aUIProperties[8].Value <<= aHintNoLayoutPage;
153 
154 // IsIgnoreSpacesRight is a parser option! Thus we don't add it to the printer UI.
155 //
156 //    // create subgroup for misc options
157 //    m_aUIProperties[8].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 9 ) );
158 //
159 //    // create a bool option for ignore spacing (matches to SID_NO_RIGHT_SPACES)
160 //    m_aUIProperties[9].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ),
161 //                                                  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_NO_RIGHT_SPACE ) ),
162 //                                                  pConfig->IsIgnoreSpacesRight() );
163 }
164 
165 
166 ////////////////////////////////////////////////////////////
167 //
168 // class SmModel
169 //
170 
171 // values from com/sun/star/beans/PropertyAttribute
172 #define PROPERTY_NONE        0
173 #define PROPERTY_READONLY   16
174 
175 enum SmModelPropertyHandles
176 {
177 	HANDLE_FORMULA,
178 	HANDLE_FONT_NAME_VARIABLES,
179 	HANDLE_FONT_NAME_FUNCTIONS,
180 	HANDLE_FONT_NAME_NUMBERS,
181 	HANDLE_FONT_NAME_TEXT,
182 	HANDLE_CUSTOM_FONT_NAME_SERIF,
183 	HANDLE_CUSTOM_FONT_NAME_SANS,
184 	HANDLE_CUSTOM_FONT_NAME_FIXED,
185 	HANDLE_CUSTOM_FONT_FIXED_POSTURE,
186 	HANDLE_CUSTOM_FONT_FIXED_WEIGHT,
187 	HANDLE_CUSTOM_FONT_SANS_POSTURE,
188 	HANDLE_CUSTOM_FONT_SANS_WEIGHT,
189 	HANDLE_CUSTOM_FONT_SERIF_POSTURE,
190 	HANDLE_CUSTOM_FONT_SERIF_WEIGHT,
191 	HANDLE_FONT_VARIABLES_POSTURE,
192 	HANDLE_FONT_VARIABLES_WEIGHT,
193 	HANDLE_FONT_FUNCTIONS_POSTURE,
194 	HANDLE_FONT_FUNCTIONS_WEIGHT,
195 	HANDLE_FONT_NUMBERS_POSTURE,
196 	HANDLE_FONT_NUMBERS_WEIGHT,
197 	HANDLE_FONT_TEXT_POSTURE,
198 	HANDLE_FONT_TEXT_WEIGHT,
199 	HANDLE_BASE_FONT_HEIGHT,
200 	HANDLE_RELATIVE_FONT_HEIGHT_TEXT,
201 	HANDLE_RELATIVE_FONT_HEIGHT_INDICES,
202 	HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS,
203 	HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS,
204 	HANDLE_RELATIVE_FONT_HEIGHT_LIMITS,
205 	HANDLE_IS_TEXT_MODE,
206     HANDLE_GREEK_CHAR_STYLE,
207 	HANDLE_ALIGNMENT,
208 	HANDLE_RELATIVE_SPACING,
209 	HANDLE_RELATIVE_LINE_SPACING,
210 	HANDLE_RELATIVE_ROOT_SPACING,
211 	HANDLE_RELATIVE_INDEX_SUPERSCRIPT,
212 	HANDLE_RELATIVE_INDEX_SUBSCRIPT,
213 	HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT,
214 	HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH,
215 	HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH,
216 	HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT,
217 	HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE,
218 	HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE,
219 	HANDLE_RELATIVE_BRACKET_EXCESS_SIZE,
220 	HANDLE_RELATIVE_BRACKET_DISTANCE,
221 	HANDLE_IS_SCALE_ALL_BRACKETS,
222 	HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE,
223 	HANDLE_RELATIVE_MATRIX_LINE_SPACING,
224 	HANDLE_RELATIVE_MATRIX_COLUMN_SPACING,
225 	HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT,
226 	HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT,
227 	HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE,
228 	HANDLE_RELATIVE_OPERATOR_SPACING,
229 	HANDLE_LEFT_MARGIN,
230 	HANDLE_RIGHT_MARGIN,
231 	HANDLE_TOP_MARGIN,
232 	HANDLE_BOTTOM_MARGIN,
233 	HANDLE_PRINTER_NAME,
234 	HANDLE_PRINTER_SETUP,
235     HANDLE_SYMBOLS,
236     HANDLE_USED_SYMBOLS,
237     HANDLE_BASIC_LIBRARIES,     /* #93295# */
238     HANDLE_RUNTIME_UID,
239 	// --> PB 2004-08-25 #i33095# Security Options
240 	HANDLE_LOAD_READONLY,
241 	// <--
242     HANDLE_DIALOG_LIBRARIES,     // #i73329#
243     HANDLE_BASELINE // 3.7.2010 #i972#
244 };
245 
lcl_createModelPropertyInfo()246 PropertySetInfo * lcl_createModelPropertyInfo ()
247 {
248 	static PropertyMapEntry aModelPropertyInfoMap[] =
249 	{
250 		{ RTL_CONSTASCII_STRINGPARAM( "Alignment"                          ), HANDLE_ALIGNMENT                          , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, 0},
251 		{ RTL_CONSTASCII_STRINGPARAM( "BaseFontHeight"                  ), HANDLE_BASE_FONT_HEIGHT                   , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, 0},
252         { RTL_CONSTASCII_STRINGPARAM( "BasicLibraries"                  ), HANDLE_BASIC_LIBRARIES                   ,      &::getCppuType((const uno::Reference< script::XLibraryContainer > *)0),    PropertyAttribute::READONLY, 0},
253 		{ RTL_CONSTASCII_STRINGPARAM( "BottomMargin"            		  ), HANDLE_BOTTOM_MARGIN              		   , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_BOTTOMSPACE			   },
254 		{ RTL_CONSTASCII_STRINGPARAM( "CustomFontNameFixed"            ), HANDLE_CUSTOM_FONT_NAME_FIXED             , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, FNT_FIXED		  },
255 		{ RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSans"              ), HANDLE_CUSTOM_FONT_NAME_SANS              , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, FNT_SANS		   },
256 		{ RTL_CONSTASCII_STRINGPARAM( "CustomFontNameSerif"             ), HANDLE_CUSTOM_FONT_NAME_SERIF             , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, FNT_SERIF		  },
257         { RTL_CONSTASCII_STRINGPARAM( "DialogLibraries"                 ), HANDLE_DIALOG_LIBRARIES                   ,      &::getCppuType((const uno::Reference< script::XLibraryContainer > *)0),    PropertyAttribute::READONLY, 0},
258 		{ RTL_CONSTASCII_STRINGPARAM( "FontFixedIsBold"),	  HANDLE_CUSTOM_FONT_FIXED_WEIGHT    ,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_FIXED},
259 		{ RTL_CONSTASCII_STRINGPARAM( "FontFixedIsItalic"), HANDLE_CUSTOM_FONT_FIXED_POSTURE   ,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_FIXED},
260 		{ RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsBold"),	 HANDLE_FONT_FUNCTIONS_WEIGHT    ,  &::getBooleanCppuType(),  			PROPERTY_NONE, FNT_FUNCTION},
261 		{ RTL_CONSTASCII_STRINGPARAM( "FontFunctionsIsItalic"),   HANDLE_FONT_FUNCTIONS_POSTURE   ,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_FUNCTION},
262 		{ RTL_CONSTASCII_STRINGPARAM( "FontNameFunctions"                ), HANDLE_FONT_NAME_FUNCTIONS                , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, FNT_FUNCTION	},
263 		{ RTL_CONSTASCII_STRINGPARAM( "FontNameNumbers"                  ), HANDLE_FONT_NAME_NUMBERS                  , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, FNT_NUMBER		 },
264 		{ RTL_CONSTASCII_STRINGPARAM( "FontNameText"                     ), HANDLE_FONT_NAME_TEXT                     , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, FNT_TEXT		   },
265 		{ RTL_CONSTASCII_STRINGPARAM( "FontNameVariables"                ), HANDLE_FONT_NAME_VARIABLES                , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, FNT_VARIABLE },
266 		{ RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsBold"),	 HANDLE_FONT_NUMBERS_WEIGHT    ,  &::getBooleanCppuType(),  			PROPERTY_NONE, FNT_NUMBER},
267 		{ RTL_CONSTASCII_STRINGPARAM( "FontNumbersIsItalic"),   HANDLE_FONT_NUMBERS_POSTURE   ,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_NUMBER},
268 		{ RTL_CONSTASCII_STRINGPARAM( "FontSansIsBold"),	 HANDLE_CUSTOM_FONT_SANS_WEIGHT    ,  &::getBooleanCppuType(),  			PROPERTY_NONE, FNT_SANS},
269 		{ RTL_CONSTASCII_STRINGPARAM( "FontSansIsItalic"),   HANDLE_CUSTOM_FONT_SANS_POSTURE   ,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_SANS},
270 		{ RTL_CONSTASCII_STRINGPARAM( "FontSerifIsBold"),	 HANDLE_CUSTOM_FONT_SERIF_WEIGHT    ,  &::getBooleanCppuType(),  			PROPERTY_NONE,  FNT_SERIF},
271 		{ RTL_CONSTASCII_STRINGPARAM( "FontSerifIsItalic"),   HANDLE_CUSTOM_FONT_SERIF_POSTURE   ,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_SERIF},
272         { RTL_CONSTASCII_STRINGPARAM( "FontTextIsBold"),     HANDLE_FONT_TEXT_WEIGHT    ,  &::getBooleanCppuType(),             PROPERTY_NONE, FNT_TEXT},
273         { RTL_CONSTASCII_STRINGPARAM( "FontTextIsItalic"),   HANDLE_FONT_TEXT_POSTURE   ,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_TEXT},
274         { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsBold"),    HANDLE_FONT_VARIABLES_WEIGHT    ,  &::getBooleanCppuType(),            PROPERTY_NONE, FNT_VARIABLE},
275         { RTL_CONSTASCII_STRINGPARAM( "FontVariablesIsItalic"),   HANDLE_FONT_VARIABLES_POSTURE,  &::getBooleanCppuType(),  PROPERTY_NONE, FNT_VARIABLE},
276 		{ RTL_CONSTASCII_STRINGPARAM( "Formula"							  ),	HANDLE_FORMULA							   , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, 0},
277 		{ RTL_CONSTASCII_STRINGPARAM( "IsScaleAllBrackets"              ), HANDLE_IS_SCALE_ALL_BRACKETS              , 		&::getBooleanCppuType(), 	PROPERTY_NONE, 0},
278 		{ RTL_CONSTASCII_STRINGPARAM( "IsTextMode"                       ), HANDLE_IS_TEXT_MODE                       , 		&::getBooleanCppuType(), 	PROPERTY_NONE, 0},
279 		{ RTL_CONSTASCII_STRINGPARAM( "GreekCharStyle" ),                   HANDLE_GREEK_CHAR_STYLE,    &::getCppuType((const sal_Int16*)0),    PROPERTY_NONE, 0},
280 		{ RTL_CONSTASCII_STRINGPARAM( "LeftMargin"               		  ), HANDLE_LEFT_MARGIN        		           , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_LEFTSPACE			     },
281 		{ RTL_CONSTASCII_STRINGPARAM( "PrinterName"                	   ), HANDLE_PRINTER_NAME               		 , 		&::getCppuType((const OUString*)0), 	PROPERTY_NONE, 0			      },
282 		{ RTL_CONSTASCII_STRINGPARAM( "PrinterSetup"                	   ), HANDLE_PRINTER_SETUP               		 , 		&::getCppuType((const Sequence < sal_Int8 >*)0), 	PROPERTY_NONE, 0			      },
283 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeBracketDistance"          ), HANDLE_RELATIVE_BRACKET_DISTANCE          , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_BRACKETSPACE	},
284 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeBracketExcessSize"       ), HANDLE_RELATIVE_BRACKET_EXCESS_SIZE       , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_BRACKETSIZE 	},
285 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightFunctions"     ), HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS     , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, SIZ_FUNCTION},
286 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightIndices"       ), HANDLE_RELATIVE_FONT_HEIGHT_INDICES       , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, SIZ_INDEX	  },
287 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightLimits"        ), HANDLE_RELATIVE_FONT_HEIGHT_LIMITS        , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, SIZ_LIMITS	 },
288 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightOperators"     ), HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS     , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, SIZ_OPERATOR},
289 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFontHeightText"       	  ), HANDLE_RELATIVE_FONT_HEIGHT_TEXT          , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, SIZ_TEXT	  },
290 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarExcessLength"), HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH, 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_FRACTION		   },
291 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFractionBarLineWeight"  ), HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT  , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_STROKEWIDTH 	},
292 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFractionDenominatorDepth"), HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH, 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_DENOMINATOR 	},
293 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeFractionNumeratorHeight" ), HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_NUMERATOR		  },
294 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSubscript"           ), HANDLE_RELATIVE_INDEX_SUBSCRIPT           , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_SUBSCRIPT		  },
295 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeIndexSuperscript"         ), HANDLE_RELATIVE_INDEX_SUPERSCRIPT         , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_SUPERSCRIPT 	},
296 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeLineSpacing"              ), HANDLE_RELATIVE_LINE_SPACING              , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_VERTICAL		   },
297 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeLowerLimitDistance"      ), HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE      , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_LOWERLIMIT		 },
298 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixColumnSpacing"     ), HANDLE_RELATIVE_MATRIX_COLUMN_SPACING     , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_MATRIXCOL},
299 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeMatrixLineSpacing"       ), HANDLE_RELATIVE_MATRIX_LINE_SPACING       , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_MATRIXROW},
300 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorExcessSize"      ), HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE      , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_OPERATORSIZE		   },
301 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeOperatorSpacing"          ), HANDLE_RELATIVE_OPERATOR_SPACING          , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_OPERATORSPACE},
302 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeRootSpacing"              ), HANDLE_RELATIVE_ROOT_SPACING              , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_ROOT			      },
303 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeScaleBracketExcessSize" ), HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_NORMALBRACKETSIZE},
304 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeSpacing"                   ), HANDLE_RELATIVE_SPACING                   , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_HORIZONTAL		 },
305 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolMinimumHeight"     ), HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT     , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_ORNAMENTSPACE		 },
306 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeSymbolPrimaryHeight"     ), HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT     , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_ORNAMENTSIZE		   },
307 		{ RTL_CONSTASCII_STRINGPARAM( "RelativeUpperLimitDistance"      ), 	HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE     , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_UPPERLIMIT		 },
308 		{ RTL_CONSTASCII_STRINGPARAM( "RightMargin"              		  ), 	HANDLE_RIGHT_MARGIN              	 , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_RIGHTSPACE			    },
309         { RTL_CONSTASCII_STRINGPARAM( "RuntimeUID"                      ), HANDLE_RUNTIME_UID                        ,      &::getCppuType(static_cast< const rtl::OUString * >(0)),    PropertyAttribute::READONLY, 0 },
310 		{ RTL_CONSTASCII_STRINGPARAM( "Symbols"              		  ), 		HANDLE_SYMBOLS              		 , 		&::getCppuType((const Sequence < SymbolDescriptor > *)0), 	PROPERTY_NONE, 0  },
311         { RTL_CONSTASCII_STRINGPARAM( "UserDefinedSymbolsInUse"       ),        HANDLE_USED_SYMBOLS                  ,      &::getCppuType((const Sequence < SymbolDescriptor > *)0),   PropertyAttribute::READONLY, 0  },
312 		{ RTL_CONSTASCII_STRINGPARAM( "TopMargin"                		  ), 	HANDLE_TOP_MARGIN                	 , 		&::getCppuType((const sal_Int16*)0), 	PROPERTY_NONE, DIS_TOPSPACE			      },
313 		// --> PB 2004-08-25 #i33095# Security Options
314 		{ RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY, &::getBooleanCppuType(), PROPERTY_NONE, 0 },
315 		// <--
316         // --> 3.7.2010 #i972#
317         { RTL_CONSTASCII_STRINGPARAM( "BaseLine"), HANDLE_BASELINE, &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, 0},
318         // <--
319 		{ NULL, 0, 0, NULL, 0, 0 }
320 	};
321 	PropertySetInfo *pInfo = new PropertySetInfo ( aModelPropertyInfoMap );
322 	return pInfo;
323 }
324 //-----------------------------------------------------------------------
SmModel(SfxObjectShell * pObjSh)325 SmModel::SmModel( SfxObjectShell *pObjSh )
326 : SfxBaseModel(pObjSh)
327 , PropertySetHelper ( lcl_createModelPropertyInfo () )
328 , m_pPrintUIOptions( NULL )
329 
330 {
331 }
332 //-----------------------------------------------------------------------
~SmModel()333 SmModel::~SmModel() throw ()
334 {
335     delete m_pPrintUIOptions;
336 }
337 /*-- 28.03.00 14:18:17---------------------------------------------------
338 
339   -----------------------------------------------------------------------*/
queryInterface(const uno::Type & rType)340 uno::Any SAL_CALL SmModel::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
341 {
342     uno::Any aRet =  ::cppu::queryInterface ( rType,
343 									// OWeakObject interfaces
344                                     dynamic_cast< XInterface* > ( static_cast< XUnoTunnel* > ( this )),
345                                     static_cast< XWeak* > ( this ),
346 									// PropertySetHelper interfaces
347                                     static_cast< XPropertySet* > ( this ),
348                                     static_cast< XMultiPropertySet* > ( this ),
349                                     //static_cast< XPropertyState* > ( this ),
350 									// my own interfaces
351                                     static_cast< XServiceInfo*  > ( this ),
352                                     static_cast< XRenderable*  > ( this ) );
353 	if (!aRet.hasValue())
354 		aRet = SfxBaseModel::queryInterface ( rType );
355 	return aRet;
356 }
357 /*-- 28.03.00 14:18:18---------------------------------------------------
358 
359   -----------------------------------------------------------------------*/
acquire()360 void SAL_CALL SmModel::acquire() throw()
361 {
362 	OWeakObject::acquire();
363 }
364 /*-- 28.03.00 14:18:18---------------------------------------------------
365 
366   -----------------------------------------------------------------------*/
release()367 void SAL_CALL SmModel::release() throw()
368 {
369 	OWeakObject::release();
370 }
371 /*-- 28.03.00 14:18:19---------------------------------------------------
372 
373   -----------------------------------------------------------------------*/
getTypes()374 uno::Sequence< uno::Type > SAL_CALL SmModel::getTypes(  ) throw(uno::RuntimeException)
375 {
376 	::vos::OGuard aGuard(Application::GetSolarMutex());
377     uno::Sequence< uno::Type > aTypes = SfxBaseModel::getTypes();
378     sal_Int32 nLen = aTypes.getLength();
379     aTypes.realloc(nLen + 4);
380     uno::Type* pTypes = aTypes.getArray();
381     pTypes[nLen++] = ::getCppuType((Reference<XServiceInfo>*)0);
382     pTypes[nLen++] = ::getCppuType((Reference<XPropertySet>*)0);
383     pTypes[nLen++] = ::getCppuType((Reference<XMultiPropertySet>*)0);
384     pTypes[nLen++] = ::getCppuType((Reference<XRenderable>*)0);
385 
386     // XPropertyState not supported?? (respective virtual functions from
387     // PropertySetHelper not overloaded)
388     //pTypes[nLen++] = ::getCppuType((Reference<XPropertyState>*)0);
389 
390     return aTypes;
391 }
392 /* -----------------------------28.03.00 14:23--------------------------------
393 
394  ---------------------------------------------------------------------------*/
getUnoTunnelId()395 const uno::Sequence< sal_Int8 > & SmModel::getUnoTunnelId()
396 {
397 	static osl::Mutex aCreateMutex;
398 	osl::Guard<osl::Mutex> aGuard( aCreateMutex );
399 
400 	static uno::Sequence< sal_Int8 > aSeq;
401 	if(!aSeq.getLength())
402 	{
403 		aSeq.realloc( 16 );
404     	rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0,	sal_True );
405 	}
406 	return aSeq;
407 } /* -----------------------------28.03.00 14:23--------------------------------
408 
409  ---------------------------------------------------------------------------*/
getSomething(const uno::Sequence<sal_Int8> & rId)410 sal_Int64 SAL_CALL SmModel::getSomething( const uno::Sequence< sal_Int8 >& rId )
411 	throw(uno::RuntimeException)
412 {
413     if( rId.getLength() == 16
414         && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
415 										rId.getConstArray(), 16 ) )
416     {
417             return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
418     }
419 
420 	return SfxBaseModel::getSomething( rId );
421 }
422 /*-- 07.01.00 16:32:59---------------------------------------------------
423 
424   -----------------------------------------------------------------------*/
425 /*-- 07.01.00 16:33:00---------------------------------------------------
426 
427   -----------------------------------------------------------------------*/
lcl_AnyToINT16(const uno::Any & rAny)428 sal_Int16 lcl_AnyToINT16(const uno::Any& rAny)
429 {
430 	uno::TypeClass eType = rAny.getValueType().getTypeClass();
431 
432 	sal_Int16 nRet = 0;
433 	if( eType == uno::TypeClass_DOUBLE )
434 		nRet = (sal_Int16)*(double*)rAny.getValue();
435 	else if( eType == uno::TypeClass_FLOAT )
436 		nRet = (sal_Int16)*(float*)rAny.getValue();
437 	else
438 		rAny >>= nRet;
439 	return nRet;
440 }
441 //-----------------------------------------------------------------------------
442 
getImplementationName(void)443 OUString SmModel::getImplementationName(void) throw( uno::RuntimeException )
444 {
445 	return getImplementationName_Static();
446 }
447 
448 
getImplementationName_Static()449 ::rtl::OUString SmModel::getImplementationName_Static()
450 {
451 	return rtl::OUString::createFromAscii("com.sun.star.comp.math.FormulaDocument");
452 }
453 
454 /*-- 20.01.04 11:21:00---------------------------------------------------
455 
456   -----------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)457 sal_Bool SmModel::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
458 {
459     return (
460             rServiceName == A2OU("com.sun.star.document.OfficeDocument"  ) ||
461             rServiceName == A2OU("com.sun.star.formula.FormulaProperties")
462            );
463 }
464 /*-- 20.01.04 11:21:00---------------------------------------------------
465 
466   -----------------------------------------------------------------------*/
getSupportedServiceNames(void)467 uno::Sequence< OUString > SmModel::getSupportedServiceNames(void) throw( uno::RuntimeException )
468 {
469 	return getSupportedServiceNames_Static();
470 }
471 
getSupportedServiceNames_Static(void)472 uno::Sequence< OUString > SmModel::getSupportedServiceNames_Static(void)
473 {
474 	::vos::OGuard aGuard(Application::GetSolarMutex());
475 
476 	uno::Sequence< OUString > aRet(2);
477 	OUString* pArray = aRet.getArray();
478 	pArray[0] = A2OU("com.sun.star.document.OfficeDocument");
479 	pArray[1] = A2OU("com.sun.star.formula.FormulaProperties");
480 	return aRet;
481 }
482 
_setPropertyValues(const PropertyMapEntry ** ppEntries,const Any * pValues)483 void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* pValues)
484 	throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException)
485 {
486 	::vos::OGuard aGuard(Application::GetSolarMutex());
487 
488 	SmDocShell *pDocSh = static_cast < SmDocShell * > (GetObjectShell());
489 
490 	if ( NULL == pDocSh )
491 		throw UnknownPropertyException();
492 
493 	SmFormat aFormat = pDocSh->GetFormat();
494 
495 	for (; *ppEntries; ppEntries++, pValues++ )
496 	{
497         if ((*ppEntries)->mnAttributes & PropertyAttribute::READONLY)
498             throw PropertyVetoException();
499 
500 		switch ( (*ppEntries)->mnHandle )
501 		{
502 			case HANDLE_FORMULA:
503 			{
504 				OUString aText;
505 				*pValues >>= aText;
506 				pDocSh->SetText(aText);
507 			}
508 			break;
509 			case HANDLE_FONT_NAME_VARIABLES                :
510 			case HANDLE_FONT_NAME_FUNCTIONS                :
511 			case HANDLE_FONT_NAME_NUMBERS                  :
512 			case HANDLE_FONT_NAME_TEXT                     :
513 			case HANDLE_CUSTOM_FONT_NAME_SERIF             :
514 			case HANDLE_CUSTOM_FONT_NAME_SANS              :
515 			case HANDLE_CUSTOM_FONT_NAME_FIXED             :
516 			{
517 				OUString aText;
518 				*pValues >>= aText;
519 				String sFontName = aText;
520 				if(!sFontName.Len())
521 					throw IllegalArgumentException();
522 
523                 if(aFormat.GetFont((*ppEntries)->mnMemberId).GetName() != sFontName)
524 				{
525                     const SmFace rOld = aFormat.GetFont((*ppEntries)->mnMemberId);
526 
527                     SmFace aSet( sFontName, rOld.GetSize() );
528                     aSet.SetBorderWidth( rOld.GetBorderWidth() );
529                     aSet.SetAlign( ALIGN_BASELINE );
530                     aFormat.SetFont( (*ppEntries)->mnMemberId, aSet );
531 				}
532 			}
533 			break;
534 			case HANDLE_CUSTOM_FONT_FIXED_POSTURE:
535 			case HANDLE_CUSTOM_FONT_SANS_POSTURE :
536 			case HANDLE_CUSTOM_FONT_SERIF_POSTURE:
537 			case HANDLE_FONT_VARIABLES_POSTURE   :
538 			case HANDLE_FONT_FUNCTIONS_POSTURE   :
539 			case HANDLE_FONT_NUMBERS_POSTURE     :
540 			case HANDLE_FONT_TEXT_POSTURE        :
541 			{
542 				if((*pValues).getValueType() != ::getBooleanCppuType())
543 					throw IllegalArgumentException();
544 				sal_Bool bVal = *(sal_Bool*)(*pValues).getValue();
545 				Font aNewFont(aFormat.GetFont((*ppEntries)->mnMemberId));
546 				aNewFont.SetItalic((bVal) ? ITALIC_NORMAL : ITALIC_NONE);
547 				aFormat.SetFont((*ppEntries)->mnMemberId, aNewFont);
548 			}
549 			break;
550 			case HANDLE_CUSTOM_FONT_FIXED_WEIGHT :
551 			case HANDLE_CUSTOM_FONT_SANS_WEIGHT  :
552 			case HANDLE_CUSTOM_FONT_SERIF_WEIGHT :
553 			case HANDLE_FONT_VARIABLES_WEIGHT    :
554 			case HANDLE_FONT_FUNCTIONS_WEIGHT    :
555 			case HANDLE_FONT_NUMBERS_WEIGHT      :
556 			case HANDLE_FONT_TEXT_WEIGHT         :
557 			{
558 				if((*pValues).getValueType() != ::getBooleanCppuType())
559 					throw IllegalArgumentException();
560 				sal_Bool bVal = *(sal_Bool*)(*pValues).getValue();
561 				Font aNewFont(aFormat.GetFont((*ppEntries)->mnMemberId));
562 				aNewFont.SetWeight((bVal) ? WEIGHT_BOLD : WEIGHT_NORMAL);
563 				aFormat.SetFont((*ppEntries)->mnMemberId, aNewFont);
564 			}
565 			break;
566 			case HANDLE_BASE_FONT_HEIGHT                   :
567 			{
568 				// Point!
569 				sal_Int16 nVal = lcl_AnyToINT16(*pValues);
570 				if(nVal < 1)
571 					throw IllegalArgumentException();
572 				Size aSize = aFormat.GetBaseSize();
573 				nVal *= 20;
574 				nVal = static_cast < sal_Int16 > ( TWIP_TO_MM100(nVal) );
575 				aSize.Height() = nVal;
576 				aFormat.SetBaseSize(aSize);
577 
578                 // apply base size to fonts
579                 const Size aTmp( aFormat.GetBaseSize() );
580                 for (sal_uInt16  i = FNT_BEGIN;  i <= FNT_END;  i++)
581                     aFormat.SetFontSize(i, aTmp);
582             }
583 			break;
584             case HANDLE_RELATIVE_FONT_HEIGHT_TEXT          :
585 			case HANDLE_RELATIVE_FONT_HEIGHT_INDICES       :
586 			case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS     :
587 			case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS     :
588 			case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS        :
589 			{
590 				sal_Int16 nVal = 0;
591 				*pValues >>= nVal;
592 				if(nVal < 1)
593 					throw IllegalArgumentException();
594 				aFormat.SetRelSize((*ppEntries)->mnMemberId, nVal);
595 			}
596 			break;
597 
598 			case HANDLE_IS_TEXT_MODE                       :
599 			{
600 				aFormat.SetTextmode(*(sal_Bool*)(*pValues).getValue());
601 			}
602             break;
603 
604             case HANDLE_GREEK_CHAR_STYLE                    :
605 			{
606 				sal_Int16 nVal = 0;
607 				*pValues >>= nVal;
608 				if (nVal < 0 || nVal > 2)
609 					throw IllegalArgumentException();
610 				aFormat.SetGreekCharStyle( nVal );
611 			}
612 			break;
613 
614 			case HANDLE_ALIGNMENT                          :
615 			{
616 				// SmHorAlign uses the same values as HorizontalAlignment
617 				sal_Int16 nVal = 0;
618 				*pValues >>= nVal;
619 				if(nVal < 0 || nVal > 2)
620 					throw IllegalArgumentException();
621 				aFormat.SetHorAlign((SmHorAlign)nVal);
622 			}
623 			break;
624 
625 			case HANDLE_RELATIVE_SPACING                   :
626 			case HANDLE_RELATIVE_LINE_SPACING              :
627 			case HANDLE_RELATIVE_ROOT_SPACING              :
628 			case HANDLE_RELATIVE_INDEX_SUPERSCRIPT         :
629 			case HANDLE_RELATIVE_INDEX_SUBSCRIPT           :
630 			case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT :
631 			case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH:
632 			case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH:
633 			case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT  :
634 			case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE      :
635 			case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE      :
636 			case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE       :
637 			case HANDLE_RELATIVE_BRACKET_DISTANCE          :
638 			case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE :
639 			case HANDLE_RELATIVE_MATRIX_LINE_SPACING       :
640 			case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING     :
641 			case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT     :
642 			case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT     :
643 			case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE      :
644 			case HANDLE_RELATIVE_OPERATOR_SPACING          :
645 			case HANDLE_LEFT_MARGIN               :
646 			case HANDLE_RIGHT_MARGIN              :
647 			case HANDLE_TOP_MARGIN                :
648 			case HANDLE_BOTTOM_MARGIN             :
649 			{
650 				sal_Int16 nVal = 0;
651 				*pValues >>= nVal;
652 				if(nVal < 0)
653 					throw IllegalArgumentException();
654 				aFormat.SetDistance((*ppEntries)->mnMemberId, nVal);
655 			}
656 			break;
657 			case HANDLE_IS_SCALE_ALL_BRACKETS              :
658 				aFormat.SetScaleNormalBrackets(*(sal_Bool*)(*pValues).getValue());
659 			break;
660 			case HANDLE_PRINTER_NAME:
661 			{
662                 // embedded documents just ignore this property for now
663                 if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
664                 {
665                     SfxPrinter *pPrinter = pDocSh->GetPrinter ( );
666                     if (pPrinter)
667                     {
668                         OUString sPrinterName;
669                         if (*pValues >>= sPrinterName )
670                         {
671                             if ( sPrinterName.getLength() )
672                             {
673                                 SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
674                                 if (pNewPrinter->IsKnown())
675                                     pDocSh->SetPrinter ( pNewPrinter );
676                                 else
677                                     delete pNewPrinter;
678                             }
679                         }
680                         else
681                             throw IllegalArgumentException();
682                     }
683                 }
684 			}
685 			break;
686 			case HANDLE_PRINTER_SETUP:
687 			{
688 				Sequence < sal_Int8 > aSequence;
689 				if ( *pValues >>= aSequence )
690 				{
691 					sal_uInt32 nSize = aSequence.getLength();
692 					SvMemoryStream aStream ( aSequence.getArray(), nSize, STREAM_READ );
693 					aStream.Seek ( STREAM_SEEK_TO_BEGIN );
694 					static sal_uInt16 __READONLY_DATA nRange[] =
695 					{
696                         SID_PRINTSIZE,       SID_PRINTSIZE,
697                         SID_PRINTZOOM,       SID_PRINTZOOM,
698                         SID_PRINTTITLE,      SID_PRINTTITLE,
699                         SID_PRINTTEXT,       SID_PRINTTEXT,
700                         SID_PRINTFRAME,      SID_PRINTFRAME,
701                         SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
702                         SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
703 						0
704 					};
705 					SfxItemSet *pItemSet = new SfxItemSet( pDocSh->GetPool(), nRange );
706                     SmModule *pp = SM_MOD();
707                     pp->GetConfig()->ConfigToItemSet(*pItemSet);
708 					SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
709 
710 					pDocSh->SetPrinter( pPrinter );
711 				}
712 				else
713 					throw IllegalArgumentException();
714 			}
715 			break;
716 			case HANDLE_SYMBOLS:
717 			{
718 				// this is set
719 				Sequence < SymbolDescriptor > aSequence;
720 				if ( *pValues >>= aSequence )
721 				{
722 					sal_uInt32 nSize = aSequence.getLength();
723                     SmModule *pp = SM_MOD();
724                     SmSymbolManager &rManager = pp->GetSymbolManager();
725 					SymbolDescriptor *pDescriptor = aSequence.getArray();
726 					for (sal_uInt32 i = 0; i < nSize ; i++, pDescriptor++)
727 					{
728 						Font aFont;
729 						aFont.SetName ( pDescriptor->sFontName );
730 						aFont.SetCharSet ( static_cast < rtl_TextEncoding > (pDescriptor->nCharSet) );
731 						aFont.SetFamily ( static_cast < FontFamily > (pDescriptor->nFamily ) );
732 						aFont.SetPitch  ( static_cast < FontPitch >  (pDescriptor->nPitch ) );
733 						aFont.SetWeight ( static_cast < FontWeight > (pDescriptor->nWeight ) );
734 						aFont.SetItalic ( static_cast < FontItalic > (pDescriptor->nItalic ) );
735 						SmSym aSymbol ( pDescriptor->sName, aFont, static_cast < sal_Unicode > (pDescriptor->nCharacter),
736 										pDescriptor->sSymbolSet );
737 						aSymbol.SetExportName ( pDescriptor->sExportName );
738                         aSymbol.SetDocSymbol( sal_True );
739                         rManager.AddOrReplaceSymbol ( aSymbol );
740 					}
741 				}
742 				else
743 					throw IllegalArgumentException();
744 			}
745 			break;
746 			// --> PB 2004-08-25 #i33095# Security Options
747 			case HANDLE_LOAD_READONLY :
748 			{
749 				if ( (*pValues).getValueType() != ::getBooleanCppuType() )
750 					throw IllegalArgumentException();
751 				sal_Bool bReadonly = sal_False;
752 				if ( *pValues >>= bReadonly )
753 					pDocSh->SetLoadReadonly( bReadonly );
754 				break;
755 			}
756 			// <--
757 		}
758 	}
759 
760 	pDocSh->SetFormat( aFormat );
761 
762 	// #i67283# since about all of the above changes are likely to change
763 	// the formula size we have to recalculate the vis-area now
764     pDocSh->SetVisArea( Rectangle( Point(0, 0), pDocSh->GetSize() ) );
765 }
766 
_getPropertyValues(const PropertyMapEntry ** ppEntries,Any * pValue)767 void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValue )
768 	throw( UnknownPropertyException, WrappedTargetException )
769 {
770 	SmDocShell *pDocSh = static_cast < SmDocShell * > (GetObjectShell());
771 
772 	if ( NULL == pDocSh )
773 		throw UnknownPropertyException();
774 
775 	const SmFormat & aFormat = pDocSh->GetFormat();
776 
777 	for (; *ppEntries; ppEntries++, pValue++ )
778 	{
779 		switch ( (*ppEntries)->mnHandle )
780 		{
781 			case HANDLE_FORMULA:
782 				*pValue <<= OUString(pDocSh->GetText());
783 			break;
784 			case HANDLE_FONT_NAME_VARIABLES                :
785 			case HANDLE_FONT_NAME_FUNCTIONS                :
786 			case HANDLE_FONT_NAME_NUMBERS                  :
787 			case HANDLE_FONT_NAME_TEXT                     :
788 			case HANDLE_CUSTOM_FONT_NAME_SERIF             :
789 			case HANDLE_CUSTOM_FONT_NAME_SANS              :
790 			case HANDLE_CUSTOM_FONT_NAME_FIXED             :
791 			{
792 				const SmFace &  rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
793 				*pValue <<= OUString(rFace.GetName());
794 			}
795 			break;
796 			case HANDLE_CUSTOM_FONT_FIXED_POSTURE:
797 			case HANDLE_CUSTOM_FONT_SANS_POSTURE :
798 			case HANDLE_CUSTOM_FONT_SERIF_POSTURE:
799 			case HANDLE_FONT_VARIABLES_POSTURE   :
800 			case HANDLE_FONT_FUNCTIONS_POSTURE   :
801 			case HANDLE_FONT_NUMBERS_POSTURE     :
802 			case HANDLE_FONT_TEXT_POSTURE        :
803 			{
804 				const SmFace &  rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
805                 sal_Bool bVal = IsItalic( rFace );
806 				(*pValue).setValue(&bVal, *(*ppEntries)->mpType);
807 			}
808 			break;
809 			case HANDLE_CUSTOM_FONT_FIXED_WEIGHT :
810 			case HANDLE_CUSTOM_FONT_SANS_WEIGHT  :
811 			case HANDLE_CUSTOM_FONT_SERIF_WEIGHT :
812 			case HANDLE_FONT_VARIABLES_WEIGHT    :
813 			case HANDLE_FONT_FUNCTIONS_WEIGHT    :
814 			case HANDLE_FONT_NUMBERS_WEIGHT      :
815 			case HANDLE_FONT_TEXT_WEIGHT         :
816 			{
817 				const SmFace &  rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
818                 sal_Bool bVal = IsBold( rFace ); // bold?
819 				(*pValue).setValue(&bVal, *(*ppEntries)->mpType);
820 			}
821 			break;
822 			case HANDLE_BASE_FONT_HEIGHT                   :
823 			{
824 				// Point!
825 				sal_Int16 nVal = static_cast < sal_Int16 > (aFormat.GetBaseSize().Height());
826 				nVal = static_cast < sal_Int16 > (MM100_TO_TWIP(nVal));
827 				nVal = (nVal + 10) / 20;
828 				*pValue <<= nVal;
829 			}
830 			break;
831 			case HANDLE_RELATIVE_FONT_HEIGHT_TEXT       	:
832 			case HANDLE_RELATIVE_FONT_HEIGHT_INDICES       :
833 			case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS     :
834 			case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS     :
835 			case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS        :
836 				*pValue <<= (sal_Int16) aFormat.GetRelSize((*ppEntries)->mnMemberId);
837 			break;
838 
839 			case HANDLE_IS_TEXT_MODE                       :
840 			{
841 				sal_Bool bVal = aFormat.IsTextmode();
842 				(*pValue).setValue(&bVal, ::getBooleanCppuType());
843 			}
844 			break;
845 
846             case HANDLE_GREEK_CHAR_STYLE                    :
847 				*pValue <<= (sal_Int16)aFormat.GetGreekCharStyle();
848 			break;
849 
850 			case HANDLE_ALIGNMENT                          :
851 				// SmHorAlign uses the same values as HorizontalAlignment
852 				*pValue <<= (sal_Int16)aFormat.GetHorAlign();
853 			break;
854 
855 			case HANDLE_RELATIVE_SPACING                   :
856 			case HANDLE_RELATIVE_LINE_SPACING              :
857 			case HANDLE_RELATIVE_ROOT_SPACING              :
858 			case HANDLE_RELATIVE_INDEX_SUPERSCRIPT         :
859 			case HANDLE_RELATIVE_INDEX_SUBSCRIPT           :
860 			case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT :
861 			case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH:
862 			case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH:
863 			case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT  :
864 			case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE      :
865 			case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE      :
866 			case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE       :
867 			case HANDLE_RELATIVE_BRACKET_DISTANCE          :
868 			case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE :
869 			case HANDLE_RELATIVE_MATRIX_LINE_SPACING       :
870 			case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING     :
871 			case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT     :
872 			case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT     :
873 			case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE      :
874 			case HANDLE_RELATIVE_OPERATOR_SPACING          :
875 			case HANDLE_LEFT_MARGIN               :
876 			case HANDLE_RIGHT_MARGIN              :
877 			case HANDLE_TOP_MARGIN                :
878 			case HANDLE_BOTTOM_MARGIN             :
879 				*pValue <<= (sal_Int16)aFormat.GetDistance((*ppEntries)->mnMemberId);
880 			break;
881 			case HANDLE_IS_SCALE_ALL_BRACKETS              :
882 			{
883 				sal_Bool bVal = aFormat.IsScaleNormalBrackets();
884 				(*pValue).setValue(&bVal, ::getBooleanCppuType());
885 			}
886 			break;
887 			case HANDLE_PRINTER_NAME:
888 			{
889 				SfxPrinter *pPrinter = pDocSh->GetPrinter ( );
890 				*pValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString();
891 			}
892 			break;
893 			case HANDLE_PRINTER_SETUP:
894 			{
895 				SfxPrinter *pPrinter = pDocSh->GetPrinter ();
896 				if (pPrinter)
897 				{
898 					SvMemoryStream aStream;
899 					pPrinter->Store( aStream );
900 					aStream.Seek ( STREAM_SEEK_TO_END );
901 					sal_uInt32 nSize = aStream.Tell();
902 					aStream.Seek ( STREAM_SEEK_TO_BEGIN );
903 					Sequence < sal_Int8 > aSequence ( nSize );
904 					aStream.Read ( aSequence.getArray(), nSize );
905 					*pValue <<= aSequence;
906 				}
907 			}
908 			break;
909 			case HANDLE_SYMBOLS:
910 			case HANDLE_USED_SYMBOLS:
911 			{
912                 const bool bUsedSymbolsOnly = (*ppEntries)->mnHandle == HANDLE_USED_SYMBOLS;
913                 const std::set< rtl::OUString > &rUsedSymbols = pDocSh->GetUsedSymbols();
914 
915 				// this is get
916                 SmModule *pp = SM_MOD();
917                 const SmSymbolManager &rManager = pp->GetSymbolManager();
918 				vector < const SmSym * > aVector;
919 
920                 const SymbolPtrVec_t aSymbols( rManager.GetSymbols() );
921                 size_t nCount = 0;
922                 for (size_t i = 0; i < aSymbols.size(); ++i)
923 				{
924                     const SmSym * pSymbol = aSymbols[ i ];
925                     const bool bIsUsedSymbol = rUsedSymbols.find( pSymbol->GetName() ) != rUsedSymbols.end();
926 					if (pSymbol && !pSymbol->IsPredefined() &&
927                         (!bUsedSymbolsOnly || bIsUsedSymbol))
928 					{
929 						aVector.push_back ( pSymbol );
930 						nCount++;
931 					}
932 				}
933 				Sequence < SymbolDescriptor > aSequence ( nCount );
934 				SymbolDescriptor * pDescriptor = aSequence.getArray();
935 
936                 vector < const SmSym * >::const_iterator aIter = aVector.begin(), aEnd = aVector.end();
937 				for(; aIter != aEnd; pDescriptor++, aIter++)
938 				{
939 					pDescriptor->sName = (*aIter)->GetName();
940 					pDescriptor->sExportName = (*aIter)->GetExportName();
941                     pDescriptor->sSymbolSet = (*aIter)->GetSymbolSetName();
942 					pDescriptor->nCharacter = static_cast < sal_Int32 > ((*aIter)->GetCharacter());
943 
944 					Font rFont = (*aIter)->GetFace();
945 					pDescriptor->sFontName = rFont.GetName();
946                     pDescriptor->nCharSet  = sal::static_int_cast< sal_Int16 >(rFont.GetCharSet());
947                     pDescriptor->nFamily   = sal::static_int_cast< sal_Int16 >(rFont.GetFamily());
948                     pDescriptor->nPitch    = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());
949                     pDescriptor->nWeight   = sal::static_int_cast< sal_Int16 >(rFont.GetWeight());
950                     pDescriptor->nItalic   = sal::static_int_cast< sal_Int16 >(rFont.GetItalic());
951 				}
952 				*pValue <<= aSequence;
953 			}
954 			break;
955             case HANDLE_BASIC_LIBRARIES:
956                 *pValue <<= pDocSh->GetBasicContainer();
957             break;
958             case HANDLE_DIALOG_LIBRARIES:
959                 *pValue <<= pDocSh->GetDialogContainer();
960             break;
961             case HANDLE_RUNTIME_UID:
962                 *pValue <<= getRuntimeUID();
963             break;
964 			// --> PB 2004-08-25 #i33095# Security Options
965 			case HANDLE_LOAD_READONLY :
966 			{
967  				*pValue <<= pDocSh->IsLoadReadonly();
968 				break;
969 			}
970 			// <--
971             // --> 3.7.2010 #i972#
972             case HANDLE_BASELINE:
973             {
974                 if ( !pDocSh->pTree )
975                     pDocSh->Parse();
976                 if ( pDocSh->pTree )
977                 {
978                     if ( !pDocSh->IsFormulaArranged() )
979                         pDocSh->ArrangeFormula();
980 
981                     *pValue <<= static_cast<sal_Int32>( pDocSh->pTree->GetFormulaBaseline() );
982                 }
983             }
984             break;
985             // <--
986         }
987 	}
988 }
989 
990 //////////////////////////////////////////////////////////////////////
991 
getRendererCount(const uno::Any &,const uno::Sequence<beans::PropertyValue> &)992 sal_Int32 SAL_CALL SmModel::getRendererCount(
993         const uno::Any& /*rSelection*/,
994         const uno::Sequence< beans::PropertyValue >& /*xOptions*/ )
995     throw (IllegalArgumentException, RuntimeException)
996 {
997 	::vos::OGuard aGuard(Application::GetSolarMutex());
998     return 1;
999 }
1000 
1001 
lcl_GuessPaperSize()1002 static Size lcl_GuessPaperSize()
1003 {
1004     Size aRes;
1005     Reference< XMultiServiceFactory >  xMgr( getProcessServiceFactory() );
1006     LocaleDataWrapper aLocWrp( xMgr, AllSettings().GetLocale() );
1007     if( MEASURE_METRIC == aLocWrp.getMeasurementSystemEnum() )
1008     {
1009         // in 100th mm
1010         PaperInfo aInfo( PAPER_A4 );
1011         aRes.Width()  = aInfo.getWidth();
1012         aRes.Height() = aInfo.getHeight();
1013     }
1014     else
1015     {
1016         // in 100th mm
1017         PaperInfo aInfo( PAPER_LETTER );
1018         aRes.Width()  = aInfo.getWidth();
1019         aRes.Height() = aInfo.getHeight();
1020     }
1021     return aRes;
1022 }
1023 
getRenderer(sal_Int32 nRenderer,const uno::Any &,const uno::Sequence<beans::PropertyValue> &)1024 uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
1025         sal_Int32 nRenderer,
1026         const uno::Any& /*rSelection*/,
1027         const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ )
1028     throw (IllegalArgumentException, RuntimeException)
1029 {
1030 	::vos::OGuard aGuard(Application::GetSolarMutex());
1031 
1032     if (0 != nRenderer)
1033         throw IllegalArgumentException();
1034 
1035     SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() );
1036     if (!pDocSh)
1037         throw RuntimeException();
1038 
1039     SmPrinterAccess aPrinterAccess( *pDocSh );
1040     Printer *pPrinter = aPrinterAccess.GetPrinter();
1041     //Point   aPrtPageOffset( pPrinter->GetPageOffset() );
1042     Size    aPrtPaperSize ( pPrinter->GetPaperSize() );
1043 
1044     // if paper size is 0 (usually if no 'real' printer is found),
1045     // guess the paper size
1046     if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
1047         aPrtPaperSize = lcl_GuessPaperSize();
1048     awt::Size   aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() );
1049 
1050     uno::Sequence< beans::PropertyValue > aRenderer(1);
1051     PropertyValue  &rValue = aRenderer.getArray()[0];
1052     rValue.Name  = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
1053     rValue.Value <<= aPageSize;
1054 
1055     if (!m_pPrintUIOptions)
1056         m_pPrintUIOptions = new SmPrintUIOptions();
1057     m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
1058 
1059     return aRenderer;
1060 }
1061 
render(sal_Int32 nRenderer,const uno::Any & rSelection,const uno::Sequence<beans::PropertyValue> & rxOptions)1062 void SAL_CALL SmModel::render(
1063         sal_Int32 nRenderer,
1064         const uno::Any& rSelection,
1065         const uno::Sequence< beans::PropertyValue >& rxOptions )
1066     throw (IllegalArgumentException, RuntimeException)
1067 {
1068 	::vos::OGuard aGuard(Application::GetSolarMutex());
1069 
1070     if (0 != nRenderer)
1071         throw IllegalArgumentException();
1072 
1073     SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() );
1074     if (!pDocSh)
1075         throw RuntimeException();
1076 
1077     // get device to be rendered in
1078     uno::Reference< awt::XDevice >  xRenderDevice;
1079     for (sal_Int32 i = 0, nCount = rxOptions.getLength();  i < nCount;  ++i)
1080     {
1081         if( rxOptions[i].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
1082             rxOptions[i].Value >>= xRenderDevice;
1083     }
1084 
1085     if (xRenderDevice.is())
1086     {
1087         VCLXDevice*   pDevice = VCLXDevice::GetImplementation( xRenderDevice );
1088         OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
1089 
1090         if (!pOut)
1091             throw RuntimeException();
1092 
1093         pOut->SetMapMode( MAP_100TH_MM );
1094 
1095         uno::Reference< frame::XModel > xModel;
1096         rSelection >>= xModel;
1097         if (xModel == pDocSh->GetModel())
1098         {
1099             //!! when called via API we may not have an active view
1100             //!! thus we go and look for a view that can be used.
1101             const TypeId aTypeId = TYPE( SmViewShell );
1102             SfxViewShell* pViewSh = SfxViewShell::GetFirst( &aTypeId, sal_False /* search non-visible views as well*/ );
1103             while (pViewSh && pViewSh->GetObjectShell() != pDocSh)
1104                 pViewSh = SfxViewShell::GetNext( *pViewSh, &aTypeId, sal_False /* search non-visible views as well*/ );
1105             SmViewShell *pView = PTR_CAST( SmViewShell, pViewSh );
1106             DBG_ASSERT( pView, "SmModel::render : no SmViewShell found" );
1107 
1108             if (pView)
1109             {
1110                 SmPrinterAccess aPrinterAccess( *pDocSh );
1111                 Printer *pPrinter = aPrinterAccess.GetPrinter();
1112 
1113                 Size    aPrtPaperSize ( pPrinter->GetPaperSize() );
1114                 Size    aOutputSize   ( pPrinter->GetOutputSize() );
1115                 Point   aPrtPageOffset( pPrinter->GetPageOffset() );
1116 
1117                 // no real printer ??
1118                 if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
1119                 {
1120                     aPrtPaperSize = lcl_GuessPaperSize();
1121                     // factors from Windows DIN A4
1122                     aOutputSize    = Size( (long)(aPrtPaperSize.Width()  * 0.941),
1123                                            (long)(aPrtPaperSize.Height() * 0.961));
1124                     aPrtPageOffset = Point( (long)(aPrtPaperSize.Width()  * 0.0250),
1125                                             (long)(aPrtPaperSize.Height() * 0.0214));
1126                 }
1127                 Point   aZeroPoint;
1128                 Rectangle OutputRect( aZeroPoint, aOutputSize );
1129 
1130 
1131                 // set minimum top and bottom border
1132                 if (aPrtPageOffset.Y() < 2000)
1133                     OutputRect.Top() += 2000 - aPrtPageOffset.Y();
1134                 if ((aPrtPaperSize.Height() - (aPrtPageOffset.Y() + OutputRect.Bottom())) < 2000)
1135                     OutputRect.Bottom() -= 2000 - (aPrtPaperSize.Height() -
1136                                                 (aPrtPageOffset.Y() + OutputRect.Bottom()));
1137 
1138                 // set minimum left and right border
1139                 if (aPrtPageOffset.X() < 2500)
1140                     OutputRect.Left() += 2500 - aPrtPageOffset.X();
1141                 if ((aPrtPaperSize.Width() - (aPrtPageOffset.X() + OutputRect.Right())) < 1500)
1142                     OutputRect.Right() -= 1500 - (aPrtPaperSize.Width() -
1143                                                 (aPrtPageOffset.X() + OutputRect.Right()));
1144 
1145                 if (!m_pPrintUIOptions)
1146                     m_pPrintUIOptions = new SmPrintUIOptions();
1147                 m_pPrintUIOptions->processProperties( rxOptions );
1148 
1149                 pView->Impl_Print( *pOut, *m_pPrintUIOptions, Rectangle( OutputRect ), Point() );
1150 
1151                 // release SmPrintUIOptions when everything is done.
1152                 // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
1153                 if (m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ))
1154                 {
1155                     delete m_pPrintUIOptions;   m_pPrintUIOptions = 0;
1156                 }
1157             }
1158         }
1159     }
1160 }
1161 
setParent(const uno::Reference<uno::XInterface> & xParent)1162 void SAL_CALL SmModel::setParent( const uno::Reference< uno::XInterface >& xParent)
1163         throw( lang::NoSupportException, uno::RuntimeException )
1164 {
1165     ::vos::OGuard aGuard( Application::GetSolarMutex() );
1166     SfxBaseModel::setParent( xParent );
1167     uno::Reference< lang::XUnoTunnel > xParentTunnel( xParent, uno::UNO_QUERY );
1168     if ( xParentTunnel.is() )
1169     {
1170         SvGlobalName aSfxIdent( SFX_GLOBAL_CLASSID );
1171         SfxObjectShell* pDoc = reinterpret_cast<SfxObjectShell *>(xParentTunnel->getSomething(
1172                                         uno::Sequence< sal_Int8 >( aSfxIdent.GetByteSequence() ) ) );
1173         if ( pDoc )
1174             GetObjectShell()->OnDocumentPrinterChanged( pDoc->GetDocumentPrinter() );
1175     }
1176 }
1177 
1178