LCOV - code coverage report
Current view: top level - starmath/source - unomodel.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 305 535 57.0 %
Date: 2014-11-03 Functions: 26 31 83.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10