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 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 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 //----------------------------------------------------------------------- 325 SmModel::SmModel( SfxObjectShell *pObjSh ) 326 : SfxBaseModel(pObjSh) 327 , PropertySetHelper ( lcl_createModelPropertyInfo () ) 328 , m_pPrintUIOptions( NULL ) 329 330 { 331 } 332 //----------------------------------------------------------------------- 333 SmModel::~SmModel() throw () 334 { 335 delete m_pPrintUIOptions; 336 } 337 /*-- 28.03.00 14:18:17--------------------------------------------------- 338 339 -----------------------------------------------------------------------*/ 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 -----------------------------------------------------------------------*/ 360 void SAL_CALL SmModel::acquire() throw() 361 { 362 OWeakObject::acquire(); 363 } 364 /*-- 28.03.00 14:18:18--------------------------------------------------- 365 366 -----------------------------------------------------------------------*/ 367 void SAL_CALL SmModel::release() throw() 368 { 369 OWeakObject::release(); 370 } 371 /*-- 28.03.00 14:18:19--------------------------------------------------- 372 373 -----------------------------------------------------------------------*/ 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 ---------------------------------------------------------------------------*/ 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 ---------------------------------------------------------------------------*/ 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 -----------------------------------------------------------------------*/ 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 443 OUString SmModel::getImplementationName(void) throw( uno::RuntimeException ) 444 { 445 return getImplementationName_Static(); 446 } 447 448 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 -----------------------------------------------------------------------*/ 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 -----------------------------------------------------------------------*/ 467 uno::Sequence< OUString > SmModel::getSupportedServiceNames(void) throw( uno::RuntimeException ) 468 { 469 return getSupportedServiceNames_Static(); 470 } 471 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 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 0 703 }; 704 SfxItemSet *pItemSet = new SfxItemSet( pDocSh->GetPool(), nRange ); 705 SmModule *pp = SM_MOD(); 706 pp->GetConfig()->ConfigToItemSet(*pItemSet); 707 SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet ); 708 709 pDocSh->SetPrinter( pPrinter ); 710 } 711 else 712 throw IllegalArgumentException(); 713 } 714 break; 715 case HANDLE_SYMBOLS: 716 { 717 // this is set 718 Sequence < SymbolDescriptor > aSequence; 719 if ( *pValues >>= aSequence ) 720 { 721 sal_uInt32 nSize = aSequence.getLength(); 722 SmModule *pp = SM_MOD(); 723 SmSymbolManager &rManager = pp->GetSymbolManager(); 724 SymbolDescriptor *pDescriptor = aSequence.getArray(); 725 for (sal_uInt32 i = 0; i < nSize ; i++, pDescriptor++) 726 { 727 Font aFont; 728 aFont.SetName ( pDescriptor->sFontName ); 729 aFont.SetCharSet ( static_cast < rtl_TextEncoding > (pDescriptor->nCharSet) ); 730 aFont.SetFamily ( static_cast < FontFamily > (pDescriptor->nFamily ) ); 731 aFont.SetPitch ( static_cast < FontPitch > (pDescriptor->nPitch ) ); 732 aFont.SetWeight ( static_cast < FontWeight > (pDescriptor->nWeight ) ); 733 aFont.SetItalic ( static_cast < FontItalic > (pDescriptor->nItalic ) ); 734 SmSym aSymbol ( pDescriptor->sName, aFont, static_cast < sal_Unicode > (pDescriptor->nCharacter), 735 pDescriptor->sSymbolSet ); 736 aSymbol.SetExportName ( pDescriptor->sExportName ); 737 aSymbol.SetDocSymbol( sal_True ); 738 rManager.AddOrReplaceSymbol ( aSymbol ); 739 } 740 } 741 else 742 throw IllegalArgumentException(); 743 } 744 break; 745 // --> PB 2004-08-25 #i33095# Security Options 746 case HANDLE_LOAD_READONLY : 747 { 748 if ( (*pValues).getValueType() != ::getBooleanCppuType() ) 749 throw IllegalArgumentException(); 750 sal_Bool bReadonly = sal_False; 751 if ( *pValues >>= bReadonly ) 752 pDocSh->SetLoadReadonly( bReadonly ); 753 break; 754 } 755 // <-- 756 } 757 } 758 759 pDocSh->SetFormat( aFormat ); 760 761 // #i67283# since about all of the above changes are likely to change 762 // the formula size we have to recalculate the vis-area now 763 pDocSh->SetVisArea( Rectangle( Point(0, 0), pDocSh->GetSize() ) ); 764 } 765 766 void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValue ) 767 throw( UnknownPropertyException, WrappedTargetException ) 768 { 769 SmDocShell *pDocSh = static_cast < SmDocShell * > (GetObjectShell()); 770 771 if ( NULL == pDocSh ) 772 throw UnknownPropertyException(); 773 774 const SmFormat & aFormat = pDocSh->GetFormat(); 775 776 for (; *ppEntries; ppEntries++, pValue++ ) 777 { 778 switch ( (*ppEntries)->mnHandle ) 779 { 780 case HANDLE_FORMULA: 781 *pValue <<= OUString(pDocSh->GetText()); 782 break; 783 case HANDLE_FONT_NAME_VARIABLES : 784 case HANDLE_FONT_NAME_FUNCTIONS : 785 case HANDLE_FONT_NAME_NUMBERS : 786 case HANDLE_FONT_NAME_TEXT : 787 case HANDLE_CUSTOM_FONT_NAME_SERIF : 788 case HANDLE_CUSTOM_FONT_NAME_SANS : 789 case HANDLE_CUSTOM_FONT_NAME_FIXED : 790 { 791 const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId); 792 *pValue <<= OUString(rFace.GetName()); 793 } 794 break; 795 case HANDLE_CUSTOM_FONT_FIXED_POSTURE: 796 case HANDLE_CUSTOM_FONT_SANS_POSTURE : 797 case HANDLE_CUSTOM_FONT_SERIF_POSTURE: 798 case HANDLE_FONT_VARIABLES_POSTURE : 799 case HANDLE_FONT_FUNCTIONS_POSTURE : 800 case HANDLE_FONT_NUMBERS_POSTURE : 801 case HANDLE_FONT_TEXT_POSTURE : 802 { 803 const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId); 804 sal_Bool bVal = IsItalic( rFace ); 805 (*pValue).setValue(&bVal, *(*ppEntries)->mpType); 806 } 807 break; 808 case HANDLE_CUSTOM_FONT_FIXED_WEIGHT : 809 case HANDLE_CUSTOM_FONT_SANS_WEIGHT : 810 case HANDLE_CUSTOM_FONT_SERIF_WEIGHT : 811 case HANDLE_FONT_VARIABLES_WEIGHT : 812 case HANDLE_FONT_FUNCTIONS_WEIGHT : 813 case HANDLE_FONT_NUMBERS_WEIGHT : 814 case HANDLE_FONT_TEXT_WEIGHT : 815 { 816 const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId); 817 sal_Bool bVal = IsBold( rFace ); // bold? 818 (*pValue).setValue(&bVal, *(*ppEntries)->mpType); 819 } 820 break; 821 case HANDLE_BASE_FONT_HEIGHT : 822 { 823 // Point! 824 sal_Int16 nVal = static_cast < sal_Int16 > (aFormat.GetBaseSize().Height()); 825 nVal = static_cast < sal_Int16 > (MM100_TO_TWIP(nVal)); 826 nVal = (nVal + 10) / 20; 827 *pValue <<= nVal; 828 } 829 break; 830 case HANDLE_RELATIVE_FONT_HEIGHT_TEXT : 831 case HANDLE_RELATIVE_FONT_HEIGHT_INDICES : 832 case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS : 833 case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS : 834 case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS : 835 *pValue <<= (sal_Int16) aFormat.GetRelSize((*ppEntries)->mnMemberId); 836 break; 837 838 case HANDLE_IS_TEXT_MODE : 839 { 840 sal_Bool bVal = aFormat.IsTextmode(); 841 (*pValue).setValue(&bVal, ::getBooleanCppuType()); 842 } 843 break; 844 845 case HANDLE_GREEK_CHAR_STYLE : 846 *pValue <<= (sal_Int16)aFormat.GetGreekCharStyle(); 847 break; 848 849 case HANDLE_ALIGNMENT : 850 // SmHorAlign uses the same values as HorizontalAlignment 851 *pValue <<= (sal_Int16)aFormat.GetHorAlign(); 852 break; 853 854 case HANDLE_RELATIVE_SPACING : 855 case HANDLE_RELATIVE_LINE_SPACING : 856 case HANDLE_RELATIVE_ROOT_SPACING : 857 case HANDLE_RELATIVE_INDEX_SUPERSCRIPT : 858 case HANDLE_RELATIVE_INDEX_SUBSCRIPT : 859 case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT : 860 case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH: 861 case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH: 862 case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT : 863 case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE : 864 case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE : 865 case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE : 866 case HANDLE_RELATIVE_BRACKET_DISTANCE : 867 case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE : 868 case HANDLE_RELATIVE_MATRIX_LINE_SPACING : 869 case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING : 870 case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT : 871 case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT : 872 case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE : 873 case HANDLE_RELATIVE_OPERATOR_SPACING : 874 case HANDLE_LEFT_MARGIN : 875 case HANDLE_RIGHT_MARGIN : 876 case HANDLE_TOP_MARGIN : 877 case HANDLE_BOTTOM_MARGIN : 878 *pValue <<= (sal_Int16)aFormat.GetDistance((*ppEntries)->mnMemberId); 879 break; 880 case HANDLE_IS_SCALE_ALL_BRACKETS : 881 { 882 sal_Bool bVal = aFormat.IsScaleNormalBrackets(); 883 (*pValue).setValue(&bVal, ::getBooleanCppuType()); 884 } 885 break; 886 case HANDLE_PRINTER_NAME: 887 { 888 SfxPrinter *pPrinter = pDocSh->GetPrinter ( ); 889 *pValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString(); 890 } 891 break; 892 case HANDLE_PRINTER_SETUP: 893 { 894 SfxPrinter *pPrinter = pDocSh->GetPrinter (); 895 if (pPrinter) 896 { 897 SvMemoryStream aStream; 898 pPrinter->Store( aStream ); 899 aStream.Seek ( STREAM_SEEK_TO_END ); 900 sal_uInt32 nSize = aStream.Tell(); 901 aStream.Seek ( STREAM_SEEK_TO_BEGIN ); 902 Sequence < sal_Int8 > aSequence ( nSize ); 903 aStream.Read ( aSequence.getArray(), nSize ); 904 *pValue <<= aSequence; 905 } 906 } 907 break; 908 case HANDLE_SYMBOLS: 909 case HANDLE_USED_SYMBOLS: 910 { 911 const bool bUsedSymbolsOnly = (*ppEntries)->mnHandle == HANDLE_USED_SYMBOLS; 912 const std::set< rtl::OUString > &rUsedSymbols = pDocSh->GetUsedSymbols(); 913 914 // this is get 915 SmModule *pp = SM_MOD(); 916 const SmSymbolManager &rManager = pp->GetSymbolManager(); 917 vector < const SmSym * > aVector; 918 919 const SymbolPtrVec_t aSymbols( rManager.GetSymbols() ); 920 size_t nCount = 0; 921 for (size_t i = 0; i < aSymbols.size(); ++i) 922 { 923 const SmSym * pSymbol = aSymbols[ i ]; 924 const bool bIsUsedSymbol = rUsedSymbols.find( pSymbol->GetName() ) != rUsedSymbols.end(); 925 if (pSymbol && !pSymbol->IsPredefined() && 926 (!bUsedSymbolsOnly || bIsUsedSymbol)) 927 { 928 aVector.push_back ( pSymbol ); 929 nCount++; 930 } 931 } 932 Sequence < SymbolDescriptor > aSequence ( nCount ); 933 SymbolDescriptor * pDescriptor = aSequence.getArray(); 934 935 vector < const SmSym * >::const_iterator aIter = aVector.begin(), aEnd = aVector.end(); 936 for(; aIter != aEnd; pDescriptor++, aIter++) 937 { 938 pDescriptor->sName = (*aIter)->GetName(); 939 pDescriptor->sExportName = (*aIter)->GetExportName(); 940 pDescriptor->sSymbolSet = (*aIter)->GetSymbolSetName(); 941 pDescriptor->nCharacter = static_cast < sal_Int32 > ((*aIter)->GetCharacter()); 942 943 Font rFont = (*aIter)->GetFace(); 944 pDescriptor->sFontName = rFont.GetName(); 945 pDescriptor->nCharSet = sal::static_int_cast< sal_Int16 >(rFont.GetCharSet()); 946 pDescriptor->nFamily = sal::static_int_cast< sal_Int16 >(rFont.GetFamily()); 947 pDescriptor->nPitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch()); 948 pDescriptor->nWeight = sal::static_int_cast< sal_Int16 >(rFont.GetWeight()); 949 pDescriptor->nItalic = sal::static_int_cast< sal_Int16 >(rFont.GetItalic()); 950 } 951 *pValue <<= aSequence; 952 } 953 break; 954 case HANDLE_BASIC_LIBRARIES: 955 *pValue <<= pDocSh->GetBasicContainer(); 956 break; 957 case HANDLE_DIALOG_LIBRARIES: 958 *pValue <<= pDocSh->GetDialogContainer(); 959 break; 960 case HANDLE_RUNTIME_UID: 961 *pValue <<= getRuntimeUID(); 962 break; 963 // --> PB 2004-08-25 #i33095# Security Options 964 case HANDLE_LOAD_READONLY : 965 { 966 *pValue <<= pDocSh->IsLoadReadonly(); 967 break; 968 } 969 // <-- 970 // --> 3.7.2010 #i972# 971 case HANDLE_BASELINE: 972 { 973 if ( !pDocSh->pTree ) 974 pDocSh->Parse(); 975 if ( pDocSh->pTree ) 976 { 977 if ( !pDocSh->IsFormulaArranged() ) 978 pDocSh->ArrangeFormula(); 979 980 *pValue <<= static_cast<sal_Int32>( pDocSh->pTree->GetFormulaBaseline() ); 981 } 982 } 983 break; 984 // <-- 985 } 986 } 987 } 988 989 ////////////////////////////////////////////////////////////////////// 990 991 sal_Int32 SAL_CALL SmModel::getRendererCount( 992 const uno::Any& /*rSelection*/, 993 const uno::Sequence< beans::PropertyValue >& /*xOptions*/ ) 994 throw (IllegalArgumentException, RuntimeException) 995 { 996 ::vos::OGuard aGuard(Application::GetSolarMutex()); 997 return 1; 998 } 999 1000 1001 static Size lcl_GuessPaperSize() 1002 { 1003 Size aRes; 1004 Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() ); 1005 LocaleDataWrapper aLocWrp( xMgr, AllSettings().GetLocale() ); 1006 if( MEASURE_METRIC == aLocWrp.getMeasurementSystemEnum() ) 1007 { 1008 // in 100th mm 1009 PaperInfo aInfo( PAPER_A4 ); 1010 aRes.Width() = aInfo.getWidth(); 1011 aRes.Height() = aInfo.getHeight(); 1012 } 1013 else 1014 { 1015 // in 100th mm 1016 PaperInfo aInfo( PAPER_LETTER ); 1017 aRes.Width() = aInfo.getWidth(); 1018 aRes.Height() = aInfo.getHeight(); 1019 } 1020 return aRes; 1021 } 1022 1023 uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( 1024 sal_Int32 nRenderer, 1025 const uno::Any& /*rSelection*/, 1026 const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ ) 1027 throw (IllegalArgumentException, RuntimeException) 1028 { 1029 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1030 1031 if (0 != nRenderer) 1032 throw IllegalArgumentException(); 1033 1034 SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() ); 1035 if (!pDocSh) 1036 throw RuntimeException(); 1037 1038 SmPrinterAccess aPrinterAccess( *pDocSh ); 1039 Printer *pPrinter = aPrinterAccess.GetPrinter(); 1040 //Point aPrtPageOffset( pPrinter->GetPageOffset() ); 1041 Size aPrtPaperSize ( pPrinter->GetPaperSize() ); 1042 1043 // if paper size is 0 (usually if no 'real' printer is found), 1044 // guess the paper size 1045 if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0) 1046 aPrtPaperSize = lcl_GuessPaperSize(); 1047 awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() ); 1048 1049 uno::Sequence< beans::PropertyValue > aRenderer(1); 1050 PropertyValue &rValue = aRenderer.getArray()[0]; 1051 rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); 1052 rValue.Value <<= aPageSize; 1053 1054 if (!m_pPrintUIOptions) 1055 m_pPrintUIOptions = new SmPrintUIOptions(); 1056 m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); 1057 1058 return aRenderer; 1059 } 1060 1061 void SAL_CALL SmModel::render( 1062 sal_Int32 nRenderer, 1063 const uno::Any& rSelection, 1064 const uno::Sequence< beans::PropertyValue >& rxOptions ) 1065 throw (IllegalArgumentException, RuntimeException) 1066 { 1067 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1068 1069 if (0 != nRenderer) 1070 throw IllegalArgumentException(); 1071 1072 SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() ); 1073 if (!pDocSh) 1074 throw RuntimeException(); 1075 1076 // get device to be rendered in 1077 uno::Reference< awt::XDevice > xRenderDevice; 1078 for (sal_Int32 i = 0, nCount = rxOptions.getLength(); i < nCount; ++i) 1079 { 1080 if( rxOptions[i].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) 1081 rxOptions[i].Value >>= xRenderDevice; 1082 } 1083 1084 if (xRenderDevice.is()) 1085 { 1086 VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); 1087 OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL; 1088 1089 if (!pOut) 1090 throw RuntimeException(); 1091 1092 pOut->SetMapMode( MAP_100TH_MM ); 1093 1094 uno::Reference< frame::XModel > xModel; 1095 rSelection >>= xModel; 1096 if (xModel == pDocSh->GetModel()) 1097 { 1098 //!! when called via API we may not have an active view 1099 //!! thus we go and look for a view that can be used. 1100 const TypeId aTypeId = TYPE( SmViewShell ); 1101 SfxViewShell* pViewSh = SfxViewShell::GetFirst( &aTypeId, sal_False /* search non-visible views as well*/ ); 1102 while (pViewSh && pViewSh->GetObjectShell() != pDocSh) 1103 pViewSh = SfxViewShell::GetNext( *pViewSh, &aTypeId, sal_False /* search non-visible views as well*/ ); 1104 SmViewShell *pView = PTR_CAST( SmViewShell, pViewSh ); 1105 DBG_ASSERT( pView, "SmModel::render : no SmViewShell found" ); 1106 1107 if (pView) 1108 { 1109 SmPrinterAccess aPrinterAccess( *pDocSh ); 1110 Printer *pPrinter = aPrinterAccess.GetPrinter(); 1111 1112 Size aPrtPaperSize ( pPrinter->GetPaperSize() ); 1113 Size aOutputSize ( pPrinter->GetOutputSize() ); 1114 Point aPrtPageOffset( pPrinter->GetPageOffset() ); 1115 1116 // no real printer ?? 1117 if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0) 1118 { 1119 aPrtPaperSize = lcl_GuessPaperSize(); 1120 // factors from Windows DIN A4 1121 aOutputSize = Size( (long)(aPrtPaperSize.Width() * 0.941), 1122 (long)(aPrtPaperSize.Height() * 0.961)); 1123 aPrtPageOffset = Point( (long)(aPrtPaperSize.Width() * 0.0250), 1124 (long)(aPrtPaperSize.Height() * 0.0214)); 1125 } 1126 Point aZeroPoint; 1127 Rectangle OutputRect( aZeroPoint, aOutputSize ); 1128 1129 1130 // set minimum top and bottom border 1131 if (aPrtPageOffset.Y() < 2000) 1132 OutputRect.Top() += 2000 - aPrtPageOffset.Y(); 1133 if ((aPrtPaperSize.Height() - (aPrtPageOffset.Y() + OutputRect.Bottom())) < 2000) 1134 OutputRect.Bottom() -= 2000 - (aPrtPaperSize.Height() - 1135 (aPrtPageOffset.Y() + OutputRect.Bottom())); 1136 1137 // set minimum left and right border 1138 if (aPrtPageOffset.X() < 2500) 1139 OutputRect.Left() += 2500 - aPrtPageOffset.X(); 1140 if ((aPrtPaperSize.Width() - (aPrtPageOffset.X() + OutputRect.Right())) < 1500) 1141 OutputRect.Right() -= 1500 - (aPrtPaperSize.Width() - 1142 (aPrtPageOffset.X() + OutputRect.Right())); 1143 1144 if (!m_pPrintUIOptions) 1145 m_pPrintUIOptions = new SmPrintUIOptions(); 1146 m_pPrintUIOptions->processProperties( rxOptions ); 1147 1148 pView->Impl_Print( *pOut, *m_pPrintUIOptions, Rectangle( OutputRect ), Point() ); 1149 1150 // release SmPrintUIOptions when everything is done. 1151 // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor. 1152 if (m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False )) 1153 { 1154 delete m_pPrintUIOptions; m_pPrintUIOptions = 0; 1155 } 1156 } 1157 } 1158 } 1159 } 1160 1161 void SAL_CALL SmModel::setParent( const uno::Reference< uno::XInterface >& xParent) 1162 throw( lang::NoSupportException, uno::RuntimeException ) 1163 { 1164 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1165 SfxBaseModel::setParent( xParent ); 1166 uno::Reference< lang::XUnoTunnel > xParentTunnel( xParent, uno::UNO_QUERY ); 1167 if ( xParentTunnel.is() ) 1168 { 1169 SvGlobalName aSfxIdent( SFX_GLOBAL_CLASSID ); 1170 SfxObjectShell* pDoc = reinterpret_cast<SfxObjectShell *>(xParentTunnel->getSomething( 1171 uno::Sequence< sal_Int8 >( aSfxIdent.GetByteSequence() ) ) ); 1172 if ( pDoc ) 1173 GetObjectShell()->OnDocumentPrinterChanged( pDoc->GetDocumentPrinter() ); 1174 } 1175 } 1176 1177