1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "scitems.hxx" 32*cdf0e10cSrcweir #include <svx/fmdpage.hxx> 33*cdf0e10cSrcweir #include <svx/fmview.hxx> 34*cdf0e10cSrcweir #include <svx/svditer.hxx> 35*cdf0e10cSrcweir #include <svx/svdpage.hxx> 36*cdf0e10cSrcweir #include <svx/svxids.hrc> 37*cdf0e10cSrcweir #include <svx/unoshape.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <svl/numuno.hxx> 40*cdf0e10cSrcweir #include <svl/smplhint.hxx> 41*cdf0e10cSrcweir #include <unotools/undoopt.hxx> 42*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 43*cdf0e10cSrcweir #include <sfx2/printer.hxx> 44*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 45*cdf0e10cSrcweir #include <vcl/pdfextoutdevdata.hxx> 46*cdf0e10cSrcweir #include <vcl/waitobj.hxx> 47*cdf0e10cSrcweir #include <unotools/charclass.hxx> 48*cdf0e10cSrcweir #include <tools/multisel.hxx> 49*cdf0e10cSrcweir #include <tools/resary.hxx> 50*cdf0e10cSrcweir #include <toolkit/awt/vclxdevice.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <ctype.h> 53*cdf0e10cSrcweir #include <float.h> // DBL_MAX 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/sheet/XNamedRanges.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/sheet/XLabelRanges.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/i18n/XForbiddenCharacters.hpp> 59*cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp> 60*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> 62*cdf0e10cSrcweir #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> 63*cdf0e10cSrcweir #include <com/sun/star/script/XInvocation.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> 65*cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlClassProvider.hpp> 66*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir #include "docuno.hxx" 69*cdf0e10cSrcweir #include "cellsuno.hxx" 70*cdf0e10cSrcweir #include "nameuno.hxx" 71*cdf0e10cSrcweir #include "datauno.hxx" 72*cdf0e10cSrcweir #include "miscuno.hxx" 73*cdf0e10cSrcweir #include "notesuno.hxx" 74*cdf0e10cSrcweir #include "styleuno.hxx" 75*cdf0e10cSrcweir #include "linkuno.hxx" 76*cdf0e10cSrcweir #include "servuno.hxx" 77*cdf0e10cSrcweir #include "targuno.hxx" 78*cdf0e10cSrcweir #include "convuno.hxx" 79*cdf0e10cSrcweir #include "optuno.hxx" 80*cdf0e10cSrcweir #include "forbiuno.hxx" 81*cdf0e10cSrcweir #include "docsh.hxx" 82*cdf0e10cSrcweir #include "hints.hxx" 83*cdf0e10cSrcweir #include "docfunc.hxx" 84*cdf0e10cSrcweir #include "dociter.hxx" 85*cdf0e10cSrcweir #include "cell.hxx" 86*cdf0e10cSrcweir #include "drwlayer.hxx" 87*cdf0e10cSrcweir #include "rangeutl.hxx" 88*cdf0e10cSrcweir #include "markdata.hxx" 89*cdf0e10cSrcweir #include "docoptio.hxx" 90*cdf0e10cSrcweir #include "scextopt.hxx" 91*cdf0e10cSrcweir #include "unoguard.hxx" 92*cdf0e10cSrcweir #include "unonames.hxx" 93*cdf0e10cSrcweir #include "shapeuno.hxx" 94*cdf0e10cSrcweir #include "viewuno.hxx" 95*cdf0e10cSrcweir #include "tabvwsh.hxx" 96*cdf0e10cSrcweir #include "printfun.hxx" 97*cdf0e10cSrcweir #include "pfuncache.hxx" 98*cdf0e10cSrcweir #include "scmod.hxx" 99*cdf0e10cSrcweir #include "rangeutl.hxx" 100*cdf0e10cSrcweir #include "ViewSettingsSequenceDefines.hxx" 101*cdf0e10cSrcweir #include "sheetevents.hxx" 102*cdf0e10cSrcweir #include "sc.hrc" 103*cdf0e10cSrcweir #include "scresid.hxx" 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir using namespace com::sun::star; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // #i111553# provides the name of the VBA constant for this document type (e.g. 'ThisExcelDoc' for Calc) 108*cdf0e10cSrcweir #define SC_UNO_VBAGLOBNAME "VBAGlobalConstantName" 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir //------------------------------------------------------------------------ 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // alles ohne Which-ID, Map nur fuer PropertySetInfo 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir //! umbenennen, sind nicht mehr nur Options 115*cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap() 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir static SfxItemPropertyMapEntry aDocOptPropertyMap_Impl[] = 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_APPLYFMDES), 0, &getBooleanCppuType(), 0, 0}, 120*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_AREALINKS), 0, &getCppuType((uno::Reference<sheet::XAreaLinks>*)0), 0, 0}, 121*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC), 0, &getBooleanCppuType(), 0, 0}, 122*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, 123*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, 124*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_VBAGLOBNAME), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), beans::PropertyAttribute::READONLY, 0}, 125*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN, &getBooleanCppuType(), 0, 0}, 126*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, 127*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, 128*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, 129*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_COLLABELRNG), 0, &getCppuType((uno::Reference<sheet::XLabelRanges>*)0), 0, 0}, 130*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_DDELINKS), 0, &getCppuType((uno::Reference<container::XNameAccess>*)0), 0, 0}, 131*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_DEFTABSTOP), PROP_UNO_DEFTABSTOP, &getCppuType((sal_Int16*)0), 0, 0}, 132*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_EXTERNALDOCLINKS), 0, &getCppuType((uno::Reference<sheet::XExternalDocLinks>*)0), 0, 0}, 133*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_FORBIDDEN), 0, &getCppuType((uno::Reference<i18n::XForbiddenCharacters>*)0), beans::PropertyAttribute::READONLY, 0}, 134*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_HASDRAWPAGES), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, 135*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_IGNORECASE), PROP_UNO_IGNORECASE, &getBooleanCppuType(), 0, 0}, 136*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ITERENABLED), PROP_UNO_ITERENABLED, &getBooleanCppuType(), 0, 0}, 137*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ITERCOUNT), PROP_UNO_ITERCOUNT, &getCppuType((sal_Int32*)0), 0, 0}, 138*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ITEREPSILON), PROP_UNO_ITEREPSILON, &getCppuType((double*)0), 0, 0}, 139*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS, &getBooleanCppuType(), 0, 0}, 140*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_MATCHWHOLE), PROP_UNO_MATCHWHOLE, &getBooleanCppuType(), 0, 0}, 141*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_NAMEDRANGES), 0, &getCppuType((uno::Reference<sheet::XNamedRanges>*)0), 0, 0}, 142*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_DATABASERNG), 0, &getCppuType((uno::Reference<sheet::XDatabaseRanges>*)0), 0, 0}, 143*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_NULLDATE), PROP_UNO_NULLDATE, &getCppuType((util::Date*)0), 0, 0}, 144*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ROWLABELRNG), 0, &getCppuType((uno::Reference<sheet::XLabelRanges>*)0), 0, 0}, 145*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_SHEETLINKS), 0, &getCppuType((uno::Reference<container::XNameAccess>*)0), 0, 0}, 146*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_SPELLONLINE), PROP_UNO_SPELLONLINE, &getBooleanCppuType(), 0, 0}, 147*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_STANDARDDEC), PROP_UNO_STANDARDDEC, &getCppuType((sal_Int16*)0), 0, 0}, 148*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED, &getBooleanCppuType(), 0, 0}, 149*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_RUNTIMEUID), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), beans::PropertyAttribute::READONLY, 0}, 150*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_HASVALIDSIGNATURES),0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, 151*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ISLOADED), 0, &getBooleanCppuType(), 0, 0}, 152*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ISUNDOENABLED), 0, &getBooleanCppuType(), 0, 0}, 153*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ISADJUSTHEIGHTENABLED), 0, &getBooleanCppuType(), 0, 0}, 154*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ISEXECUTELINKENABLED), 0, &getBooleanCppuType(), 0, 0}, 155*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_ISCHANGEREADONLYENABLED), 0, &getBooleanCppuType(), 0, 0}, 156*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_REFERENCEDEVICE), 0, &getCppuType((uno::Reference<awt::XDevice>*)0), beans::PropertyAttribute::READONLY, 0}, 157*cdf0e10cSrcweir {MAP_CHAR_LEN("BuildId"), 0, &::getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, 158*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CODENAME), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir {0,0,0,0,0,0} 161*cdf0e10cSrcweir }; 162*cdf0e10cSrcweir return aDocOptPropertyMap_Impl; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir //! StandardDecimals als Property und vom NumberFormatter ???????? 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetColumnsPropertyMap() 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir static SfxItemPropertyMapEntry aColumnsPropertyMap_Impl[] = 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), 0, &getBooleanCppuType(), 0, 0 }, 172*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), 0, &getBooleanCppuType(), 0, 0 }, 173*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), 0, &getBooleanCppuType(), 0, 0 }, 174*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_OWIDTH), 0, &getBooleanCppuType(), 0, 0 }, 175*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CELLWID), 0, &getCppuType((sal_Int32*)0), 0, 0 }, 176*cdf0e10cSrcweir {0,0,0,0,0,0} 177*cdf0e10cSrcweir }; 178*cdf0e10cSrcweir return aColumnsPropertyMap_Impl; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetRowsPropertyMap() 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir static SfxItemPropertyMapEntry aRowsPropertyMap_Impl[] = 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CELLHGT), 0, &getCppuType((sal_Int32*)0), 0, 0 }, 186*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), 0, &getBooleanCppuType(), 0, 0 }, 187*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_OHEIGHT), 0, &getBooleanCppuType(), 0, 0 }, 188*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), 0, &getBooleanCppuType(), 0, 0 }, 189*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), 0, &getBooleanCppuType(), 0, 0 }, 190*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), 0, &getBooleanCppuType(), 0, 0 }, 191*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR }, 192*cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT }, 193*cdf0e10cSrcweir // not sorted, not used with SfxItemPropertyMapEntry::GetByName 194*cdf0e10cSrcweir {0,0,0,0,0,0} 195*cdf0e10cSrcweir }; 196*cdf0e10cSrcweir return aRowsPropertyMap_Impl; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir //! move these functions to a header file 200*cdf0e10cSrcweir inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; } 201*cdf0e10cSrcweir inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir //------------------------------------------------------------------------ 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir #define SCMODELOBJ_SERVICE "com.sun.star.sheet.SpreadsheetDocument" 206*cdf0e10cSrcweir #define SCDOCSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetDocumentSettings" 207*cdf0e10cSrcweir #define SCDOC_SERVICE "com.sun.star.document.OfficeDocument" 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScAnnotationsObj, "ScAnnotationsObj", "com.sun.star.sheet.CellAnnotations" ) 210*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScDrawPagesObj, "ScDrawPagesObj", "com.sun.star.drawing.DrawPages" ) 211*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScScenariosObj, "ScScenariosObj", "com.sun.star.sheet.Scenarios" ) 212*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettingsObj, "ScSpreadsheetSettingsObj", "com.sun.star.sheet.SpreadsheetDocumentSettings" ) 213*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScTableColumnsObj, "ScTableColumnsObj", "com.sun.star.table.TableColumns" ) 214*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScTableRowsObj, "ScTableRowsObj", "com.sun.star.table.TableRows" ) 215*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScTableSheetsObj, "ScTableSheetsObj", "com.sun.star.sheet.Spreadsheets" ) 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir //------------------------------------------------------------------------ 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir class ScPrintUIOptions : public vcl::PrinterOptionsHelper 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir public: 222*cdf0e10cSrcweir ScPrintUIOptions(); 223*cdf0e10cSrcweir void SetDefaults(); 224*cdf0e10cSrcweir }; 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir ScPrintUIOptions::ScPrintUIOptions() 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir const ScPrintOptions& rPrintOpt = SC_MOD()->GetPrintOptions(); 229*cdf0e10cSrcweir sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1; 230*cdf0e10cSrcweir sal_Bool bSuppress = rPrintOpt.GetSkipEmpty(); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir ResStringArray aStrings( ScResId( SCSTR_PRINT_OPTIONS ) ); 233*cdf0e10cSrcweir DBG_ASSERT( aStrings.Count() >= 10, "resource incomplete" ); 234*cdf0e10cSrcweir if( aStrings.Count() < 10 ) // bad resource ? 235*cdf0e10cSrcweir return; 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir m_aUIProperties.realloc( 8 ); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir // create Section for spreadsheet (results in an extra tab page in dialog) 240*cdf0e10cSrcweir SvtModuleOptions aOpt; 241*cdf0e10cSrcweir String aAppGroupname( aStrings.GetString( 9 ) ); 242*cdf0e10cSrcweir aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), 243*cdf0e10cSrcweir aOpt.GetModuleName( SvtModuleOptions::E_SCALC ) ); 244*cdf0e10cSrcweir m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TabPage:AppPage" ) ) ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir // create subgroup for pages 247*cdf0e10cSrcweir m_aUIProperties[1].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 0 ) ), rtl::OUString() ); 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir // create a bool option for empty pages 250*cdf0e10cSrcweir m_aUIProperties[2].Value = getBoolControlOpt( rtl::OUString( aStrings.GetString( 1 ) ), 251*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:IsIncludeEmptyPages:CheckBox" ) ), 252*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsIncludeEmptyPages" ) ), 253*cdf0e10cSrcweir ! bSuppress 254*cdf0e10cSrcweir ); 255*cdf0e10cSrcweir // create Subgroup for print content 256*cdf0e10cSrcweir vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; 257*cdf0e10cSrcweir aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); 258*cdf0e10cSrcweir m_aUIProperties[3].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 2 ) ), 259*cdf0e10cSrcweir rtl::OUString(), 260*cdf0e10cSrcweir aPrintRangeOpt 261*cdf0e10cSrcweir ); 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir // create a choice for the content to create 264*cdf0e10cSrcweir uno::Sequence< rtl::OUString > aChoices( 3 ), aHelpIds( 3 ); 265*cdf0e10cSrcweir aChoices[0] = aStrings.GetString( 3 ); 266*cdf0e10cSrcweir aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0" ) ); 267*cdf0e10cSrcweir aChoices[1] = aStrings.GetString( 4 ); 268*cdf0e10cSrcweir aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1" ) ); 269*cdf0e10cSrcweir aChoices[2] = aStrings.GetString( 5 ); 270*cdf0e10cSrcweir aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2" ) ); 271*cdf0e10cSrcweir m_aUIProperties[4].Value = getChoiceControlOpt( rtl::OUString(), 272*cdf0e10cSrcweir aHelpIds, 273*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ), 274*cdf0e10cSrcweir aChoices, 275*cdf0e10cSrcweir nContent ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir // create Subgroup for print range 278*cdf0e10cSrcweir aPrintRangeOpt.mbInternalOnly = sal_True; 279*cdf0e10cSrcweir m_aUIProperties[5].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 6 ) ), 280*cdf0e10cSrcweir rtl::OUString(), 281*cdf0e10cSrcweir aPrintRangeOpt 282*cdf0e10cSrcweir ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir // create a choice for the range to print 285*cdf0e10cSrcweir rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); 286*cdf0e10cSrcweir aChoices.realloc( 2 ); 287*cdf0e10cSrcweir aHelpIds.realloc( 2 ); 288*cdf0e10cSrcweir aChoices[0] = aStrings.GetString( 7 ); 289*cdf0e10cSrcweir aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:0" ) ); 290*cdf0e10cSrcweir aChoices[1] = aStrings.GetString( 8 ); 291*cdf0e10cSrcweir aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:1" ) ); 292*cdf0e10cSrcweir m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(), 293*cdf0e10cSrcweir aHelpIds, 294*cdf0e10cSrcweir aPrintRangeName, 295*cdf0e10cSrcweir aChoices, 296*cdf0e10cSrcweir 0 ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir // create a an Edit dependent on "Pages" selected 299*cdf0e10cSrcweir vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True ); 300*cdf0e10cSrcweir m_aUIProperties[7].Value = getEditControlOpt( rtl::OUString(), 301*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageRange:Edit" ) ), 302*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), 303*cdf0e10cSrcweir rtl::OUString(), 304*cdf0e10cSrcweir aPageRangeOpt 305*cdf0e10cSrcweir ); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir void ScPrintUIOptions::SetDefaults() 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir // re-initialize the default values from print options 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir const ScPrintOptions& rPrintOpt = SC_MOD()->GetPrintOptions(); 313*cdf0e10cSrcweir sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1; 314*cdf0e10cSrcweir sal_Bool bSuppress = rPrintOpt.GetSkipEmpty(); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir for (sal_Int32 nUIPos=0; nUIPos<m_aUIProperties.getLength(); ++nUIPos) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aUIProp; 319*cdf0e10cSrcweir if ( m_aUIProperties[nUIPos].Value >>= aUIProp ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir for (sal_Int32 nPropPos=0; nPropPos<aUIProp.getLength(); ++nPropPos) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir rtl::OUString aName = aUIProp[nPropPos].Name; 324*cdf0e10cSrcweir if ( aName.equalsAscii("Property") ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir beans::PropertyValue aPropertyValue; 327*cdf0e10cSrcweir if ( aUIProp[nPropPos].Value >>= aPropertyValue ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir if ( aPropertyValue.Name.equalsAscii( "PrintContent" ) ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir aPropertyValue.Value <<= nContent; 332*cdf0e10cSrcweir aUIProp[nPropPos].Value <<= aPropertyValue; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir else if ( aPropertyValue.Name.equalsAscii( "IsIncludeEmptyPages" ) ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aPropertyValue.Value, ! bSuppress ); 337*cdf0e10cSrcweir aUIProp[nPropPos].Value <<= aPropertyValue; 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir m_aUIProperties[nUIPos].Value <<= aUIProp; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir // static 348*cdf0e10cSrcweir void ScModelObj::CreateAndSet(ScDocShell* pDocSh) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir if (pDocSh) 351*cdf0e10cSrcweir pDocSh->SetBaseModel( new ScModelObj(pDocSh) ); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir ScModelObj::ScModelObj( ScDocShell* pDocSh ) : 355*cdf0e10cSrcweir SfxBaseModel( pDocSh ), 356*cdf0e10cSrcweir aPropSet( lcl_GetDocOptPropertyMap() ), 357*cdf0e10cSrcweir pDocShell( pDocSh ), 358*cdf0e10cSrcweir pPrintFuncCache( NULL ), 359*cdf0e10cSrcweir pPrinterOptions( NULL ), 360*cdf0e10cSrcweir maChangesListeners( m_aMutex ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir // pDocShell may be NULL if this is the base of a ScDocOptionsObj 363*cdf0e10cSrcweir if ( pDocShell ) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); // SfxModel is derived from SfxListener 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir ScModelObj::~ScModelObj() 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir if (pDocShell) 372*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir if (xNumberAgg.is()) 375*cdf0e10cSrcweir xNumberAgg->setDelegator(uno::Reference<uno::XInterface>()); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir delete pPrintFuncCache; 378*cdf0e10cSrcweir delete pPrinterOptions; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir uno::Reference< uno::XAggregation> ScModelObj::GetFormatter() 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir // pDocShell may be NULL if this is the base of a ScDocOptionsObj 384*cdf0e10cSrcweir if ( !xNumberAgg.is() && pDocShell ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir // setDelegator veraendert den RefCount, darum eine Referenz selber halten 387*cdf0e10cSrcweir // (direkt am m_refCount, um sich beim release nicht selbst zu loeschen) 388*cdf0e10cSrcweir comphelper::increment( m_refCount ); 389*cdf0e10cSrcweir // waehrend des queryInterface braucht man ein Ref auf das 390*cdf0e10cSrcweir // SvNumberFormatsSupplierObj, sonst wird es geloescht. 391*cdf0e10cSrcweir uno::Reference<util::XNumberFormatsSupplier> xFormatter(new SvNumberFormatsSupplierObj(pDocShell->GetDocument()->GetFormatTable() )); 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir xNumberAgg.set(uno::Reference<uno::XAggregation>( xFormatter, uno::UNO_QUERY )); 394*cdf0e10cSrcweir // extra block to force deletion of the temporary before setDelegator 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir // beim setDelegator darf die zusaetzliche Ref nicht mehr existieren 398*cdf0e10cSrcweir xFormatter = NULL; 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir if (xNumberAgg.is()) 401*cdf0e10cSrcweir xNumberAgg->setDelegator( (cppu::OWeakObject*)this ); 402*cdf0e10cSrcweir comphelper::decrement( m_refCount ); 403*cdf0e10cSrcweir } // if ( !xNumberAgg.is() ) 404*cdf0e10cSrcweir return xNumberAgg; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir ScDocument* ScModelObj::GetDocument() const 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir if (pDocShell) 410*cdf0e10cSrcweir return pDocShell->GetDocument(); 411*cdf0e10cSrcweir return NULL; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir SfxObjectShell* ScModelObj::GetEmbeddedObject() const 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir return pDocShell; 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir void ScModelObj::UpdateAllRowHeights(const ScMarkData* pTabMark, bool bCalcOutputFactor) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir if (pDocShell) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir if (bCalcOutputFactor) 424*cdf0e10cSrcweir pDocShell->CalcOutputFactor(); 425*cdf0e10cSrcweir pDocShell->UpdateAllRowHeights(pTabMark); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir void ScModelObj::BeforeXMLLoading() 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir if (pDocShell) 432*cdf0e10cSrcweir pDocShell->BeforeXMLLoading(); 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir void ScModelObj::AfterXMLLoading(sal_Bool bRet) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir if (pDocShell) 438*cdf0e10cSrcweir pDocShell->AfterXMLLoading(bRet); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir ScSheetSaveData* ScModelObj::GetSheetSaveData() 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir if (pDocShell) 444*cdf0e10cSrcweir return pDocShell->GetSheetSaveData(); 445*cdf0e10cSrcweir return NULL; 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir void ScModelObj::RepaintRange( const ScRange& rRange ) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir if (pDocShell) 451*cdf0e10cSrcweir pDocShell->PostPaint( rRange, PAINT_GRID ); 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType ) 455*cdf0e10cSrcweir throw(uno::RuntimeException) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir SC_QUERYINTERFACE( sheet::XSpreadsheetDocument ) 458*cdf0e10cSrcweir SC_QUERYINTERFACE( document::XActionLockable ) 459*cdf0e10cSrcweir SC_QUERYINTERFACE( sheet::XCalculatable ) 460*cdf0e10cSrcweir SC_QUERYINTERFACE( util::XProtectable ) 461*cdf0e10cSrcweir SC_QUERYINTERFACE( drawing::XDrawPagesSupplier ) 462*cdf0e10cSrcweir SC_QUERYINTERFACE( sheet::XGoalSeek ) 463*cdf0e10cSrcweir SC_QUERYINTERFACE( sheet::XConsolidatable ) 464*cdf0e10cSrcweir SC_QUERYINTERFACE( sheet::XDocumentAuditing ) 465*cdf0e10cSrcweir SC_QUERYINTERFACE( style::XStyleFamiliesSupplier ) 466*cdf0e10cSrcweir SC_QUERYINTERFACE( view::XRenderable ) 467*cdf0e10cSrcweir SC_QUERYINTERFACE( document::XLinkTargetSupplier ) 468*cdf0e10cSrcweir SC_QUERYINTERFACE( beans::XPropertySet ) 469*cdf0e10cSrcweir SC_QUERYINTERFACE( lang::XMultiServiceFactory ) 470*cdf0e10cSrcweir SC_QUERYINTERFACE( lang::XServiceInfo ) 471*cdf0e10cSrcweir SC_QUERYINTERFACE( util::XChangesNotifier ) 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir uno::Any aRet(SfxBaseModel::queryInterface( rType )); 474*cdf0e10cSrcweir if ( !aRet.hasValue() 475*cdf0e10cSrcweir && rType != ::getCppuType((uno::Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0) 476*cdf0e10cSrcweir && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XController>*)0) 477*cdf0e10cSrcweir && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XFrame>*)0) 478*cdf0e10cSrcweir && rType != ::getCppuType((uno::Reference< com::sun::star::script::XInvocation>*)0) 479*cdf0e10cSrcweir && rType != ::getCppuType((uno::Reference< com::sun::star::reflection::XIdlClassProvider>*)0) 480*cdf0e10cSrcweir && rType != ::getCppuType((uno::Reference< com::sun::star::beans::XFastPropertySet>*)0) 481*cdf0e10cSrcweir && rType != ::getCppuType((uno::Reference< com::sun::star::awt::XWindow>*)0)) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir GetFormatter(); 484*cdf0e10cSrcweir if ( xNumberAgg.is() ) 485*cdf0e10cSrcweir aRet = xNumberAgg->queryAggregation( rType ); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir return aRet; 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir void SAL_CALL ScModelObj::acquire() throw() 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir SfxBaseModel::acquire(); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir void SAL_CALL ScModelObj::release() throw() 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir SfxBaseModel::release(); 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeException) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir static uno::Sequence<uno::Type> aTypes; 504*cdf0e10cSrcweir if ( aTypes.getLength() == 0 ) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir uno::Sequence<uno::Type> aParentTypes(SfxBaseModel::getTypes()); 507*cdf0e10cSrcweir long nParentLen = aParentTypes.getLength(); 508*cdf0e10cSrcweir const uno::Type* pParentPtr = aParentTypes.getConstArray(); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir uno::Sequence<uno::Type> aAggTypes; 511*cdf0e10cSrcweir if ( GetFormatter().is() ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir const uno::Type& rProvType = ::getCppuType((uno::Reference<lang::XTypeProvider>*) 0); 514*cdf0e10cSrcweir uno::Any aNumProv(xNumberAgg->queryAggregation(rProvType)); 515*cdf0e10cSrcweir if(aNumProv.getValueType() == rProvType) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir uno::Reference<lang::XTypeProvider> xNumProv( 518*cdf0e10cSrcweir *(uno::Reference<lang::XTypeProvider>*)aNumProv.getValue()); 519*cdf0e10cSrcweir aAggTypes = xNumProv->getTypes(); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir long nAggLen = aAggTypes.getLength(); 523*cdf0e10cSrcweir const uno::Type* pAggPtr = aAggTypes.getConstArray(); 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir const long nThisLen = 15; 526*cdf0e10cSrcweir aTypes.realloc( nParentLen + nAggLen + nThisLen ); 527*cdf0e10cSrcweir uno::Type* pPtr = aTypes.getArray(); 528*cdf0e10cSrcweir pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetDocument>*)0); 529*cdf0e10cSrcweir pPtr[nParentLen + 1] = getCppuType((const uno::Reference<document::XActionLockable>*)0); 530*cdf0e10cSrcweir pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XCalculatable>*)0); 531*cdf0e10cSrcweir pPtr[nParentLen + 3] = getCppuType((const uno::Reference<util::XProtectable>*)0); 532*cdf0e10cSrcweir pPtr[nParentLen + 4] = getCppuType((const uno::Reference<drawing::XDrawPagesSupplier>*)0); 533*cdf0e10cSrcweir pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XGoalSeek>*)0); 534*cdf0e10cSrcweir pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XConsolidatable>*)0); 535*cdf0e10cSrcweir pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XDocumentAuditing>*)0); 536*cdf0e10cSrcweir pPtr[nParentLen + 8] = getCppuType((const uno::Reference<style::XStyleFamiliesSupplier>*)0); 537*cdf0e10cSrcweir pPtr[nParentLen + 9] = getCppuType((const uno::Reference<view::XRenderable>*)0); 538*cdf0e10cSrcweir pPtr[nParentLen +10] = getCppuType((const uno::Reference<document::XLinkTargetSupplier>*)0); 539*cdf0e10cSrcweir pPtr[nParentLen +11] = getCppuType((const uno::Reference<beans::XPropertySet>*)0); 540*cdf0e10cSrcweir pPtr[nParentLen +12] = getCppuType((const uno::Reference<lang::XMultiServiceFactory>*)0); 541*cdf0e10cSrcweir pPtr[nParentLen +13] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0); 542*cdf0e10cSrcweir pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XChangesNotifier>*)0); 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir long i; 545*cdf0e10cSrcweir for (i=0; i<nParentLen; i++) 546*cdf0e10cSrcweir pPtr[i] = pParentPtr[i]; // parent types first 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir for (i=0; i<nAggLen; i++) 549*cdf0e10cSrcweir pPtr[nParentLen+nThisLen+i] = pAggPtr[i]; // aggregated types last 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir return aTypes; 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL ScModelObj::getImplementationId() 555*cdf0e10cSrcweir throw(uno::RuntimeException) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId; 558*cdf0e10cSrcweir if( aId.getLength() == 0 ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir aId.realloc( 16 ); 561*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir return aId; 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir // Not interested in reference update hints here 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) ) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId(); 573*cdf0e10cSrcweir if ( nId == SFX_HINT_DYING ) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir pDocShell = NULL; // has become invalid 576*cdf0e10cSrcweir if (xNumberAgg.is()) 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir SvNumberFormatsSupplierObj* pNumFmt = 579*cdf0e10cSrcweir SvNumberFormatsSupplierObj::getImplementation( 580*cdf0e10cSrcweir uno::Reference<util::XNumberFormatsSupplier>(xNumberAgg, uno::UNO_QUERY) ); 581*cdf0e10cSrcweir if ( pNumFmt ) 582*cdf0e10cSrcweir pNumFmt->SetNumberFormatter( NULL ); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir DELETEZ( pPrintFuncCache ); // must be deleted because it has a pointer to the DocShell 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir else if ( nId == SFX_HINT_DATACHANGED ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir // cached data for rendering become invalid when contents change 590*cdf0e10cSrcweir // (if a broadcast is added to SetDrawModified, is has to be tested here, too) 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir DELETEZ( pPrintFuncCache ); 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir // handle "OnCalculate" sheet events (search also for VBA event handlers) 595*cdf0e10cSrcweir if ( pDocShell ) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 598*cdf0e10cSrcweir if ( pDoc->GetVbaEventProcessor().is() ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir // If the VBA event processor is set, HasAnyCalcNotification is much faster than HasAnySheetEventScript 601*cdf0e10cSrcweir if ( pDoc->HasAnyCalcNotification() && pDoc->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ) ) 602*cdf0e10cSrcweir HandleCalculateEvents(); 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir else 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir if ( pDoc->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE ) ) 607*cdf0e10cSrcweir HandleCalculateEvents(); 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir else if ( rHint.ISA( ScPointerChangedHint ) ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir sal_uInt16 nFlags = ((const ScPointerChangedHint&)rHint).GetFlags(); 615*cdf0e10cSrcweir if (nFlags & SC_POINTERCHANGED_NUMFMT) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir // NumberFormatter-Pointer am Uno-Objekt neu setzen 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir if (GetFormatter().is()) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir SvNumberFormatsSupplierObj* pNumFmt = 622*cdf0e10cSrcweir SvNumberFormatsSupplierObj::getImplementation( 623*cdf0e10cSrcweir uno::Reference<util::XNumberFormatsSupplier>(xNumberAgg, uno::UNO_QUERY) ); 624*cdf0e10cSrcweir if ( pNumFmt && pDocShell ) 625*cdf0e10cSrcweir pNumFmt->SetNumberFormatter( pDocShell->GetDocument()->GetFormatTable() ); 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir // always call parent - SfxBaseModel might need to handle the same hints again 631*cdf0e10cSrcweir SfxBaseModel::Notify( rBC, rHint ); // SfxBaseModel is derived from SfxListener 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir // XSpreadsheetDocument 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir uno::Reference<sheet::XSpreadsheets> SAL_CALL ScModelObj::getSheets() throw(uno::RuntimeException) 637*cdf0e10cSrcweir { 638*cdf0e10cSrcweir ScUnoGuard aGuard; 639*cdf0e10cSrcweir if (pDocShell) 640*cdf0e10cSrcweir return new ScTableSheetsObj(pDocShell); 641*cdf0e10cSrcweir return NULL; 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir // XStyleFamiliesSupplier 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir uno::Reference<container::XNameAccess> SAL_CALL ScModelObj::getStyleFamilies() 647*cdf0e10cSrcweir throw(uno::RuntimeException) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir ScUnoGuard aGuard; 650*cdf0e10cSrcweir if (pDocShell) 651*cdf0e10cSrcweir return new ScStyleFamiliesObj(pDocShell); 652*cdf0e10cSrcweir return NULL; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir // XRenderable 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir OutputDevice* lcl_GetRenderDevice( const uno::Sequence<beans::PropertyValue>& rOptions ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir OutputDevice* pRet = NULL; 660*cdf0e10cSrcweir const beans::PropertyValue* pPropArray = rOptions.getConstArray(); 661*cdf0e10cSrcweir long nPropCount = rOptions.getLength(); 662*cdf0e10cSrcweir for (long i = 0; i < nPropCount; i++) 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir const beans::PropertyValue& rProp = pPropArray[i]; 665*cdf0e10cSrcweir String aPropName(rProp.Name); 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir if (aPropName.EqualsAscii( SC_UNONAME_RENDERDEV )) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir uno::Reference<awt::XDevice> xRenderDevice(rProp.Value, uno::UNO_QUERY); 670*cdf0e10cSrcweir if ( xRenderDevice.is() ) 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); 673*cdf0e10cSrcweir if ( pDevice ) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir pRet = pDevice->GetOutputDevice(); 676*cdf0e10cSrcweir pRet->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() ); 677*cdf0e10cSrcweir } 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir return pRet; 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir bool lcl_ParseTarget( const String& rTarget, ScRange& rTargetRange, Rectangle& rTargetRect, 685*cdf0e10cSrcweir bool& rIsSheet, ScDocument* pDoc, SCTAB nSourceTab ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir // test in same order as in SID_CURRENTCELL execute 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir ScAddress aAddress; 690*cdf0e10cSrcweir ScRangeUtil aRangeUtil; 691*cdf0e10cSrcweir SCTAB nNameTab; 692*cdf0e10cSrcweir sal_Int32 nNumeric = 0; 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir bool bRangeValid = false; 695*cdf0e10cSrcweir bool bRectValid = false; 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir if ( rTargetRange.Parse( rTarget, pDoc ) & SCA_VALID ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir bRangeValid = true; // range reference 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir else if ( aAddress.Parse( rTarget, pDoc ) & SCA_VALID ) 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir rTargetRange = aAddress; 704*cdf0e10cSrcweir bRangeValid = true; // cell reference 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir else if ( aRangeUtil.MakeRangeFromName( rTarget, pDoc, nSourceTab, rTargetRange, RUTL_NAMES ) || 707*cdf0e10cSrcweir aRangeUtil.MakeRangeFromName( rTarget, pDoc, nSourceTab, rTargetRange, RUTL_DBASE ) ) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir bRangeValid = true; // named range or database range 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir else if ( ByteString( rTarget, RTL_TEXTENCODING_ASCII_US ).IsNumericAscii() && 712*cdf0e10cSrcweir ( nNumeric = rTarget.ToInt32() ) > 0 && nNumeric <= MAXROW+1 ) 713*cdf0e10cSrcweir { 714*cdf0e10cSrcweir // row number is always mapped to cell A(row) on the same sheet 715*cdf0e10cSrcweir rTargetRange = ScAddress( 0, (SCROW)(nNumeric-1), nSourceTab ); // target row number is 1-based 716*cdf0e10cSrcweir bRangeValid = true; // row number 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir else if ( pDoc->GetTable( rTarget, nNameTab ) ) 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir rTargetRange = ScAddress(0,0,nNameTab); 721*cdf0e10cSrcweir bRangeValid = true; // sheet name 722*cdf0e10cSrcweir rIsSheet = true; // needs special handling (first page of the sheet) 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir else 725*cdf0e10cSrcweir { 726*cdf0e10cSrcweir // look for named drawing object 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 729*cdf0e10cSrcweir if ( pDrawLayer ) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 732*cdf0e10cSrcweir for (SCTAB i=0; i<nTabCount && !bRangeValid; i++) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i)); 735*cdf0e10cSrcweir DBG_ASSERT(pPage,"Page ?"); 736*cdf0e10cSrcweir if (pPage) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 739*cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 740*cdf0e10cSrcweir while (pObject && !bRangeValid) 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir if ( ScDrawLayer::GetVisibleName( pObject ) == rTarget ) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir rTargetRect = pObject->GetLogicRect(); // 1/100th mm 745*cdf0e10cSrcweir rTargetRange = pDoc->GetRange( i, rTargetRect ); // underlying cells 746*cdf0e10cSrcweir bRangeValid = bRectValid = true; // rectangle is valid 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir pObject = aIter.Next(); 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir } 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir if ( bRangeValid && !bRectValid ) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir // get rectangle for cell range 757*cdf0e10cSrcweir rTargetRect = pDoc->GetMMRect( rTargetRange.aStart.Col(), rTargetRange.aStart.Row(), 758*cdf0e10cSrcweir rTargetRange.aEnd.Col(), rTargetRange.aEnd.Row(), 759*cdf0e10cSrcweir rTargetRange.aStart.Tab() ); 760*cdf0e10cSrcweir } 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir return bRangeValid; 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir sal_Bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection, 766*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rOptions, 767*cdf0e10cSrcweir ScMarkData& rMark, 768*cdf0e10cSrcweir ScPrintSelectionStatus& rStatus, String& rPagesStr ) const 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir DBG_ASSERT( !rMark.IsMarked() && !rMark.IsMultiMarked(), "FillRenderMarkData: MarkData must be empty" ); 771*cdf0e10cSrcweir DBG_ASSERT( pDocShell, "FillRenderMarkData: DocShell must be set" ); 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir sal_Bool bDone = sal_False; 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir uno::Reference<frame::XController> xView; 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir // defaults when no options are passed: all sheets, include empty pages 778*cdf0e10cSrcweir sal_Bool bSelectedSheetsOnly = sal_False; 779*cdf0e10cSrcweir sal_Bool bIncludeEmptyPages = sal_True; 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir bool bHasPrintContent = false; 782*cdf0e10cSrcweir sal_Int32 nPrintContent = 0; // all sheets / selected sheets / selected cells 783*cdf0e10cSrcweir sal_Int32 nPrintRange = 0; // all pages / pages 784*cdf0e10cSrcweir rtl::OUString aPageRange; // "pages" edit value 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir for( sal_Int32 i = 0, nLen = rOptions.getLength(); i < nLen; i++ ) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir if( rOptions[i].Name.equalsAscii( "IsOnlySelectedSheets" ) ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir rOptions[i].Value >>= bSelectedSheetsOnly; 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir else if( rOptions[i].Name.equalsAscii( "IsIncludeEmptyPages" ) ) 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir rOptions[i].Value >>= bIncludeEmptyPages; 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir else if( rOptions[i].Name.equalsAscii( "PageRange" ) ) 797*cdf0e10cSrcweir { 798*cdf0e10cSrcweir rOptions[i].Value >>= aPageRange; 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir else if( rOptions[i].Name.equalsAscii( "PrintRange" ) ) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir rOptions[i].Value >>= nPrintRange; 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir else if( rOptions[i].Name.equalsAscii( "PrintContent" ) ) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir bHasPrintContent = true; 807*cdf0e10cSrcweir rOptions[i].Value >>= nPrintContent; 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir else if( rOptions[i].Name.equalsAscii( "View" ) ) 810*cdf0e10cSrcweir { 811*cdf0e10cSrcweir rOptions[i].Value >>= xView; 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir // "Print Content" selection wins over "Selected Sheets" option 816*cdf0e10cSrcweir if ( bHasPrintContent ) 817*cdf0e10cSrcweir bSelectedSheetsOnly = ( nPrintContent != 0 ); 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY); 820*cdf0e10cSrcweir if ( xInterface.is() ) 821*cdf0e10cSrcweir { 822*cdf0e10cSrcweir ScCellRangesBase* pSelObj = ScCellRangesBase::getImplementation( xInterface ); 823*cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY ); 824*cdf0e10cSrcweir if ( pSelObj && pSelObj->GetDocShell() == pDocShell ) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir sal_Bool bSheet = ( ScTableSheetObj::getImplementation( xInterface ) != NULL ); 827*cdf0e10cSrcweir sal_Bool bCursor = pSelObj->IsCursorOnly(); 828*cdf0e10cSrcweir const ScRangeList& rRanges = pSelObj->GetRangeList(); 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir rMark.MarkFromRangeList( rRanges, sal_False ); 831*cdf0e10cSrcweir rMark.MarkToSimple(); 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir if ( rMark.IsMultiMarked() ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir // #i115266# copy behavior of old printing: 836*cdf0e10cSrcweir // treat multiple selection like a single selection with the enclosing range 837*cdf0e10cSrcweir ScRange aMultiMarkArea; 838*cdf0e10cSrcweir rMark.GetMultiMarkArea( aMultiMarkArea ); 839*cdf0e10cSrcweir rMark.ResetMark(); 840*cdf0e10cSrcweir rMark.SetMarkArea( aMultiMarkArea ); 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir if ( rMark.IsMarked() && !rMark.IsMultiMarked() ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir // a sheet object is treated like an empty selection: print the used area of the sheet 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir if ( bCursor || bSheet ) // nothing selected -> use whole tables 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir rMark.ResetMark(); // doesn't change table selection 850*cdf0e10cSrcweir rStatus.SetMode( SC_PRINTSEL_CURSOR ); 851*cdf0e10cSrcweir } 852*cdf0e10cSrcweir else 853*cdf0e10cSrcweir rStatus.SetMode( SC_PRINTSEL_RANGE ); 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir rStatus.SetRanges( rRanges ); 856*cdf0e10cSrcweir bDone = sal_True; 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir // multi selection isn't supported 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir else if( xShapes.is() ) 861*cdf0e10cSrcweir { 862*cdf0e10cSrcweir //print a selected ole object 863*cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY ); 864*cdf0e10cSrcweir if( xIndexAccess.is() ) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir // multi selection isn't supported yet 867*cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY ); 868*cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( xShape ); 869*cdf0e10cSrcweir if( pShape ) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir SdrObject *pSdrObj = pShape->GetSdrObject(); 872*cdf0e10cSrcweir if( pDocShell ) 873*cdf0e10cSrcweir { 874*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 875*cdf0e10cSrcweir if( pDoc && pSdrObj ) 876*cdf0e10cSrcweir { 877*cdf0e10cSrcweir Rectangle aObjRect = pSdrObj->GetCurrentBoundRect(); 878*cdf0e10cSrcweir SCTAB nCurrentTab = ScDocShell::GetCurTab(); 879*cdf0e10cSrcweir ScRange aRange = pDoc->GetRange( nCurrentTab, aObjRect ); 880*cdf0e10cSrcweir rMark.SetMarkArea( aRange ); 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir if( rMark.IsMarked() && !rMark.IsMultiMarked() ) 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir rStatus.SetMode( SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS ); 885*cdf0e10cSrcweir bDone = sal_True; 886*cdf0e10cSrcweir } 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir } 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir } 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir else if ( ScModelObj::getImplementation( xInterface ) == this ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir // render the whole document 895*cdf0e10cSrcweir // -> no selection, all sheets 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); 898*cdf0e10cSrcweir for (SCTAB nTab = 0; nTab < nTabCount; nTab++) 899*cdf0e10cSrcweir rMark.SelectTable( nTab, sal_True ); 900*cdf0e10cSrcweir rStatus.SetMode( SC_PRINTSEL_DOCUMENT ); 901*cdf0e10cSrcweir bDone = sal_True; 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir // other selection types aren't supported 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir // restrict to selected sheets if a view is available 907*cdf0e10cSrcweir if ( bSelectedSheetsOnly && xView.is() ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir ScTabViewObj* pViewObj = ScTabViewObj::getImplementation( xView ); 910*cdf0e10cSrcweir if (pViewObj) 911*cdf0e10cSrcweir { 912*cdf0e10cSrcweir ScTabViewShell* pViewSh = pViewObj->GetViewShell(); 913*cdf0e10cSrcweir if (pViewSh) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir // #i95280# when printing from the shell, the view is never activated, 916*cdf0e10cSrcweir // so Excel view settings must also be evaluated here. 917*cdf0e10cSrcweir ScExtDocOptions* pExtOpt = pDocShell->GetDocument()->GetExtDocOptions(); 918*cdf0e10cSrcweir if ( pExtOpt && pExtOpt->IsChanged() ) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir pViewSh->GetViewData()->ReadExtOptions(*pExtOpt); // Excel view settings 921*cdf0e10cSrcweir pViewSh->SetTabNo( pViewSh->GetViewData()->GetTabNo(), sal_True ); 922*cdf0e10cSrcweir pExtOpt->SetChanged( false ); 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir const ScMarkData& rViewMark = pViewSh->GetViewData()->GetMarkData(); 926*cdf0e10cSrcweir SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); 927*cdf0e10cSrcweir for (SCTAB nTab = 0; nTab < nTabCount; nTab++) 928*cdf0e10cSrcweir if (!rViewMark.GetTableSelect(nTab)) 929*cdf0e10cSrcweir rMark.SelectTable( nTab, sal_False ); 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir ScPrintOptions aNewOptions; 935*cdf0e10cSrcweir aNewOptions.SetSkipEmpty( !bIncludeEmptyPages ); 936*cdf0e10cSrcweir aNewOptions.SetAllSheets( !bSelectedSheetsOnly ); 937*cdf0e10cSrcweir rStatus.SetOptions( aNewOptions ); 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir // "PrintRange" enables (1) or disables (0) the "PageRange" edit 940*cdf0e10cSrcweir if ( nPrintRange == 1 ) 941*cdf0e10cSrcweir rPagesStr = aPageRange; 942*cdf0e10cSrcweir else 943*cdf0e10cSrcweir rPagesStr.Erase(); 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir return bDone; 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir sal_Int32 SAL_CALL ScModelObj::getRendererCount( const uno::Any& aSelection, 950*cdf0e10cSrcweir const uno::Sequence<beans::PropertyValue>& rOptions ) 951*cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException) 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir ScUnoGuard aGuard; 954*cdf0e10cSrcweir if (!pDocShell) 955*cdf0e10cSrcweir throw uno::RuntimeException(); 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir ScMarkData aMark; 958*cdf0e10cSrcweir ScPrintSelectionStatus aStatus; 959*cdf0e10cSrcweir String aPagesStr; 960*cdf0e10cSrcweir if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) ) 961*cdf0e10cSrcweir return 0; 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir // The same ScPrintFuncCache object in pPrintFuncCache is used as long as 964*cdf0e10cSrcweir // the same selection is used (aStatus) and the document isn't changed 965*cdf0e10cSrcweir // (pPrintFuncCache is cleared in Notify handler) 966*cdf0e10cSrcweir 967*cdf0e10cSrcweir if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) ) 968*cdf0e10cSrcweir { 969*cdf0e10cSrcweir delete pPrintFuncCache; 970*cdf0e10cSrcweir pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus ); 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir sal_Int32 nPages = pPrintFuncCache->GetPageCount(); 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir sal_Int32 nSelectCount = nPages; 975*cdf0e10cSrcweir if ( aPagesStr.Len() ) 976*cdf0e10cSrcweir { 977*cdf0e10cSrcweir MultiSelection aPageRanges( aPagesStr ); 978*cdf0e10cSrcweir aPageRanges.SetTotalRange( Range( 1, nPages ) ); 979*cdf0e10cSrcweir nSelectCount = aPageRanges.GetSelectCount(); 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir return nSelectCount; 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir sal_Int32 lcl_GetRendererNum( sal_Int32 nSelRenderer, const String& rPagesStr, sal_Int32 nTotalPages ) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir if ( !rPagesStr.Len() ) 987*cdf0e10cSrcweir return nSelRenderer; 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir MultiSelection aPageRanges( rPagesStr ); 990*cdf0e10cSrcweir aPageRanges.SetTotalRange( Range( 1, nTotalPages ) ); 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir sal_Int32 nSelected = aPageRanges.FirstSelected(); 993*cdf0e10cSrcweir while ( nSelRenderer > 0 ) 994*cdf0e10cSrcweir { 995*cdf0e10cSrcweir nSelected = aPageRanges.NextSelected(); 996*cdf0e10cSrcweir --nSelRenderer; 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir return nSelected - 1; // selection is 1-based 999*cdf0e10cSrcweir } 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 nSelRenderer, 1002*cdf0e10cSrcweir const uno::Any& aSelection, const uno::Sequence<beans::PropertyValue>& rOptions ) 1003*cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException) 1004*cdf0e10cSrcweir { 1005*cdf0e10cSrcweir ScUnoGuard aGuard; 1006*cdf0e10cSrcweir if (!pDocShell) 1007*cdf0e10cSrcweir throw uno::RuntimeException(); 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir ScMarkData aMark; 1010*cdf0e10cSrcweir ScPrintSelectionStatus aStatus; 1011*cdf0e10cSrcweir String aPagesStr; 1012*cdf0e10cSrcweir // #i115266# if FillRenderMarkData fails, keep nTotalPages at 0, but still handle getRenderer(0) below 1013*cdf0e10cSrcweir long nTotalPages = 0; 1014*cdf0e10cSrcweir if ( FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) ) 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) ) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir delete pPrintFuncCache; 1019*cdf0e10cSrcweir pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus ); 1020*cdf0e10cSrcweir } 1021*cdf0e10cSrcweir nTotalPages = pPrintFuncCache->GetPageCount(); 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages ); 1024*cdf0e10cSrcweir if ( nRenderer >= nTotalPages ) 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir if ( nSelRenderer == 0 ) 1027*cdf0e10cSrcweir { 1028*cdf0e10cSrcweir // getRenderer(0) is used to query the settings, so it must always return something 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir SCTAB nCurTab = 0; //! use current sheet from view? 1031*cdf0e10cSrcweir ScPrintFunc aDefaultFunc( pDocShell, pDocShell->GetPrinter(), nCurTab ); 1032*cdf0e10cSrcweir Size aTwips = aDefaultFunc.GetPageSize(); 1033*cdf0e10cSrcweir awt::Size aPageSize( TwipsToHMM( aTwips.Width() ), TwipsToHMM( aTwips.Height() ) ); 1034*cdf0e10cSrcweir 1035*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aSequence(1); 1036*cdf0e10cSrcweir beans::PropertyValue* pArray = aSequence.getArray(); 1037*cdf0e10cSrcweir pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_PAGESIZE ); 1038*cdf0e10cSrcweir pArray[0].Value <<= aPageSize; 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir if( ! pPrinterOptions ) 1041*cdf0e10cSrcweir pPrinterOptions = new ScPrintUIOptions; 1042*cdf0e10cSrcweir else 1043*cdf0e10cSrcweir pPrinterOptions->SetDefaults(); 1044*cdf0e10cSrcweir pPrinterOptions->appendPrintUIOptions( aSequence ); 1045*cdf0e10cSrcweir return aSequence; 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir else 1048*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1049*cdf0e10cSrcweir } 1050*cdf0e10cSrcweir 1051*cdf0e10cSrcweir // printer is used as device (just for page layout), draw view is not needed 1052*cdf0e10cSrcweir 1053*cdf0e10cSrcweir SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer ); 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir ScRange aRange; 1056*cdf0e10cSrcweir const ScRange* pSelRange = NULL; 1057*cdf0e10cSrcweir if ( aMark.IsMarked() ) 1058*cdf0e10cSrcweir { 1059*cdf0e10cSrcweir aMark.GetMarkArea( aRange ); 1060*cdf0e10cSrcweir pSelRange = &aRange; 1061*cdf0e10cSrcweir } 1062*cdf0e10cSrcweir ScPrintFunc aFunc( pDocShell, pDocShell->GetPrinter(), nTab, 1063*cdf0e10cSrcweir pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() ); 1064*cdf0e10cSrcweir aFunc.SetRenderFlag( sal_True ); 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir Range aPageRange( nRenderer+1, nRenderer+1 ); 1067*cdf0e10cSrcweir MultiSelection aPage( aPageRange ); 1068*cdf0e10cSrcweir aPage.SetTotalRange( Range(0,RANGE_MAX) ); 1069*cdf0e10cSrcweir aPage.Select( aPageRange ); 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab ); 1072*cdf0e10cSrcweir long nTabStart = pPrintFuncCache->GetTabStart( nTab ); 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir (void)aFunc.DoPrint( aPage, nTabStart, nDisplayStart, sal_False, NULL ); 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir ScRange aCellRange; 1077*cdf0e10cSrcweir sal_Bool bWasCellRange = aFunc.GetLastSourceRange( aCellRange ); 1078*cdf0e10cSrcweir Size aTwips = aFunc.GetPageSize(); 1079*cdf0e10cSrcweir awt::Size aPageSize( TwipsToHMM( aTwips.Width() ), TwipsToHMM( aTwips.Height() ) ); 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir long nPropCount = bWasCellRange ? 3 : 2; 1082*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aSequence(nPropCount); 1083*cdf0e10cSrcweir beans::PropertyValue* pArray = aSequence.getArray(); 1084*cdf0e10cSrcweir pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_PAGESIZE ); 1085*cdf0e10cSrcweir pArray[0].Value <<= aPageSize; 1086*cdf0e10cSrcweir // #i111158# all positions are relative to the whole page, including non-printable area 1087*cdf0e10cSrcweir pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_INC_NP_AREA ); 1088*cdf0e10cSrcweir pArray[1].Value = uno::makeAny( sal_True ); 1089*cdf0e10cSrcweir if ( bWasCellRange ) 1090*cdf0e10cSrcweir { 1091*cdf0e10cSrcweir table::CellRangeAddress aRangeAddress( nTab, 1092*cdf0e10cSrcweir aCellRange.aStart.Col(), aCellRange.aStart.Row(), 1093*cdf0e10cSrcweir aCellRange.aEnd.Col(), aCellRange.aEnd.Row() ); 1094*cdf0e10cSrcweir pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_SOURCERANGE ); 1095*cdf0e10cSrcweir pArray[2].Value <<= aRangeAddress; 1096*cdf0e10cSrcweir } 1097*cdf0e10cSrcweir 1098*cdf0e10cSrcweir if( ! pPrinterOptions ) 1099*cdf0e10cSrcweir pPrinterOptions = new ScPrintUIOptions; 1100*cdf0e10cSrcweir else 1101*cdf0e10cSrcweir pPrinterOptions->SetDefaults(); 1102*cdf0e10cSrcweir pPrinterOptions->appendPrintUIOptions( aSequence ); 1103*cdf0e10cSrcweir return aSequence; 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelection, 1107*cdf0e10cSrcweir const uno::Sequence<beans::PropertyValue>& rOptions ) 1108*cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 1109*cdf0e10cSrcweir { 1110*cdf0e10cSrcweir ScUnoGuard aGuard; 1111*cdf0e10cSrcweir if (!pDocShell) 1112*cdf0e10cSrcweir throw uno::RuntimeException(); 1113*cdf0e10cSrcweir 1114*cdf0e10cSrcweir ScMarkData aMark; 1115*cdf0e10cSrcweir ScPrintSelectionStatus aStatus; 1116*cdf0e10cSrcweir String aPagesStr; 1117*cdf0e10cSrcweir if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) ) 1118*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) ) 1121*cdf0e10cSrcweir { 1122*cdf0e10cSrcweir delete pPrintFuncCache; 1123*cdf0e10cSrcweir pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus ); 1124*cdf0e10cSrcweir } 1125*cdf0e10cSrcweir long nTotalPages = pPrintFuncCache->GetPageCount(); 1126*cdf0e10cSrcweir sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages ); 1127*cdf0e10cSrcweir if ( nRenderer >= nTotalPages ) 1128*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir OutputDevice* pDev = lcl_GetRenderDevice( rOptions ); 1131*cdf0e10cSrcweir if ( !pDev ) 1132*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1133*cdf0e10cSrcweir 1134*cdf0e10cSrcweir SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer ); 1135*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir FmFormView* pDrawView = NULL; 1138*cdf0e10cSrcweir Rectangle aFull( 0, 0, LONG_MAX, LONG_MAX ); 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir // #114135# 1141*cdf0e10cSrcweir ScDrawLayer* pModel = pDoc->GetDrawLayer(); 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir if( pModel ) 1144*cdf0e10cSrcweir { 1145*cdf0e10cSrcweir pDrawView = new FmFormView( pModel, pDev ); 1146*cdf0e10cSrcweir pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab)); 1147*cdf0e10cSrcweir pDrawView->SetPrintPreview( sal_True ); 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir 1150*cdf0e10cSrcweir ScRange aRange; 1151*cdf0e10cSrcweir const ScRange* pSelRange = NULL; 1152*cdf0e10cSrcweir if ( aMark.IsMarked() ) 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir aMark.GetMarkArea( aRange ); 1155*cdf0e10cSrcweir pSelRange = &aRange; 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir 1158*cdf0e10cSrcweir // to increase performance, ScPrintState might be used here for subsequent 1159*cdf0e10cSrcweir // pages of the same sheet 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir ScPrintFunc aFunc( pDev, pDocShell, nTab, pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() ); 1162*cdf0e10cSrcweir aFunc.SetDrawView( pDrawView ); 1163*cdf0e10cSrcweir aFunc.SetRenderFlag( sal_True ); 1164*cdf0e10cSrcweir if( aStatus.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS ) 1165*cdf0e10cSrcweir aFunc.SetExclusivelyDrawOleAndDrawObjects(); 1166*cdf0e10cSrcweir 1167*cdf0e10cSrcweir Range aPageRange( nRenderer+1, nRenderer+1 ); 1168*cdf0e10cSrcweir MultiSelection aPage( aPageRange ); 1169*cdf0e10cSrcweir aPage.SetTotalRange( Range(0,RANGE_MAX) ); 1170*cdf0e10cSrcweir aPage.Select( aPageRange ); 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab ); 1173*cdf0e10cSrcweir long nTabStart = pPrintFuncCache->GetTabStart( nTab ); 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() ); 1176*cdf0e10cSrcweir if ( nRenderer == nTabStart ) 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir // first page of a sheet: add outline item for the sheet name 1179*cdf0e10cSrcweir 1180*cdf0e10cSrcweir if ( pPDFData && pPDFData->GetIsExportBookmarks() ) 1181*cdf0e10cSrcweir { 1182*cdf0e10cSrcweir // the sheet starts at the top of the page 1183*cdf0e10cSrcweir Rectangle aArea( pDev->PixelToLogic( Rectangle( 0,0,0,0 ) ) ); 1184*cdf0e10cSrcweir sal_Int32 nDestID = pPDFData->CreateDest( aArea ); 1185*cdf0e10cSrcweir String aTabName; 1186*cdf0e10cSrcweir pDoc->GetName( nTab, aTabName ); 1187*cdf0e10cSrcweir sal_Int32 nParent = -1; // top-level 1188*cdf0e10cSrcweir pPDFData->CreateOutlineItem( nParent, aTabName, nDestID ); 1189*cdf0e10cSrcweir } 1190*cdf0e10cSrcweir //--->i56629 1191*cdf0e10cSrcweir // add the named destination stuff 1192*cdf0e10cSrcweir if( pPDFData && pPDFData->GetIsExportNamedDestinations() ) 1193*cdf0e10cSrcweir { 1194*cdf0e10cSrcweir Rectangle aArea( pDev->PixelToLogic( Rectangle( 0,0,0,0 ) ) ); 1195*cdf0e10cSrcweir String aTabName; 1196*cdf0e10cSrcweir pDoc->GetName( nTab, aTabName ); 1197*cdf0e10cSrcweir //need the PDF page number here 1198*cdf0e10cSrcweir pPDFData->CreateNamedDest( aTabName, aArea ); 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir //<---i56629 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir (void)aFunc.DoPrint( aPage, nTabStart, nDisplayStart, sal_True, NULL ); 1204*cdf0e10cSrcweir 1205*cdf0e10cSrcweir // resolve the hyperlinks for PDF export 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir if ( pPDFData ) 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir // iterate over the hyperlinks that were output for this page 1210*cdf0e10cSrcweir 1211*cdf0e10cSrcweir std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->GetBookmarks(); 1212*cdf0e10cSrcweir std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIter = rBookmarks.begin(); 1213*cdf0e10cSrcweir std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end(); 1214*cdf0e10cSrcweir while ( aIter != aIEnd ) 1215*cdf0e10cSrcweir { 1216*cdf0e10cSrcweir rtl::OUString aBookmark = aIter->aBookmark; 1217*cdf0e10cSrcweir if ( aBookmark.toChar() == (sal_Unicode) '#' ) 1218*cdf0e10cSrcweir { 1219*cdf0e10cSrcweir // try to resolve internal link 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir String aTarget( aBookmark.copy( 1 ) ); 1222*cdf0e10cSrcweir 1223*cdf0e10cSrcweir ScRange aTargetRange; 1224*cdf0e10cSrcweir Rectangle aTargetRect; // 1/100th mm 1225*cdf0e10cSrcweir bool bIsSheet = false; 1226*cdf0e10cSrcweir bool bValid = lcl_ParseTarget( aTarget, aTargetRange, aTargetRect, bIsSheet, pDoc, nTab ); 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir if ( bValid ) 1229*cdf0e10cSrcweir { 1230*cdf0e10cSrcweir sal_Int32 nPage = -1; 1231*cdf0e10cSrcweir Rectangle aArea; 1232*cdf0e10cSrcweir if ( bIsSheet ) 1233*cdf0e10cSrcweir { 1234*cdf0e10cSrcweir // Get first page for sheet (if nothing from that sheet is printed, 1235*cdf0e10cSrcweir // this page can show a different sheet) 1236*cdf0e10cSrcweir nPage = pPrintFuncCache->GetTabStart( aTargetRange.aStart.Tab() ); 1237*cdf0e10cSrcweir aArea = pDev->PixelToLogic( Rectangle( 0,0,0,0 ) ); 1238*cdf0e10cSrcweir } 1239*cdf0e10cSrcweir else 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir pPrintFuncCache->InitLocations( aMark, pDev ); // does nothing if already initialized 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir ScPrintPageLocation aLocation; 1244*cdf0e10cSrcweir if ( pPrintFuncCache->FindLocation( aTargetRange.aStart, aLocation ) ) 1245*cdf0e10cSrcweir { 1246*cdf0e10cSrcweir nPage = aLocation.nPage; 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir // get the rectangle of the page's cell range in 1/100th mm 1249*cdf0e10cSrcweir ScRange aLocRange = aLocation.aCellRange; 1250*cdf0e10cSrcweir Rectangle aLocationMM = pDoc->GetMMRect( 1251*cdf0e10cSrcweir aLocRange.aStart.Col(), aLocRange.aStart.Row(), 1252*cdf0e10cSrcweir aLocRange.aEnd.Col(), aLocRange.aEnd.Row(), 1253*cdf0e10cSrcweir aLocRange.aStart.Tab() ); 1254*cdf0e10cSrcweir Rectangle aLocationPixel = aLocation.aRectangle; 1255*cdf0e10cSrcweir 1256*cdf0e10cSrcweir // Scale and move the target rectangle from aLocationMM to aLocationPixel, 1257*cdf0e10cSrcweir // to get the target rectangle in pixels. 1258*cdf0e10cSrcweir 1259*cdf0e10cSrcweir Fraction aScaleX( aLocationPixel.GetWidth(), aLocationMM.GetWidth() ); 1260*cdf0e10cSrcweir Fraction aScaleY( aLocationPixel.GetHeight(), aLocationMM.GetHeight() ); 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir long nX1 = aLocationPixel.Left() + (long) 1263*cdf0e10cSrcweir ( Fraction( aTargetRect.Left() - aLocationMM.Left(), 1 ) * aScaleX ); 1264*cdf0e10cSrcweir long nX2 = aLocationPixel.Left() + (long) 1265*cdf0e10cSrcweir ( Fraction( aTargetRect.Right() - aLocationMM.Left(), 1 ) * aScaleX ); 1266*cdf0e10cSrcweir long nY1 = aLocationPixel.Top() + (long) 1267*cdf0e10cSrcweir ( Fraction( aTargetRect.Top() - aLocationMM.Top(), 1 ) * aScaleY ); 1268*cdf0e10cSrcweir long nY2 = aLocationPixel.Top() + (long) 1269*cdf0e10cSrcweir ( Fraction( aTargetRect.Bottom() - aLocationMM.Top(), 1 ) * aScaleY ); 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir if ( nX1 > aLocationPixel.Right() ) nX1 = aLocationPixel.Right(); 1272*cdf0e10cSrcweir if ( nX2 > aLocationPixel.Right() ) nX2 = aLocationPixel.Right(); 1273*cdf0e10cSrcweir if ( nY1 > aLocationPixel.Bottom() ) nY1 = aLocationPixel.Bottom(); 1274*cdf0e10cSrcweir if ( nY2 > aLocationPixel.Bottom() ) nY2 = aLocationPixel.Bottom(); 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir // The link target area is interpreted using the device's MapMode at 1277*cdf0e10cSrcweir // the time of the CreateDest call, so PixelToLogic can be used here, 1278*cdf0e10cSrcweir // regardless of the MapMode that is actually selected. 1279*cdf0e10cSrcweir 1280*cdf0e10cSrcweir aArea = pDev->PixelToLogic( Rectangle( nX1, nY1, nX2, nY2 ) ); 1281*cdf0e10cSrcweir } 1282*cdf0e10cSrcweir } 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir if ( nPage >= 0 ) 1285*cdf0e10cSrcweir { 1286*cdf0e10cSrcweir if ( aIter->nLinkId != -1 ) 1287*cdf0e10cSrcweir pPDFData->SetLinkDest( aIter->nLinkId, pPDFData->CreateDest( aArea, nPage ) ); 1288*cdf0e10cSrcweir else 1289*cdf0e10cSrcweir pPDFData->DescribeRegisteredDest( aIter->nDestId, aArea, nPage ); 1290*cdf0e10cSrcweir } 1291*cdf0e10cSrcweir } 1292*cdf0e10cSrcweir } 1293*cdf0e10cSrcweir else 1294*cdf0e10cSrcweir { 1295*cdf0e10cSrcweir // external link, use as-is 1296*cdf0e10cSrcweir pPDFData->SetLinkURL( aIter->nLinkId, aBookmark ); 1297*cdf0e10cSrcweir } 1298*cdf0e10cSrcweir aIter++; 1299*cdf0e10cSrcweir } 1300*cdf0e10cSrcweir rBookmarks.clear(); 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir if ( pDrawView ) 1304*cdf0e10cSrcweir pDrawView->HideSdrPage(); 1305*cdf0e10cSrcweir delete pDrawView; 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir // XLinkTargetSupplier 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir uno::Reference<container::XNameAccess> SAL_CALL ScModelObj::getLinks() throw(uno::RuntimeException) 1311*cdf0e10cSrcweir { 1312*cdf0e10cSrcweir ScUnoGuard aGuard; 1313*cdf0e10cSrcweir if (pDocShell) 1314*cdf0e10cSrcweir return new ScLinkTargetTypesObj(pDocShell); 1315*cdf0e10cSrcweir return NULL; 1316*cdf0e10cSrcweir } 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir // XActionLockable 1319*cdf0e10cSrcweir 1320*cdf0e10cSrcweir sal_Bool SAL_CALL ScModelObj::isActionLocked() throw(uno::RuntimeException) 1321*cdf0e10cSrcweir { 1322*cdf0e10cSrcweir ScUnoGuard aGuard; 1323*cdf0e10cSrcweir sal_Bool bLocked = sal_False; 1324*cdf0e10cSrcweir if (pDocShell) 1325*cdf0e10cSrcweir bLocked = ( pDocShell->GetLockCount() != 0 ); 1326*cdf0e10cSrcweir return bLocked; 1327*cdf0e10cSrcweir } 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir void SAL_CALL ScModelObj::addActionLock() throw(uno::RuntimeException) 1330*cdf0e10cSrcweir { 1331*cdf0e10cSrcweir ScUnoGuard aGuard; 1332*cdf0e10cSrcweir if (pDocShell) 1333*cdf0e10cSrcweir pDocShell->LockDocument(); 1334*cdf0e10cSrcweir } 1335*cdf0e10cSrcweir 1336*cdf0e10cSrcweir void SAL_CALL ScModelObj::removeActionLock() throw(uno::RuntimeException) 1337*cdf0e10cSrcweir { 1338*cdf0e10cSrcweir ScUnoGuard aGuard; 1339*cdf0e10cSrcweir if (pDocShell) 1340*cdf0e10cSrcweir pDocShell->UnlockDocument(); 1341*cdf0e10cSrcweir } 1342*cdf0e10cSrcweir 1343*cdf0e10cSrcweir void SAL_CALL ScModelObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException) 1344*cdf0e10cSrcweir { 1345*cdf0e10cSrcweir ScUnoGuard aGuard; 1346*cdf0e10cSrcweir if (pDocShell) 1347*cdf0e10cSrcweir pDocShell->SetLockCount(nLock); 1348*cdf0e10cSrcweir } 1349*cdf0e10cSrcweir 1350*cdf0e10cSrcweir sal_Int16 SAL_CALL ScModelObj::resetActionLocks() throw(uno::RuntimeException) 1351*cdf0e10cSrcweir { 1352*cdf0e10cSrcweir ScUnoGuard aGuard; 1353*cdf0e10cSrcweir sal_uInt16 nRet = 0; 1354*cdf0e10cSrcweir if (pDocShell) 1355*cdf0e10cSrcweir { 1356*cdf0e10cSrcweir nRet = pDocShell->GetLockCount(); 1357*cdf0e10cSrcweir pDocShell->SetLockCount(0); 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir return nRet; 1360*cdf0e10cSrcweir } 1361*cdf0e10cSrcweir 1362*cdf0e10cSrcweir void SAL_CALL ScModelObj::lockControllers() throw (::com::sun::star::uno::RuntimeException) 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir ScUnoGuard aGuard; 1365*cdf0e10cSrcweir SfxBaseModel::lockControllers(); 1366*cdf0e10cSrcweir if (pDocShell) 1367*cdf0e10cSrcweir pDocShell->LockPaint(); 1368*cdf0e10cSrcweir } 1369*cdf0e10cSrcweir 1370*cdf0e10cSrcweir void SAL_CALL ScModelObj::unlockControllers() throw (::com::sun::star::uno::RuntimeException) 1371*cdf0e10cSrcweir { 1372*cdf0e10cSrcweir ScUnoGuard aGuard; 1373*cdf0e10cSrcweir if (hasControllersLocked()) 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir SfxBaseModel::unlockControllers(); 1376*cdf0e10cSrcweir if (pDocShell) 1377*cdf0e10cSrcweir pDocShell->UnlockPaint(); 1378*cdf0e10cSrcweir } 1379*cdf0e10cSrcweir } 1380*cdf0e10cSrcweir 1381*cdf0e10cSrcweir // XCalculate 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir void SAL_CALL ScModelObj::calculate() throw(uno::RuntimeException) 1384*cdf0e10cSrcweir { 1385*cdf0e10cSrcweir ScUnoGuard aGuard; 1386*cdf0e10cSrcweir if (pDocShell) 1387*cdf0e10cSrcweir pDocShell->DoRecalc(sal_True); 1388*cdf0e10cSrcweir else 1389*cdf0e10cSrcweir { 1390*cdf0e10cSrcweir DBG_ERROR("keine DocShell"); //! Exception oder so? 1391*cdf0e10cSrcweir } 1392*cdf0e10cSrcweir } 1393*cdf0e10cSrcweir 1394*cdf0e10cSrcweir void SAL_CALL ScModelObj::calculateAll() throw(uno::RuntimeException) 1395*cdf0e10cSrcweir { 1396*cdf0e10cSrcweir ScUnoGuard aGuard; 1397*cdf0e10cSrcweir if (pDocShell) 1398*cdf0e10cSrcweir pDocShell->DoHardRecalc(sal_True); 1399*cdf0e10cSrcweir else 1400*cdf0e10cSrcweir { 1401*cdf0e10cSrcweir DBG_ERROR("keine DocShell"); //! Exception oder so? 1402*cdf0e10cSrcweir } 1403*cdf0e10cSrcweir } 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir sal_Bool SAL_CALL ScModelObj::isAutomaticCalculationEnabled() throw(uno::RuntimeException) 1406*cdf0e10cSrcweir { 1407*cdf0e10cSrcweir ScUnoGuard aGuard; 1408*cdf0e10cSrcweir if (pDocShell) 1409*cdf0e10cSrcweir return pDocShell->GetDocument()->GetAutoCalc(); 1410*cdf0e10cSrcweir 1411*cdf0e10cSrcweir DBG_ERROR("keine DocShell"); //! Exception oder so? 1412*cdf0e10cSrcweir return sal_False; 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir 1415*cdf0e10cSrcweir void SAL_CALL ScModelObj::enableAutomaticCalculation( sal_Bool bEnabled ) 1416*cdf0e10cSrcweir throw(uno::RuntimeException) 1417*cdf0e10cSrcweir { 1418*cdf0e10cSrcweir ScUnoGuard aGuard; 1419*cdf0e10cSrcweir if (pDocShell) 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1422*cdf0e10cSrcweir if ( pDoc->GetAutoCalc() != bEnabled ) 1423*cdf0e10cSrcweir { 1424*cdf0e10cSrcweir pDoc->SetAutoCalc( bEnabled ); 1425*cdf0e10cSrcweir pDocShell->SetDocumentModified(); 1426*cdf0e10cSrcweir } 1427*cdf0e10cSrcweir } 1428*cdf0e10cSrcweir else 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir DBG_ERROR("keine DocShell"); //! Exception oder so? 1431*cdf0e10cSrcweir } 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir 1434*cdf0e10cSrcweir // XProtectable 1435*cdf0e10cSrcweir 1436*cdf0e10cSrcweir void SAL_CALL ScModelObj::protect( const rtl::OUString& aPassword ) throw(uno::RuntimeException) 1437*cdf0e10cSrcweir { 1438*cdf0e10cSrcweir ScUnoGuard aGuard; 1439*cdf0e10cSrcweir // #i108245# if already protected, don't change anything 1440*cdf0e10cSrcweir if ( pDocShell && !pDocShell->GetDocument()->IsDocProtected() ) 1441*cdf0e10cSrcweir { 1442*cdf0e10cSrcweir String aString(aPassword); 1443*cdf0e10cSrcweir 1444*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 1445*cdf0e10cSrcweir aFunc.Protect( TABLEID_DOC, aString, sal_True ); 1446*cdf0e10cSrcweir } 1447*cdf0e10cSrcweir } 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir void SAL_CALL ScModelObj::unprotect( const rtl::OUString& aPassword ) 1450*cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 1451*cdf0e10cSrcweir { 1452*cdf0e10cSrcweir ScUnoGuard aGuard; 1453*cdf0e10cSrcweir if (pDocShell) 1454*cdf0e10cSrcweir { 1455*cdf0e10cSrcweir String aString(aPassword); 1456*cdf0e10cSrcweir 1457*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 1458*cdf0e10cSrcweir sal_Bool bDone = aFunc.Unprotect( TABLEID_DOC, aString, sal_True ); 1459*cdf0e10cSrcweir if (!bDone) 1460*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1461*cdf0e10cSrcweir } 1462*cdf0e10cSrcweir } 1463*cdf0e10cSrcweir 1464*cdf0e10cSrcweir sal_Bool SAL_CALL ScModelObj::isProtected() throw(uno::RuntimeException) 1465*cdf0e10cSrcweir { 1466*cdf0e10cSrcweir ScUnoGuard aGuard; 1467*cdf0e10cSrcweir if (pDocShell) 1468*cdf0e10cSrcweir return pDocShell->GetDocument()->IsDocProtected(); 1469*cdf0e10cSrcweir 1470*cdf0e10cSrcweir DBG_ERROR("keine DocShell"); //! Exception oder so? 1471*cdf0e10cSrcweir return sal_False; 1472*cdf0e10cSrcweir } 1473*cdf0e10cSrcweir 1474*cdf0e10cSrcweir // XDrawPagesSupplier 1475*cdf0e10cSrcweir 1476*cdf0e10cSrcweir uno::Reference<drawing::XDrawPages> SAL_CALL ScModelObj::getDrawPages() throw(uno::RuntimeException) 1477*cdf0e10cSrcweir { 1478*cdf0e10cSrcweir ScUnoGuard aGuard; 1479*cdf0e10cSrcweir if (pDocShell) 1480*cdf0e10cSrcweir return new ScDrawPagesObj(pDocShell); 1481*cdf0e10cSrcweir 1482*cdf0e10cSrcweir DBG_ERROR("keine DocShell"); //! Exception oder so? 1483*cdf0e10cSrcweir return NULL; 1484*cdf0e10cSrcweir } 1485*cdf0e10cSrcweir 1486*cdf0e10cSrcweir #if 0 1487*cdf0e10cSrcweir // XPrintable 1488*cdf0e10cSrcweir 1489*cdf0e10cSrcweir rtl::OUString ScModelObj::getPrinterName(void) const 1490*cdf0e10cSrcweir { 1491*cdf0e10cSrcweir ScUnoGuard aGuard; 1492*cdf0e10cSrcweir if (pDocShell) 1493*cdf0e10cSrcweir { 1494*cdf0e10cSrcweir SfxPrinter* pPrinter = pDocShell->GetPrinter(); 1495*cdf0e10cSrcweir if (pPrinter) 1496*cdf0e10cSrcweir return pPrinter->GetName(); 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir 1499*cdf0e10cSrcweir DBG_ERROR("getPrinterName: keine DocShell oder kein Printer"); 1500*cdf0e10cSrcweir return rtl::OUString(); 1501*cdf0e10cSrcweir } 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir void ScModelObj::setPrinterName(const rtl::OUString& PrinterName) 1504*cdf0e10cSrcweir { 1505*cdf0e10cSrcweir ScUnoGuard aGuard; 1506*cdf0e10cSrcweir // Drucker setzen - wie in SfxViewShell::ExecPrint_Impl 1507*cdf0e10cSrcweir 1508*cdf0e10cSrcweir if (pDocShell) 1509*cdf0e10cSrcweir { 1510*cdf0e10cSrcweir SfxPrinter* pPrinter = pDocShell->GetPrinter(); 1511*cdf0e10cSrcweir if (pPrinter) 1512*cdf0e10cSrcweir { 1513*cdf0e10cSrcweir String aString(PrinterName); 1514*cdf0e10cSrcweir SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString ); 1515*cdf0e10cSrcweir if (pNewPrinter->IsKnown()) 1516*cdf0e10cSrcweir pDocShell->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER ); 1517*cdf0e10cSrcweir else 1518*cdf0e10cSrcweir delete pNewPrinter; 1519*cdf0e10cSrcweir } 1520*cdf0e10cSrcweir } 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir 1523*cdf0e10cSrcweir XPropertySetRef ScModelObj::createPrintOptions(void) 1524*cdf0e10cSrcweir { 1525*cdf0e10cSrcweir ScUnoGuard aGuard; 1526*cdf0e10cSrcweir return new ScPrintSettingsObj; //! ScPrintSettingsObj implementieren! 1527*cdf0e10cSrcweir } 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir void ScModelObj::print(const XPropertySetRef& xOptions) 1530*cdf0e10cSrcweir { 1531*cdf0e10cSrcweir ScUnoGuard aGuard; 1532*cdf0e10cSrcweir if (pDocShell) 1533*cdf0e10cSrcweir { 1534*cdf0e10cSrcweir //! xOptions auswerten (wie denn?) 1535*cdf0e10cSrcweir 1536*cdf0e10cSrcweir //! muss noch 1537*cdf0e10cSrcweir } 1538*cdf0e10cSrcweir } 1539*cdf0e10cSrcweir #endif 1540*cdf0e10cSrcweir 1541*cdf0e10cSrcweir // XGoalSeek 1542*cdf0e10cSrcweir 1543*cdf0e10cSrcweir sheet::GoalResult SAL_CALL ScModelObj::seekGoal( 1544*cdf0e10cSrcweir const table::CellAddress& aFormulaPosition, 1545*cdf0e10cSrcweir const table::CellAddress& aVariablePosition, 1546*cdf0e10cSrcweir const ::rtl::OUString& aGoalValue ) 1547*cdf0e10cSrcweir throw(uno::RuntimeException) 1548*cdf0e10cSrcweir { 1549*cdf0e10cSrcweir ScUnoGuard aGuard; 1550*cdf0e10cSrcweir sheet::GoalResult aResult; 1551*cdf0e10cSrcweir aResult.Divergence = DBL_MAX; // nichts gefunden 1552*cdf0e10cSrcweir if (pDocShell) 1553*cdf0e10cSrcweir { 1554*cdf0e10cSrcweir WaitObject aWait( pDocShell->GetActiveDialogParent() ); 1555*cdf0e10cSrcweir String aGoalString(aGoalValue); 1556*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1557*cdf0e10cSrcweir double fValue = 0.0; 1558*cdf0e10cSrcweir sal_Bool bFound = pDoc->Solver( 1559*cdf0e10cSrcweir (SCCOL)aFormulaPosition.Column, (SCROW)aFormulaPosition.Row, aFormulaPosition.Sheet, 1560*cdf0e10cSrcweir (SCCOL)aVariablePosition.Column, (SCROW)aVariablePosition.Row, aVariablePosition.Sheet, 1561*cdf0e10cSrcweir aGoalString, fValue ); 1562*cdf0e10cSrcweir aResult.Result = fValue; 1563*cdf0e10cSrcweir if (bFound) 1564*cdf0e10cSrcweir aResult.Divergence = 0.0; //! das ist gelogen 1565*cdf0e10cSrcweir } 1566*cdf0e10cSrcweir return aResult; 1567*cdf0e10cSrcweir } 1568*cdf0e10cSrcweir 1569*cdf0e10cSrcweir // XConsolidatable 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir uno::Reference<sheet::XConsolidationDescriptor> SAL_CALL ScModelObj::createConsolidationDescriptor( 1572*cdf0e10cSrcweir sal_Bool bEmpty ) throw(uno::RuntimeException) 1573*cdf0e10cSrcweir { 1574*cdf0e10cSrcweir ScUnoGuard aGuard; 1575*cdf0e10cSrcweir ScConsolidationDescriptor* pNew = new ScConsolidationDescriptor; 1576*cdf0e10cSrcweir if ( pDocShell && !bEmpty ) 1577*cdf0e10cSrcweir { 1578*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1579*cdf0e10cSrcweir const ScConsolidateParam* pParam = pDoc->GetConsolidateDlgData(); 1580*cdf0e10cSrcweir if (pParam) 1581*cdf0e10cSrcweir pNew->SetParam( *pParam ); 1582*cdf0e10cSrcweir } 1583*cdf0e10cSrcweir return pNew; 1584*cdf0e10cSrcweir } 1585*cdf0e10cSrcweir 1586*cdf0e10cSrcweir void SAL_CALL ScModelObj::consolidate( 1587*cdf0e10cSrcweir const uno::Reference<sheet::XConsolidationDescriptor>& xDescriptor ) 1588*cdf0e10cSrcweir throw(uno::RuntimeException) 1589*cdf0e10cSrcweir { 1590*cdf0e10cSrcweir ScUnoGuard aGuard; 1591*cdf0e10cSrcweir // das koennte theoretisch ein fremdes Objekt sein, also nur das 1592*cdf0e10cSrcweir // oeffentliche XConsolidationDescriptor Interface benutzen, um 1593*cdf0e10cSrcweir // die Daten in ein ScConsolidationDescriptor Objekt zu kopieren: 1594*cdf0e10cSrcweir //! wenn es schon ein ScConsolidationDescriptor ist, direkt per getImplementation? 1595*cdf0e10cSrcweir 1596*cdf0e10cSrcweir ScConsolidationDescriptor aImpl; 1597*cdf0e10cSrcweir aImpl.setFunction( xDescriptor->getFunction() ); 1598*cdf0e10cSrcweir aImpl.setSources( xDescriptor->getSources() ); 1599*cdf0e10cSrcweir aImpl.setStartOutputPosition( xDescriptor->getStartOutputPosition() ); 1600*cdf0e10cSrcweir aImpl.setUseColumnHeaders( xDescriptor->getUseColumnHeaders() ); 1601*cdf0e10cSrcweir aImpl.setUseRowHeaders( xDescriptor->getUseRowHeaders() ); 1602*cdf0e10cSrcweir aImpl.setInsertLinks( xDescriptor->getInsertLinks() ); 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir if (pDocShell) 1605*cdf0e10cSrcweir { 1606*cdf0e10cSrcweir const ScConsolidateParam& rParam = aImpl.GetParam(); 1607*cdf0e10cSrcweir pDocShell->DoConsolidate( rParam, sal_True ); 1608*cdf0e10cSrcweir pDocShell->GetDocument()->SetConsolidateDlgData( &rParam ); 1609*cdf0e10cSrcweir } 1610*cdf0e10cSrcweir } 1611*cdf0e10cSrcweir 1612*cdf0e10cSrcweir // XDocumentAuditing 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir void SAL_CALL ScModelObj::refreshArrows() throw(uno::RuntimeException) 1615*cdf0e10cSrcweir { 1616*cdf0e10cSrcweir ScUnoGuard aGuard; 1617*cdf0e10cSrcweir if (pDocShell) 1618*cdf0e10cSrcweir { 1619*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 1620*cdf0e10cSrcweir aFunc.DetectiveRefresh(); 1621*cdf0e10cSrcweir } 1622*cdf0e10cSrcweir } 1623*cdf0e10cSrcweir 1624*cdf0e10cSrcweir // XViewDataSupplier 1625*cdf0e10cSrcweir uno::Reference< container::XIndexAccess > SAL_CALL ScModelObj::getViewData( ) 1626*cdf0e10cSrcweir throw (uno::RuntimeException) 1627*cdf0e10cSrcweir { 1628*cdf0e10cSrcweir uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() ); 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir if( !xRet.is() ) 1631*cdf0e10cSrcweir { 1632*cdf0e10cSrcweir ScUnoGuard aGuard; 1633*cdf0e10cSrcweir if (pDocShell && pDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED) 1634*cdf0e10cSrcweir { 1635*cdf0e10cSrcweir xRet.set(uno::Reference < container::XIndexAccess >::query(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues"))))); 1636*cdf0e10cSrcweir 1637*cdf0e10cSrcweir uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY ); 1638*cdf0e10cSrcweir DBG_ASSERT( xCont.is(), "ScModelObj::getViewData() failed for OLE object" ); 1639*cdf0e10cSrcweir if( xCont.is() ) 1640*cdf0e10cSrcweir { 1641*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aSeq; 1642*cdf0e10cSrcweir aSeq.realloc(1); 1643*cdf0e10cSrcweir String sName; 1644*cdf0e10cSrcweir pDocShell->GetDocument()->GetName( pDocShell->GetDocument()->GetVisibleTab(), sName ); 1645*cdf0e10cSrcweir rtl::OUString sOUName(sName); 1646*cdf0e10cSrcweir aSeq[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE)); 1647*cdf0e10cSrcweir aSeq[0].Value <<= sOUName; 1648*cdf0e10cSrcweir xCont->insertByIndex( 0, uno::makeAny( aSeq ) ); 1649*cdf0e10cSrcweir } 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir } 1652*cdf0e10cSrcweir 1653*cdf0e10cSrcweir return xRet; 1654*cdf0e10cSrcweir } 1655*cdf0e10cSrcweir 1656*cdf0e10cSrcweir // XPropertySet (Doc-Optionen) 1657*cdf0e10cSrcweir //! auch an der Applikation anbieten? 1658*cdf0e10cSrcweir 1659*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScModelObj::getPropertySetInfo() 1660*cdf0e10cSrcweir throw(uno::RuntimeException) 1661*cdf0e10cSrcweir { 1662*cdf0e10cSrcweir ScUnoGuard aGuard; 1663*cdf0e10cSrcweir static uno::Reference<beans::XPropertySetInfo> aRef( 1664*cdf0e10cSrcweir new SfxItemPropertySetInfo( aPropSet.getPropertyMap() )); 1665*cdf0e10cSrcweir return aRef; 1666*cdf0e10cSrcweir } 1667*cdf0e10cSrcweir 1668*cdf0e10cSrcweir void SAL_CALL ScModelObj::setPropertyValue( 1669*cdf0e10cSrcweir const rtl::OUString& aPropertyName, const uno::Any& aValue ) 1670*cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, 1671*cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException, 1672*cdf0e10cSrcweir uno::RuntimeException) 1673*cdf0e10cSrcweir { 1674*cdf0e10cSrcweir ScUnoGuard aGuard; 1675*cdf0e10cSrcweir String aString(aPropertyName); 1676*cdf0e10cSrcweir 1677*cdf0e10cSrcweir if (pDocShell) 1678*cdf0e10cSrcweir { 1679*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1680*cdf0e10cSrcweir const ScDocOptions& rOldOpt = pDoc->GetDocOptions(); 1681*cdf0e10cSrcweir ScDocOptions aNewOpt = rOldOpt; 1682*cdf0e10cSrcweir 1683*cdf0e10cSrcweir sal_Bool bOpt = ScDocOptionsHelper::setPropertyValue( aNewOpt, *aPropSet.getPropertyMap(), aPropertyName, aValue ); 1684*cdf0e10cSrcweir if (bOpt) 1685*cdf0e10cSrcweir { 1686*cdf0e10cSrcweir // done... 1687*cdf0e10cSrcweir } 1688*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNONAME_CLOCAL ) ) 1689*cdf0e10cSrcweir { 1690*cdf0e10cSrcweir lang::Locale aLocale; 1691*cdf0e10cSrcweir if ( aValue >>= aLocale ) 1692*cdf0e10cSrcweir { 1693*cdf0e10cSrcweir LanguageType eLatin, eCjk, eCtl; 1694*cdf0e10cSrcweir pDoc->GetLanguage( eLatin, eCjk, eCtl ); 1695*cdf0e10cSrcweir eLatin = ScUnoConversion::GetLanguage(aLocale); 1696*cdf0e10cSrcweir pDoc->SetLanguage( eLatin, eCjk, eCtl ); 1697*cdf0e10cSrcweir } 1698*cdf0e10cSrcweir } 1699*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_CODENAME ) ) 1700*cdf0e10cSrcweir { 1701*cdf0e10cSrcweir rtl::OUString sCodeName; 1702*cdf0e10cSrcweir if ( aValue >>= sCodeName ) 1703*cdf0e10cSrcweir pDoc->SetCodeName( sCodeName ); 1704*cdf0e10cSrcweir } 1705*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) ) 1706*cdf0e10cSrcweir { 1707*cdf0e10cSrcweir lang::Locale aLocale; 1708*cdf0e10cSrcweir if ( aValue >>= aLocale ) 1709*cdf0e10cSrcweir { 1710*cdf0e10cSrcweir LanguageType eLatin, eCjk, eCtl; 1711*cdf0e10cSrcweir pDoc->GetLanguage( eLatin, eCjk, eCtl ); 1712*cdf0e10cSrcweir eCjk = ScUnoConversion::GetLanguage(aLocale); 1713*cdf0e10cSrcweir pDoc->SetLanguage( eLatin, eCjk, eCtl ); 1714*cdf0e10cSrcweir } 1715*cdf0e10cSrcweir } 1716*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_CTL_CLOCAL ) ) 1717*cdf0e10cSrcweir { 1718*cdf0e10cSrcweir lang::Locale aLocale; 1719*cdf0e10cSrcweir if ( aValue >>= aLocale ) 1720*cdf0e10cSrcweir { 1721*cdf0e10cSrcweir LanguageType eLatin, eCjk, eCtl; 1722*cdf0e10cSrcweir pDoc->GetLanguage( eLatin, eCjk, eCtl ); 1723*cdf0e10cSrcweir eCtl = ScUnoConversion::GetLanguage(aLocale); 1724*cdf0e10cSrcweir pDoc->SetLanguage( eLatin, eCjk, eCtl ); 1725*cdf0e10cSrcweir } 1726*cdf0e10cSrcweir } 1727*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_APPLYFMDES ) ) 1728*cdf0e10cSrcweir { 1729*cdf0e10cSrcweir // model is created if not there 1730*cdf0e10cSrcweir ScDrawLayer* pModel = pDocShell->MakeDrawLayer(); 1731*cdf0e10cSrcweir pModel->SetOpenInDesignMode( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir SfxBindings* pBindings = pDocShell->GetViewBindings(); 1734*cdf0e10cSrcweir if (pBindings) 1735*cdf0e10cSrcweir pBindings->Invalidate( SID_FM_OPEN_READONLY ); 1736*cdf0e10cSrcweir } 1737*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_AUTOCONTFOC ) ) 1738*cdf0e10cSrcweir { 1739*cdf0e10cSrcweir // model is created if not there 1740*cdf0e10cSrcweir ScDrawLayer* pModel = pDocShell->MakeDrawLayer(); 1741*cdf0e10cSrcweir pModel->SetAutoControlFocus( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1742*cdf0e10cSrcweir 1743*cdf0e10cSrcweir SfxBindings* pBindings = pDocShell->GetViewBindings(); 1744*cdf0e10cSrcweir if (pBindings) 1745*cdf0e10cSrcweir pBindings->Invalidate( SID_FM_AUTOCONTROLFOCUS ); 1746*cdf0e10cSrcweir } 1747*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISLOADED ) ) 1748*cdf0e10cSrcweir { 1749*cdf0e10cSrcweir pDocShell->SetEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1750*cdf0e10cSrcweir } 1751*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISUNDOENABLED ) ) 1752*cdf0e10cSrcweir { 1753*cdf0e10cSrcweir sal_Bool bUndoEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 1754*cdf0e10cSrcweir pDoc->EnableUndo( bUndoEnabled ); 1755*cdf0e10cSrcweir sal_uInt16 nCount = ( bUndoEnabled ? 1756*cdf0e10cSrcweir static_cast< sal_uInt16 >( SvtUndoOptions().GetUndoCount() ) : 0 ); 1757*cdf0e10cSrcweir pDocShell->GetUndoManager()->SetMaxUndoActionCount( nCount ); 1758*cdf0e10cSrcweir } 1759*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED ) ) 1760*cdf0e10cSrcweir { 1761*cdf0e10cSrcweir bool bOldAdjustHeightEnabled = pDoc->IsAdjustHeightEnabled(); 1762*cdf0e10cSrcweir bool bAdjustHeightEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 1763*cdf0e10cSrcweir if( bOldAdjustHeightEnabled != bAdjustHeightEnabled ) 1764*cdf0e10cSrcweir { 1765*cdf0e10cSrcweir pDoc->EnableAdjustHeight( bAdjustHeightEnabled ); 1766*cdf0e10cSrcweir if( bAdjustHeightEnabled ) 1767*cdf0e10cSrcweir pDocShell->UpdateAllRowHeights(); 1768*cdf0e10cSrcweir } 1769*cdf0e10cSrcweir } 1770*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED ) ) 1771*cdf0e10cSrcweir { 1772*cdf0e10cSrcweir pDoc->EnableExecuteLink( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1773*cdf0e10cSrcweir } 1774*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED ) ) 1775*cdf0e10cSrcweir { 1776*cdf0e10cSrcweir pDoc->EnableChangeReadOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1777*cdf0e10cSrcweir } 1778*cdf0e10cSrcweir else if ( aString.EqualsAscii( "BuildId" ) ) 1779*cdf0e10cSrcweir { 1780*cdf0e10cSrcweir aValue >>= maBuildId; 1781*cdf0e10cSrcweir } 1782*cdf0e10cSrcweir else if ( aString.EqualsAscii( "SavedObject" ) ) // set from chart after saving 1783*cdf0e10cSrcweir { 1784*cdf0e10cSrcweir rtl::OUString aObjName; 1785*cdf0e10cSrcweir aValue >>= aObjName; 1786*cdf0e10cSrcweir if ( aObjName.getLength() ) 1787*cdf0e10cSrcweir pDoc->RestoreChartListener( aObjName ); 1788*cdf0e10cSrcweir } 1789*cdf0e10cSrcweir 1790*cdf0e10cSrcweir if ( aNewOpt != rOldOpt ) 1791*cdf0e10cSrcweir { 1792*cdf0e10cSrcweir pDoc->SetDocOptions( aNewOpt ); 1793*cdf0e10cSrcweir // Don't recalculate while loading XML, when the formula text is stored. 1794*cdf0e10cSrcweir // Recalculation after loading is handled separately. 1795*cdf0e10cSrcweir //! Recalc only for options that need it? 1796*cdf0e10cSrcweir if ( !pDoc->IsImportingXML() ) 1797*cdf0e10cSrcweir pDocShell->DoHardRecalc( sal_True ); 1798*cdf0e10cSrcweir pDocShell->SetDocumentModified(); 1799*cdf0e10cSrcweir } 1800*cdf0e10cSrcweir } 1801*cdf0e10cSrcweir } 1802*cdf0e10cSrcweir 1803*cdf0e10cSrcweir uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyName ) 1804*cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, 1805*cdf0e10cSrcweir uno::RuntimeException) 1806*cdf0e10cSrcweir { 1807*cdf0e10cSrcweir ScUnoGuard aGuard; 1808*cdf0e10cSrcweir String aString(aPropertyName); 1809*cdf0e10cSrcweir uno::Any aRet; 1810*cdf0e10cSrcweir 1811*cdf0e10cSrcweir if (pDocShell) 1812*cdf0e10cSrcweir { 1813*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1814*cdf0e10cSrcweir const ScDocOptions& rOpt = pDoc->GetDocOptions(); 1815*cdf0e10cSrcweir aRet = ScDocOptionsHelper::getPropertyValue( rOpt, *aPropSet.getPropertyMap(), aPropertyName ); 1816*cdf0e10cSrcweir if ( aRet.hasValue() ) 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir // done... 1819*cdf0e10cSrcweir } 1820*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNONAME_CLOCAL ) ) 1821*cdf0e10cSrcweir { 1822*cdf0e10cSrcweir LanguageType eLatin, eCjk, eCtl; 1823*cdf0e10cSrcweir pDoc->GetLanguage( eLatin, eCjk, eCtl ); 1824*cdf0e10cSrcweir 1825*cdf0e10cSrcweir lang::Locale aLocale; 1826*cdf0e10cSrcweir ScUnoConversion::FillLocale( aLocale, eLatin ); 1827*cdf0e10cSrcweir aRet <<= aLocale; 1828*cdf0e10cSrcweir } 1829*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_CODENAME ) ) 1830*cdf0e10cSrcweir { 1831*cdf0e10cSrcweir rtl::OUString sCodeName = pDoc->GetCodeName(); 1832*cdf0e10cSrcweir aRet <<= sCodeName; 1833*cdf0e10cSrcweir } 1834*cdf0e10cSrcweir 1835*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) ) 1836*cdf0e10cSrcweir { 1837*cdf0e10cSrcweir LanguageType eLatin, eCjk, eCtl; 1838*cdf0e10cSrcweir pDoc->GetLanguage( eLatin, eCjk, eCtl ); 1839*cdf0e10cSrcweir 1840*cdf0e10cSrcweir lang::Locale aLocale; 1841*cdf0e10cSrcweir ScUnoConversion::FillLocale( aLocale, eCjk ); 1842*cdf0e10cSrcweir aRet <<= aLocale; 1843*cdf0e10cSrcweir } 1844*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_CTL_CLOCAL ) ) 1845*cdf0e10cSrcweir { 1846*cdf0e10cSrcweir LanguageType eLatin, eCjk, eCtl; 1847*cdf0e10cSrcweir pDoc->GetLanguage( eLatin, eCjk, eCtl ); 1848*cdf0e10cSrcweir 1849*cdf0e10cSrcweir lang::Locale aLocale; 1850*cdf0e10cSrcweir ScUnoConversion::FillLocale( aLocale, eCtl ); 1851*cdf0e10cSrcweir aRet <<= aLocale; 1852*cdf0e10cSrcweir } 1853*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_NAMEDRANGES ) ) 1854*cdf0e10cSrcweir { 1855*cdf0e10cSrcweir aRet <<= uno::Reference<sheet::XNamedRanges>(new ScNamedRangesObj( pDocShell )); 1856*cdf0e10cSrcweir } 1857*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_DATABASERNG ) ) 1858*cdf0e10cSrcweir { 1859*cdf0e10cSrcweir aRet <<= uno::Reference<sheet::XDatabaseRanges>(new ScDatabaseRangesObj( pDocShell )); 1860*cdf0e10cSrcweir } 1861*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_COLLABELRNG ) ) 1862*cdf0e10cSrcweir { 1863*cdf0e10cSrcweir aRet <<= uno::Reference<sheet::XLabelRanges>(new ScLabelRangesObj( pDocShell, sal_True )); 1864*cdf0e10cSrcweir } 1865*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ROWLABELRNG ) ) 1866*cdf0e10cSrcweir { 1867*cdf0e10cSrcweir aRet <<= uno::Reference<sheet::XLabelRanges>(new ScLabelRangesObj( pDocShell, sal_False )); 1868*cdf0e10cSrcweir } 1869*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_AREALINKS ) ) 1870*cdf0e10cSrcweir { 1871*cdf0e10cSrcweir aRet <<= uno::Reference<sheet::XAreaLinks>(new ScAreaLinksObj( pDocShell )); 1872*cdf0e10cSrcweir } 1873*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_DDELINKS ) ) 1874*cdf0e10cSrcweir { 1875*cdf0e10cSrcweir aRet <<= uno::Reference<container::XNameAccess>(new ScDDELinksObj( pDocShell )); 1876*cdf0e10cSrcweir } 1877*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_EXTERNALDOCLINKS ) ) 1878*cdf0e10cSrcweir { 1879*cdf0e10cSrcweir aRet <<= uno::Reference<sheet::XExternalDocLinks>(new ScExternalDocLinksObj(pDocShell)); 1880*cdf0e10cSrcweir } 1881*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_SHEETLINKS ) ) 1882*cdf0e10cSrcweir { 1883*cdf0e10cSrcweir aRet <<= uno::Reference<container::XNameAccess>(new ScSheetLinksObj( pDocShell )); 1884*cdf0e10cSrcweir } 1885*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_APPLYFMDES ) ) 1886*cdf0e10cSrcweir { 1887*cdf0e10cSrcweir // default for no model is TRUE 1888*cdf0e10cSrcweir ScDrawLayer* pModel = pDoc->GetDrawLayer(); 1889*cdf0e10cSrcweir sal_Bool bOpenInDesign = pModel ? pModel->GetOpenInDesignMode() : sal_True; 1890*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, bOpenInDesign ); 1891*cdf0e10cSrcweir } 1892*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_AUTOCONTFOC ) ) 1893*cdf0e10cSrcweir { 1894*cdf0e10cSrcweir // default for no model is FALSE 1895*cdf0e10cSrcweir ScDrawLayer* pModel = pDoc->GetDrawLayer(); 1896*cdf0e10cSrcweir sal_Bool bAutoControlFocus = pModel ? pModel->GetAutoControlFocus() : sal_False; 1897*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, bAutoControlFocus ); 1898*cdf0e10cSrcweir } 1899*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_FORBIDDEN ) ) 1900*cdf0e10cSrcweir { 1901*cdf0e10cSrcweir aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell )); 1902*cdf0e10cSrcweir } 1903*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_HASDRAWPAGES ) ) 1904*cdf0e10cSrcweir { 1905*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetDocument()->GetDrawLayer() != 0) ); 1906*cdf0e10cSrcweir } 1907*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_BASICLIBRARIES ) ) 1908*cdf0e10cSrcweir { 1909*cdf0e10cSrcweir aRet <<= pDocShell->GetBasicContainer(); 1910*cdf0e10cSrcweir } 1911*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_DIALOGLIBRARIES ) ) 1912*cdf0e10cSrcweir { 1913*cdf0e10cSrcweir aRet <<= pDocShell->GetDialogContainer(); 1914*cdf0e10cSrcweir } 1915*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_VBAGLOBNAME ) ) 1916*cdf0e10cSrcweir { 1917*cdf0e10cSrcweir /* #i111553# This property provides the name of the constant that 1918*cdf0e10cSrcweir will be used to store this model in the global Basic manager. 1919*cdf0e10cSrcweir That constant will be equivelant to 'ThisComponent' but for 1920*cdf0e10cSrcweir each application, so e.g. a 'ThisExcelDoc' and a 'ThisWordDoc' 1921*cdf0e10cSrcweir constant can co-exist, as required by VBA. */ 1922*cdf0e10cSrcweir aRet <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisExcelDoc" ) ); 1923*cdf0e10cSrcweir } 1924*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_RUNTIMEUID ) ) 1925*cdf0e10cSrcweir { 1926*cdf0e10cSrcweir aRet <<= getRuntimeUID(); 1927*cdf0e10cSrcweir } 1928*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_HASVALIDSIGNATURES ) ) 1929*cdf0e10cSrcweir { 1930*cdf0e10cSrcweir aRet <<= hasValidSignatures(); 1931*cdf0e10cSrcweir } 1932*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISLOADED ) ) 1933*cdf0e10cSrcweir { 1934*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, !pDocShell->IsEmpty() ); 1935*cdf0e10cSrcweir } 1936*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISUNDOENABLED ) ) 1937*cdf0e10cSrcweir { 1938*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsUndoEnabled() ); 1939*cdf0e10cSrcweir } 1940*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED ) ) 1941*cdf0e10cSrcweir { 1942*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsAdjustHeightEnabled() ); 1943*cdf0e10cSrcweir } 1944*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED ) ) 1945*cdf0e10cSrcweir { 1946*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsExecuteLinkEnabled() ); 1947*cdf0e10cSrcweir } 1948*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED ) ) 1949*cdf0e10cSrcweir { 1950*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsChangeReadOnlyEnabled() ); 1951*cdf0e10cSrcweir } 1952*cdf0e10cSrcweir else if ( aString.EqualsAscii( SC_UNO_REFERENCEDEVICE ) ) 1953*cdf0e10cSrcweir { 1954*cdf0e10cSrcweir VCLXDevice* pXDev = new VCLXDevice(); 1955*cdf0e10cSrcweir pXDev->SetOutputDevice( pDoc->GetRefDevice() ); 1956*cdf0e10cSrcweir aRet <<= uno::Reference< awt::XDevice >( pXDev ); 1957*cdf0e10cSrcweir } 1958*cdf0e10cSrcweir else if ( aString.EqualsAscii( "BuildId" ) ) 1959*cdf0e10cSrcweir { 1960*cdf0e10cSrcweir aRet <<= maBuildId; 1961*cdf0e10cSrcweir } 1962*cdf0e10cSrcweir else if ( aString.EqualsAscii( "InternalDocument" ) ) 1963*cdf0e10cSrcweir { 1964*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL) ); 1965*cdf0e10cSrcweir } 1966*cdf0e10cSrcweir } 1967*cdf0e10cSrcweir 1968*cdf0e10cSrcweir return aRet; 1969*cdf0e10cSrcweir } 1970*cdf0e10cSrcweir 1971*cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScModelObj ) 1972*cdf0e10cSrcweir 1973*cdf0e10cSrcweir // XMultiServiceFactory 1974*cdf0e10cSrcweir 1975*cdf0e10cSrcweir uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance( 1976*cdf0e10cSrcweir const rtl::OUString& aServiceSpecifier ) 1977*cdf0e10cSrcweir throw(uno::Exception, uno::RuntimeException) 1978*cdf0e10cSrcweir { 1979*cdf0e10cSrcweir ScUnoGuard aGuard; 1980*cdf0e10cSrcweir uno::Reference<uno::XInterface> xRet; 1981*cdf0e10cSrcweir String aNameStr(aServiceSpecifier); 1982*cdf0e10cSrcweir sal_uInt16 nType = ScServiceProvider::GetProviderType(aNameStr); 1983*cdf0e10cSrcweir if ( nType != SC_SERVICE_INVALID ) 1984*cdf0e10cSrcweir { 1985*cdf0e10cSrcweir // drawing layer tables must be kept as long as the model is alive 1986*cdf0e10cSrcweir // return stored instance if already set 1987*cdf0e10cSrcweir switch ( nType ) 1988*cdf0e10cSrcweir { 1989*cdf0e10cSrcweir case SC_SERVICE_GRADTAB: xRet.set(xDrawGradTab); break; 1990*cdf0e10cSrcweir case SC_SERVICE_HATCHTAB: xRet.set(xDrawHatchTab); break; 1991*cdf0e10cSrcweir case SC_SERVICE_BITMAPTAB: xRet.set(xDrawBitmapTab); break; 1992*cdf0e10cSrcweir case SC_SERVICE_TRGRADTAB: xRet.set(xDrawTrGradTab); break; 1993*cdf0e10cSrcweir case SC_SERVICE_MARKERTAB: xRet.set(xDrawMarkerTab); break; 1994*cdf0e10cSrcweir case SC_SERVICE_DASHTAB: xRet.set(xDrawDashTab); break; 1995*cdf0e10cSrcweir case SC_SERVICE_CHDATAPROV: xRet.set(xChartDataProv); break; 1996*cdf0e10cSrcweir case SC_SERVICE_VBAOBJECTPROVIDER: xRet.set(xObjProvider); break; 1997*cdf0e10cSrcweir } 1998*cdf0e10cSrcweir 1999*cdf0e10cSrcweir // #i64497# If a chart is in a temporary document during clipoard paste, 2000*cdf0e10cSrcweir // there should be no data provider, so that own data is used 2001*cdf0e10cSrcweir bool bCreate = 2002*cdf0e10cSrcweir ! ( nType == SC_SERVICE_CHDATAPROV && 2003*cdf0e10cSrcweir ( pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL )); 2004*cdf0e10cSrcweir // this should never happen, i.e. the temporary document should never be 2005*cdf0e10cSrcweir // loaded, becuase this unlinks the data 2006*cdf0e10cSrcweir OSL_ASSERT( bCreate ); 2007*cdf0e10cSrcweir 2008*cdf0e10cSrcweir if ( !xRet.is() && bCreate ) 2009*cdf0e10cSrcweir { 2010*cdf0e10cSrcweir xRet.set(ScServiceProvider::MakeInstance( nType, pDocShell )); 2011*cdf0e10cSrcweir 2012*cdf0e10cSrcweir // store created instance 2013*cdf0e10cSrcweir switch ( nType ) 2014*cdf0e10cSrcweir { 2015*cdf0e10cSrcweir case SC_SERVICE_GRADTAB: xDrawGradTab.set(xRet); break; 2016*cdf0e10cSrcweir case SC_SERVICE_HATCHTAB: xDrawHatchTab.set(xRet); break; 2017*cdf0e10cSrcweir case SC_SERVICE_BITMAPTAB: xDrawBitmapTab.set(xRet); break; 2018*cdf0e10cSrcweir case SC_SERVICE_TRGRADTAB: xDrawTrGradTab.set(xRet); break; 2019*cdf0e10cSrcweir case SC_SERVICE_MARKERTAB: xDrawMarkerTab.set(xRet); break; 2020*cdf0e10cSrcweir case SC_SERVICE_DASHTAB: xDrawDashTab.set(xRet); break; 2021*cdf0e10cSrcweir case SC_SERVICE_CHDATAPROV: xChartDataProv.set(xRet); break; 2022*cdf0e10cSrcweir case SC_SERVICE_VBAOBJECTPROVIDER: xObjProvider.set(xRet); break; 2023*cdf0e10cSrcweir } 2024*cdf0e10cSrcweir } 2025*cdf0e10cSrcweir } 2026*cdf0e10cSrcweir else 2027*cdf0e10cSrcweir { 2028*cdf0e10cSrcweir // alles was ich nicht kenn, werf ich der SvxFmMSFactory an den Hals, 2029*cdf0e10cSrcweir // da wird dann 'ne Exception geworfen, wenn's nicht passt... 2030*cdf0e10cSrcweir 2031*cdf0e10cSrcweir try 2032*cdf0e10cSrcweir { 2033*cdf0e10cSrcweir xRet.set(SvxFmMSFactory::createInstance(aServiceSpecifier)); 2034*cdf0e10cSrcweir // extra block to force deletion of the temporary before ScShapeObj ctor (setDelegator) 2035*cdf0e10cSrcweir } 2036*cdf0e10cSrcweir catch ( lang::ServiceNotRegisteredException & ) 2037*cdf0e10cSrcweir { 2038*cdf0e10cSrcweir } 2039*cdf0e10cSrcweir 2040*cdf0e10cSrcweir // #96117# if the drawing factory created a shape, a ScShapeObj has to be used 2041*cdf0e10cSrcweir // to support own properties like ImageMap: 2042*cdf0e10cSrcweir 2043*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape( xRet, uno::UNO_QUERY ); 2044*cdf0e10cSrcweir if ( xShape.is() ) 2045*cdf0e10cSrcweir { 2046*cdf0e10cSrcweir xRet.clear(); // for aggregation, xShape must be the object's only ref 2047*cdf0e10cSrcweir new ScShapeObj( xShape ); // aggregates object and modifies xShape 2048*cdf0e10cSrcweir xRet.set(xShape); 2049*cdf0e10cSrcweir } 2050*cdf0e10cSrcweir } 2051*cdf0e10cSrcweir return xRet; 2052*cdf0e10cSrcweir } 2053*cdf0e10cSrcweir 2054*cdf0e10cSrcweir uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstanceWithArguments( 2055*cdf0e10cSrcweir const rtl::OUString& ServiceSpecifier, 2056*cdf0e10cSrcweir const uno::Sequence<uno::Any>& aArgs ) 2057*cdf0e10cSrcweir throw(uno::Exception, uno::RuntimeException) 2058*cdf0e10cSrcweir { 2059*cdf0e10cSrcweir //! unterscheiden zwischen eigenen Services und denen vom Drawing-Layer? 2060*cdf0e10cSrcweir 2061*cdf0e10cSrcweir ScUnoGuard aGuard; 2062*cdf0e10cSrcweir uno::Reference<uno::XInterface> xInt(createInstance(ServiceSpecifier)); 2063*cdf0e10cSrcweir 2064*cdf0e10cSrcweir if ( aArgs.getLength() ) 2065*cdf0e10cSrcweir { 2066*cdf0e10cSrcweir // used only for cell value binding so far - it can be initialized after creating 2067*cdf0e10cSrcweir 2068*cdf0e10cSrcweir uno::Reference<lang::XInitialization> xInit( xInt, uno::UNO_QUERY ); 2069*cdf0e10cSrcweir if ( xInit.is() ) 2070*cdf0e10cSrcweir xInit->initialize( aArgs ); 2071*cdf0e10cSrcweir } 2072*cdf0e10cSrcweir 2073*cdf0e10cSrcweir return xInt; 2074*cdf0e10cSrcweir } 2075*cdf0e10cSrcweir 2076*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getAvailableServiceNames() 2077*cdf0e10cSrcweir throw(uno::RuntimeException) 2078*cdf0e10cSrcweir { 2079*cdf0e10cSrcweir ScUnoGuard aGuard; 2080*cdf0e10cSrcweir 2081*cdf0e10cSrcweir //! warum sind die Parameter bei concatServiceNames nicht const ??? 2082*cdf0e10cSrcweir //! return concatServiceNames( ScServiceProvider::GetAllServiceNames(), 2083*cdf0e10cSrcweir //! SvxFmMSFactory::getAvailableServiceNames() ); 2084*cdf0e10cSrcweir 2085*cdf0e10cSrcweir uno::Sequence<rtl::OUString> aMyServices(ScServiceProvider::GetAllServiceNames()); 2086*cdf0e10cSrcweir uno::Sequence<rtl::OUString> aDrawServices(SvxFmMSFactory::getAvailableServiceNames()); 2087*cdf0e10cSrcweir 2088*cdf0e10cSrcweir return concatServiceNames( aMyServices, aDrawServices ); 2089*cdf0e10cSrcweir } 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir // XServiceInfo 2092*cdf0e10cSrcweir 2093*cdf0e10cSrcweir rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException) 2094*cdf0e10cSrcweir { 2095*cdf0e10cSrcweir return rtl::OUString::createFromAscii( "ScModelObj" ); 2096*cdf0e10cSrcweir } 2097*cdf0e10cSrcweir 2098*cdf0e10cSrcweir sal_Bool SAL_CALL ScModelObj::supportsService( const rtl::OUString& rServiceName ) 2099*cdf0e10cSrcweir throw(uno::RuntimeException) 2100*cdf0e10cSrcweir { 2101*cdf0e10cSrcweir String aServiceStr(rServiceName); 2102*cdf0e10cSrcweir return aServiceStr.EqualsAscii( SCMODELOBJ_SERVICE ) || 2103*cdf0e10cSrcweir aServiceStr.EqualsAscii( SCDOCSETTINGS_SERVICE ) || 2104*cdf0e10cSrcweir aServiceStr.EqualsAscii( SCDOC_SERVICE ); 2105*cdf0e10cSrcweir } 2106*cdf0e10cSrcweir 2107*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getSupportedServiceNames() 2108*cdf0e10cSrcweir throw(uno::RuntimeException) 2109*cdf0e10cSrcweir { 2110*cdf0e10cSrcweir uno::Sequence<rtl::OUString> aRet(2); 2111*cdf0e10cSrcweir rtl::OUString* pArray = aRet.getArray(); 2112*cdf0e10cSrcweir pArray[0] = rtl::OUString::createFromAscii( SCMODELOBJ_SERVICE ); 2113*cdf0e10cSrcweir pArray[1] = rtl::OUString::createFromAscii( SCDOCSETTINGS_SERVICE ); 2114*cdf0e10cSrcweir return aRet; 2115*cdf0e10cSrcweir } 2116*cdf0e10cSrcweir 2117*cdf0e10cSrcweir // XUnoTunnel 2118*cdf0e10cSrcweir 2119*cdf0e10cSrcweir sal_Int64 SAL_CALL ScModelObj::getSomething( 2120*cdf0e10cSrcweir const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) 2121*cdf0e10cSrcweir { 2122*cdf0e10cSrcweir if ( rId.getLength() == 16 && 2123*cdf0e10cSrcweir 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 2124*cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 2125*cdf0e10cSrcweir { 2126*cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 2127*cdf0e10cSrcweir } 2128*cdf0e10cSrcweir 2129*cdf0e10cSrcweir if ( rId.getLength() == 16 && 2130*cdf0e10cSrcweir 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(), 2131*cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 2132*cdf0e10cSrcweir { 2133*cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell )); 2134*cdf0e10cSrcweir } 2135*cdf0e10cSrcweir 2136*cdf0e10cSrcweir // aggregated number formats supplier has XUnoTunnel, too 2137*cdf0e10cSrcweir // interface from aggregated object must be obtained via queryAggregation 2138*cdf0e10cSrcweir 2139*cdf0e10cSrcweir sal_Int64 nRet = SfxBaseModel::getSomething( rId ); 2140*cdf0e10cSrcweir if ( nRet ) 2141*cdf0e10cSrcweir return nRet; 2142*cdf0e10cSrcweir 2143*cdf0e10cSrcweir if ( GetFormatter().is() ) 2144*cdf0e10cSrcweir { 2145*cdf0e10cSrcweir const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*) 0); 2146*cdf0e10cSrcweir uno::Any aNumTunnel(xNumberAgg->queryAggregation(rTunnelType)); 2147*cdf0e10cSrcweir if(aNumTunnel.getValueType() == rTunnelType) 2148*cdf0e10cSrcweir { 2149*cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xTunnelAgg( 2150*cdf0e10cSrcweir *(uno::Reference<lang::XUnoTunnel>*)aNumTunnel.getValue()); 2151*cdf0e10cSrcweir return xTunnelAgg->getSomething( rId ); 2152*cdf0e10cSrcweir } 2153*cdf0e10cSrcweir } 2154*cdf0e10cSrcweir 2155*cdf0e10cSrcweir return 0; 2156*cdf0e10cSrcweir } 2157*cdf0e10cSrcweir 2158*cdf0e10cSrcweir // static 2159*cdf0e10cSrcweir const uno::Sequence<sal_Int8>& ScModelObj::getUnoTunnelId() 2160*cdf0e10cSrcweir { 2161*cdf0e10cSrcweir static uno::Sequence<sal_Int8> * pSeq = 0; 2162*cdf0e10cSrcweir if( !pSeq ) 2163*cdf0e10cSrcweir { 2164*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 2165*cdf0e10cSrcweir if( !pSeq ) 2166*cdf0e10cSrcweir { 2167*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 2168*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 2169*cdf0e10cSrcweir pSeq = &aSeq; 2170*cdf0e10cSrcweir } 2171*cdf0e10cSrcweir } 2172*cdf0e10cSrcweir return *pSeq; 2173*cdf0e10cSrcweir } 2174*cdf0e10cSrcweir 2175*cdf0e10cSrcweir // static 2176*cdf0e10cSrcweir ScModelObj* ScModelObj::getImplementation( const uno::Reference<uno::XInterface> xObj ) 2177*cdf0e10cSrcweir { 2178*cdf0e10cSrcweir ScModelObj* pRet = NULL; 2179*cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); 2180*cdf0e10cSrcweir if (xUT.is()) 2181*cdf0e10cSrcweir pRet = reinterpret_cast<ScModelObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId()))); 2182*cdf0e10cSrcweir return pRet; 2183*cdf0e10cSrcweir } 2184*cdf0e10cSrcweir 2185*cdf0e10cSrcweir // XChangesNotifier 2186*cdf0e10cSrcweir 2187*cdf0e10cSrcweir void ScModelObj::addChangesListener( const uno::Reference< util::XChangesListener >& aListener ) 2188*cdf0e10cSrcweir throw (uno::RuntimeException) 2189*cdf0e10cSrcweir { 2190*cdf0e10cSrcweir ScUnoGuard aGuard; 2191*cdf0e10cSrcweir maChangesListeners.addInterface( aListener ); 2192*cdf0e10cSrcweir } 2193*cdf0e10cSrcweir 2194*cdf0e10cSrcweir void ScModelObj::removeChangesListener( const uno::Reference< util::XChangesListener >& aListener ) 2195*cdf0e10cSrcweir throw (uno::RuntimeException) 2196*cdf0e10cSrcweir { 2197*cdf0e10cSrcweir ScUnoGuard aGuard; 2198*cdf0e10cSrcweir maChangesListeners.removeInterface( aListener ); 2199*cdf0e10cSrcweir } 2200*cdf0e10cSrcweir 2201*cdf0e10cSrcweir bool ScModelObj::HasChangesListeners() const 2202*cdf0e10cSrcweir { 2203*cdf0e10cSrcweir if ( maChangesListeners.getLength() > 0 ) 2204*cdf0e10cSrcweir return true; 2205*cdf0e10cSrcweir 2206*cdf0e10cSrcweir // "change" event set in any sheet? 2207*cdf0e10cSrcweir return pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript(SC_SHEETEVENT_CHANGE); 2208*cdf0e10cSrcweir } 2209*cdf0e10cSrcweir 2210*cdf0e10cSrcweir void ScModelObj::NotifyChanges( const ::rtl::OUString& rOperation, const ScRangeList& rRanges, 2211*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rProperties ) 2212*cdf0e10cSrcweir { 2213*cdf0e10cSrcweir if ( pDocShell && HasChangesListeners() ) 2214*cdf0e10cSrcweir { 2215*cdf0e10cSrcweir util::ChangesEvent aEvent; 2216*cdf0e10cSrcweir aEvent.Source.set( static_cast< cppu::OWeakObject* >( this ) ); 2217*cdf0e10cSrcweir aEvent.Base <<= aEvent.Source; 2218*cdf0e10cSrcweir 2219*cdf0e10cSrcweir sal_uLong nRangeCount = rRanges.Count(); 2220*cdf0e10cSrcweir aEvent.Changes.realloc( static_cast< sal_Int32 >( nRangeCount ) ); 2221*cdf0e10cSrcweir for ( sal_uLong nIndex = 0; nIndex < nRangeCount; ++nIndex ) 2222*cdf0e10cSrcweir { 2223*cdf0e10cSrcweir uno::Reference< table::XCellRange > xRangeObj; 2224*cdf0e10cSrcweir 2225*cdf0e10cSrcweir ScRange aRange( *rRanges.GetObject( nIndex ) ); 2226*cdf0e10cSrcweir if ( aRange.aStart == aRange.aEnd ) 2227*cdf0e10cSrcweir { 2228*cdf0e10cSrcweir xRangeObj.set( new ScCellObj( pDocShell, aRange.aStart ) ); 2229*cdf0e10cSrcweir } 2230*cdf0e10cSrcweir else 2231*cdf0e10cSrcweir { 2232*cdf0e10cSrcweir xRangeObj.set( new ScCellRangeObj( pDocShell, aRange ) ); 2233*cdf0e10cSrcweir } 2234*cdf0e10cSrcweir 2235*cdf0e10cSrcweir util::ElementChange& rChange = aEvent.Changes[ static_cast< sal_Int32 >( nIndex ) ]; 2236*cdf0e10cSrcweir rChange.Accessor <<= rOperation; 2237*cdf0e10cSrcweir rChange.Element <<= rProperties; 2238*cdf0e10cSrcweir rChange.ReplacedElement <<= xRangeObj; 2239*cdf0e10cSrcweir } 2240*cdf0e10cSrcweir 2241*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( maChangesListeners ); 2242*cdf0e10cSrcweir while ( aIter.hasMoreElements() ) 2243*cdf0e10cSrcweir { 2244*cdf0e10cSrcweir try 2245*cdf0e10cSrcweir { 2246*cdf0e10cSrcweir static_cast< util::XChangesListener* >( aIter.next() )->changesOccurred( aEvent ); 2247*cdf0e10cSrcweir } 2248*cdf0e10cSrcweir catch( uno::Exception& ) 2249*cdf0e10cSrcweir { 2250*cdf0e10cSrcweir } 2251*cdf0e10cSrcweir } 2252*cdf0e10cSrcweir } 2253*cdf0e10cSrcweir 2254*cdf0e10cSrcweir // handle sheet events 2255*cdf0e10cSrcweir //! separate method with ScMarkData? Then change HasChangesListeners back. 2256*cdf0e10cSrcweir if ( rOperation.compareToAscii("cell-change") == 0 && pDocShell ) 2257*cdf0e10cSrcweir { 2258*cdf0e10cSrcweir ScMarkData aMarkData; 2259*cdf0e10cSrcweir aMarkData.MarkFromRangeList( rRanges, sal_False ); 2260*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2261*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 2262*cdf0e10cSrcweir for (SCTAB nTab = 0; nTab < nTabCount; nTab++) 2263*cdf0e10cSrcweir if (aMarkData.GetTableSelect(nTab)) 2264*cdf0e10cSrcweir { 2265*cdf0e10cSrcweir const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); 2266*cdf0e10cSrcweir if (pEvents) 2267*cdf0e10cSrcweir { 2268*cdf0e10cSrcweir const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CHANGE); 2269*cdf0e10cSrcweir if (pScript) 2270*cdf0e10cSrcweir { 2271*cdf0e10cSrcweir ScRangeList aTabRanges; // collect ranges on this sheet 2272*cdf0e10cSrcweir sal_uLong nRangeCount = rRanges.Count(); 2273*cdf0e10cSrcweir for ( sal_uLong nIndex = 0; nIndex < nRangeCount; ++nIndex ) 2274*cdf0e10cSrcweir { 2275*cdf0e10cSrcweir ScRange aRange( *rRanges.GetObject( nIndex ) ); 2276*cdf0e10cSrcweir if ( aRange.aStart.Tab() == nTab ) 2277*cdf0e10cSrcweir aTabRanges.Append( aRange ); 2278*cdf0e10cSrcweir } 2279*cdf0e10cSrcweir sal_uLong nTabRangeCount = aTabRanges.Count(); 2280*cdf0e10cSrcweir if ( nTabRangeCount > 0 ) 2281*cdf0e10cSrcweir { 2282*cdf0e10cSrcweir uno::Reference<uno::XInterface> xTarget; 2283*cdf0e10cSrcweir if ( nTabRangeCount == 1 ) 2284*cdf0e10cSrcweir { 2285*cdf0e10cSrcweir ScRange aRange( *aTabRanges.GetObject( 0 ) ); 2286*cdf0e10cSrcweir if ( aRange.aStart == aRange.aEnd ) 2287*cdf0e10cSrcweir xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellObj( pDocShell, aRange.aStart ) ) ); 2288*cdf0e10cSrcweir else 2289*cdf0e10cSrcweir xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellRangeObj( pDocShell, aRange ) ) ); 2290*cdf0e10cSrcweir } 2291*cdf0e10cSrcweir else 2292*cdf0e10cSrcweir xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellRangesObj( pDocShell, aTabRanges ) ) ); 2293*cdf0e10cSrcweir 2294*cdf0e10cSrcweir uno::Sequence<uno::Any> aParams(1); 2295*cdf0e10cSrcweir aParams[0] <<= xTarget; 2296*cdf0e10cSrcweir 2297*cdf0e10cSrcweir uno::Any aRet; 2298*cdf0e10cSrcweir uno::Sequence<sal_Int16> aOutArgsIndex; 2299*cdf0e10cSrcweir uno::Sequence<uno::Any> aOutArgs; 2300*cdf0e10cSrcweir 2301*cdf0e10cSrcweir /*ErrCode eRet =*/ pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); 2302*cdf0e10cSrcweir } 2303*cdf0e10cSrcweir } 2304*cdf0e10cSrcweir } 2305*cdf0e10cSrcweir } 2306*cdf0e10cSrcweir } 2307*cdf0e10cSrcweir } 2308*cdf0e10cSrcweir 2309*cdf0e10cSrcweir void ScModelObj::HandleCalculateEvents() 2310*cdf0e10cSrcweir { 2311*cdf0e10cSrcweir if (pDocShell) 2312*cdf0e10cSrcweir { 2313*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2314*cdf0e10cSrcweir // don't call events before the document is visible 2315*cdf0e10cSrcweir // (might also set a flag on SFX_EVENT_LOADFINISHED and only disable while loading) 2316*cdf0e10cSrcweir if ( pDoc->IsDocVisible() ) 2317*cdf0e10cSrcweir { 2318*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 2319*cdf0e10cSrcweir for (SCTAB nTab = 0; nTab < nTabCount; nTab++) 2320*cdf0e10cSrcweir { 2321*cdf0e10cSrcweir if (pDoc->HasCalcNotification(nTab)) 2322*cdf0e10cSrcweir { 2323*cdf0e10cSrcweir if (const ScSheetEvents* pEvents = pDoc->GetSheetEvents( nTab )) 2324*cdf0e10cSrcweir { 2325*cdf0e10cSrcweir if (const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CALCULATE)) 2326*cdf0e10cSrcweir { 2327*cdf0e10cSrcweir uno::Any aRet; 2328*cdf0e10cSrcweir uno::Sequence<uno::Any> aParams; 2329*cdf0e10cSrcweir uno::Sequence<sal_Int16> aOutArgsIndex; 2330*cdf0e10cSrcweir uno::Sequence<uno::Any> aOutArgs; 2331*cdf0e10cSrcweir pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); 2332*cdf0e10cSrcweir } 2333*cdf0e10cSrcweir } 2334*cdf0e10cSrcweir 2335*cdf0e10cSrcweir try 2336*cdf0e10cSrcweir { 2337*cdf0e10cSrcweir uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); 2338*cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 1 ); 2339*cdf0e10cSrcweir aArgs[ 0 ] <<= nTab; 2340*cdf0e10cSrcweir xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_CALCULATE ), aArgs ); 2341*cdf0e10cSrcweir } 2342*cdf0e10cSrcweir catch( uno::Exception& ) 2343*cdf0e10cSrcweir { 2344*cdf0e10cSrcweir } 2345*cdf0e10cSrcweir } 2346*cdf0e10cSrcweir } 2347*cdf0e10cSrcweir } 2348*cdf0e10cSrcweir pDoc->ResetCalcNotifications(); 2349*cdf0e10cSrcweir } 2350*cdf0e10cSrcweir } 2351*cdf0e10cSrcweir 2352*cdf0e10cSrcweir //------------------------------------------------------------------------ 2353*cdf0e10cSrcweir 2354*cdf0e10cSrcweir ScDrawPagesObj::ScDrawPagesObj(ScDocShell* pDocSh) : 2355*cdf0e10cSrcweir pDocShell( pDocSh ) 2356*cdf0e10cSrcweir { 2357*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 2358*cdf0e10cSrcweir } 2359*cdf0e10cSrcweir 2360*cdf0e10cSrcweir ScDrawPagesObj::~ScDrawPagesObj() 2361*cdf0e10cSrcweir { 2362*cdf0e10cSrcweir if (pDocShell) 2363*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 2364*cdf0e10cSrcweir } 2365*cdf0e10cSrcweir 2366*cdf0e10cSrcweir void ScDrawPagesObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 2367*cdf0e10cSrcweir { 2368*cdf0e10cSrcweir // Referenz-Update interessiert hier nicht 2369*cdf0e10cSrcweir 2370*cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) && 2371*cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 2372*cdf0e10cSrcweir { 2373*cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 2374*cdf0e10cSrcweir } 2375*cdf0e10cSrcweir } 2376*cdf0e10cSrcweir 2377*cdf0e10cSrcweir uno::Reference<drawing::XDrawPage> ScDrawPagesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const 2378*cdf0e10cSrcweir { 2379*cdf0e10cSrcweir if (pDocShell) 2380*cdf0e10cSrcweir { 2381*cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDocShell->MakeDrawLayer(); 2382*cdf0e10cSrcweir DBG_ASSERT(pDrawLayer,"kann Draw-Layer nicht anlegen"); 2383*cdf0e10cSrcweir if ( pDrawLayer && nIndex >= 0 && nIndex < pDocShell->GetDocument()->GetTableCount() ) 2384*cdf0e10cSrcweir { 2385*cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage((sal_uInt16)nIndex); 2386*cdf0e10cSrcweir DBG_ASSERT(pPage,"Draw-Page nicht gefunden"); 2387*cdf0e10cSrcweir if (pPage) 2388*cdf0e10cSrcweir { 2389*cdf0e10cSrcweir return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY); 2390*cdf0e10cSrcweir } 2391*cdf0e10cSrcweir } 2392*cdf0e10cSrcweir } 2393*cdf0e10cSrcweir return NULL; 2394*cdf0e10cSrcweir } 2395*cdf0e10cSrcweir 2396*cdf0e10cSrcweir // XDrawPages 2397*cdf0e10cSrcweir 2398*cdf0e10cSrcweir uno::Reference<drawing::XDrawPage> SAL_CALL ScDrawPagesObj::insertNewByIndex( sal_Int32 nPos ) 2399*cdf0e10cSrcweir throw(uno::RuntimeException) 2400*cdf0e10cSrcweir { 2401*cdf0e10cSrcweir ScUnoGuard aGuard; 2402*cdf0e10cSrcweir uno::Reference<drawing::XDrawPage> xRet; 2403*cdf0e10cSrcweir if (pDocShell) 2404*cdf0e10cSrcweir { 2405*cdf0e10cSrcweir String aNewName; 2406*cdf0e10cSrcweir pDocShell->GetDocument()->CreateValidTabName(aNewName); 2407*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2408*cdf0e10cSrcweir if ( aFunc.InsertTable( (SCTAB)nPos, aNewName, sal_True, sal_True ) ) 2409*cdf0e10cSrcweir xRet.set(GetObjectByIndex_Impl( nPos )); 2410*cdf0e10cSrcweir } 2411*cdf0e10cSrcweir return xRet; 2412*cdf0e10cSrcweir } 2413*cdf0e10cSrcweir 2414*cdf0e10cSrcweir void SAL_CALL ScDrawPagesObj::remove( const uno::Reference<drawing::XDrawPage>& xPage ) 2415*cdf0e10cSrcweir throw(uno::RuntimeException) 2416*cdf0e10cSrcweir { 2417*cdf0e10cSrcweir ScUnoGuard aGuard; 2418*cdf0e10cSrcweir SvxDrawPage* pImp = SvxDrawPage::getImplementation( xPage ); 2419*cdf0e10cSrcweir if ( pDocShell && pImp ) 2420*cdf0e10cSrcweir { 2421*cdf0e10cSrcweir SdrPage* pPage = pImp->GetSdrPage(); 2422*cdf0e10cSrcweir if (pPage) 2423*cdf0e10cSrcweir { 2424*cdf0e10cSrcweir SCTAB nPageNum = static_cast<SCTAB>(pPage->GetPageNum()); 2425*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2426*cdf0e10cSrcweir aFunc.DeleteTable( nPageNum, sal_True, sal_True ); 2427*cdf0e10cSrcweir } 2428*cdf0e10cSrcweir } 2429*cdf0e10cSrcweir } 2430*cdf0e10cSrcweir 2431*cdf0e10cSrcweir // XIndexAccess 2432*cdf0e10cSrcweir 2433*cdf0e10cSrcweir sal_Int32 SAL_CALL ScDrawPagesObj::getCount() throw(uno::RuntimeException) 2434*cdf0e10cSrcweir { 2435*cdf0e10cSrcweir ScUnoGuard aGuard; 2436*cdf0e10cSrcweir if (pDocShell) 2437*cdf0e10cSrcweir return pDocShell->GetDocument()->GetTableCount(); 2438*cdf0e10cSrcweir return 0; 2439*cdf0e10cSrcweir } 2440*cdf0e10cSrcweir 2441*cdf0e10cSrcweir uno::Any SAL_CALL ScDrawPagesObj::getByIndex( sal_Int32 nIndex ) 2442*cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, 2443*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2444*cdf0e10cSrcweir { 2445*cdf0e10cSrcweir ScUnoGuard aGuard; 2446*cdf0e10cSrcweir uno::Reference<drawing::XDrawPage> xPage(GetObjectByIndex_Impl(nIndex)); 2447*cdf0e10cSrcweir if (xPage.is()) 2448*cdf0e10cSrcweir return uno::makeAny(xPage); 2449*cdf0e10cSrcweir else 2450*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 2451*cdf0e10cSrcweir // return uno::Any(); 2452*cdf0e10cSrcweir } 2453*cdf0e10cSrcweir 2454*cdf0e10cSrcweir uno::Type SAL_CALL ScDrawPagesObj::getElementType() throw(uno::RuntimeException) 2455*cdf0e10cSrcweir { 2456*cdf0e10cSrcweir ScUnoGuard aGuard; 2457*cdf0e10cSrcweir return getCppuType((uno::Reference<drawing::XDrawPage>*)0); 2458*cdf0e10cSrcweir } 2459*cdf0e10cSrcweir 2460*cdf0e10cSrcweir sal_Bool SAL_CALL ScDrawPagesObj::hasElements() throw(uno::RuntimeException) 2461*cdf0e10cSrcweir { 2462*cdf0e10cSrcweir ScUnoGuard aGuard; 2463*cdf0e10cSrcweir return ( getCount() != 0 ); 2464*cdf0e10cSrcweir } 2465*cdf0e10cSrcweir 2466*cdf0e10cSrcweir //------------------------------------------------------------------------ 2467*cdf0e10cSrcweir 2468*cdf0e10cSrcweir ScTableSheetsObj::ScTableSheetsObj(ScDocShell* pDocSh) : 2469*cdf0e10cSrcweir pDocShell( pDocSh ) 2470*cdf0e10cSrcweir { 2471*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 2472*cdf0e10cSrcweir } 2473*cdf0e10cSrcweir 2474*cdf0e10cSrcweir ScTableSheetsObj::~ScTableSheetsObj() 2475*cdf0e10cSrcweir { 2476*cdf0e10cSrcweir if (pDocShell) 2477*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 2478*cdf0e10cSrcweir } 2479*cdf0e10cSrcweir 2480*cdf0e10cSrcweir void ScTableSheetsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 2481*cdf0e10cSrcweir { 2482*cdf0e10cSrcweir // Referenz-Update interessiert hier nicht 2483*cdf0e10cSrcweir 2484*cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) && 2485*cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 2486*cdf0e10cSrcweir { 2487*cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 2488*cdf0e10cSrcweir } 2489*cdf0e10cSrcweir } 2490*cdf0e10cSrcweir 2491*cdf0e10cSrcweir // XSpreadsheets 2492*cdf0e10cSrcweir 2493*cdf0e10cSrcweir ScTableSheetObj* ScTableSheetsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const 2494*cdf0e10cSrcweir { 2495*cdf0e10cSrcweir if ( pDocShell && nIndex >= 0 && nIndex < pDocShell->GetDocument()->GetTableCount() ) 2496*cdf0e10cSrcweir return new ScTableSheetObj( pDocShell, static_cast<SCTAB>(nIndex) ); 2497*cdf0e10cSrcweir 2498*cdf0e10cSrcweir return NULL; 2499*cdf0e10cSrcweir } 2500*cdf0e10cSrcweir 2501*cdf0e10cSrcweir ScTableSheetObj* ScTableSheetsObj::GetObjectByName_Impl(const rtl::OUString& aName) const 2502*cdf0e10cSrcweir { 2503*cdf0e10cSrcweir if (pDocShell) 2504*cdf0e10cSrcweir { 2505*cdf0e10cSrcweir SCTAB nIndex; 2506*cdf0e10cSrcweir String aString(aName); 2507*cdf0e10cSrcweir if ( pDocShell->GetDocument()->GetTable( aString, nIndex ) ) 2508*cdf0e10cSrcweir return new ScTableSheetObj( pDocShell, nIndex ); 2509*cdf0e10cSrcweir } 2510*cdf0e10cSrcweir return NULL; 2511*cdf0e10cSrcweir } 2512*cdf0e10cSrcweir 2513*cdf0e10cSrcweir void SAL_CALL ScTableSheetsObj::insertNewByName( const rtl::OUString& aName, sal_Int16 nPosition ) 2514*cdf0e10cSrcweir throw(uno::RuntimeException) 2515*cdf0e10cSrcweir { 2516*cdf0e10cSrcweir ScUnoGuard aGuard; 2517*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2518*cdf0e10cSrcweir if (pDocShell) 2519*cdf0e10cSrcweir { 2520*cdf0e10cSrcweir String aNamStr(aName); 2521*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2522*cdf0e10cSrcweir bDone = aFunc.InsertTable( nPosition, aNamStr, sal_True, sal_True ); 2523*cdf0e10cSrcweir } 2524*cdf0e10cSrcweir if (!bDone) 2525*cdf0e10cSrcweir throw uno::RuntimeException(); // no other exceptions specified 2526*cdf0e10cSrcweir } 2527*cdf0e10cSrcweir 2528*cdf0e10cSrcweir void SAL_CALL ScTableSheetsObj::moveByName( const rtl::OUString& aName, sal_Int16 nDestination ) 2529*cdf0e10cSrcweir throw(uno::RuntimeException) 2530*cdf0e10cSrcweir { 2531*cdf0e10cSrcweir ScUnoGuard aGuard; 2532*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2533*cdf0e10cSrcweir if (pDocShell) 2534*cdf0e10cSrcweir { 2535*cdf0e10cSrcweir String aNamStr(aName); 2536*cdf0e10cSrcweir SCTAB nSource; 2537*cdf0e10cSrcweir if ( pDocShell->GetDocument()->GetTable( aNamStr, nSource ) ) 2538*cdf0e10cSrcweir bDone = pDocShell->MoveTable( nSource, nDestination, sal_False, sal_True ); 2539*cdf0e10cSrcweir } 2540*cdf0e10cSrcweir if (!bDone) 2541*cdf0e10cSrcweir throw uno::RuntimeException(); // no other exceptions specified 2542*cdf0e10cSrcweir } 2543*cdf0e10cSrcweir 2544*cdf0e10cSrcweir void SAL_CALL ScTableSheetsObj::copyByName( const rtl::OUString& aName, 2545*cdf0e10cSrcweir const rtl::OUString& aCopy, sal_Int16 nDestination ) 2546*cdf0e10cSrcweir throw(uno::RuntimeException) 2547*cdf0e10cSrcweir { 2548*cdf0e10cSrcweir ScUnoGuard aGuard; 2549*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2550*cdf0e10cSrcweir if (pDocShell) 2551*cdf0e10cSrcweir { 2552*cdf0e10cSrcweir String aNamStr(aName); 2553*cdf0e10cSrcweir String aNewStr(aCopy); 2554*cdf0e10cSrcweir SCTAB nSource; 2555*cdf0e10cSrcweir if ( pDocShell->GetDocument()->GetTable( aNamStr, nSource ) ) 2556*cdf0e10cSrcweir { 2557*cdf0e10cSrcweir bDone = pDocShell->MoveTable( nSource, nDestination, sal_True, sal_True ); 2558*cdf0e10cSrcweir if (bDone) 2559*cdf0e10cSrcweir { 2560*cdf0e10cSrcweir // #i92477# any index past the last sheet means "append" in MoveTable 2561*cdf0e10cSrcweir SCTAB nResultTab = static_cast<SCTAB>(nDestination); 2562*cdf0e10cSrcweir SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); // count after copying 2563*cdf0e10cSrcweir if (nResultTab >= nTabCount) 2564*cdf0e10cSrcweir nResultTab = nTabCount - 1; 2565*cdf0e10cSrcweir 2566*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2567*cdf0e10cSrcweir bDone = aFunc.RenameTable( nResultTab, aNewStr, sal_True, sal_True ); 2568*cdf0e10cSrcweir } 2569*cdf0e10cSrcweir } 2570*cdf0e10cSrcweir } 2571*cdf0e10cSrcweir if (!bDone) 2572*cdf0e10cSrcweir throw uno::RuntimeException(); // no other exceptions specified 2573*cdf0e10cSrcweir } 2574*cdf0e10cSrcweir 2575*cdf0e10cSrcweir void SAL_CALL ScTableSheetsObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement ) 2576*cdf0e10cSrcweir throw(lang::IllegalArgumentException, container::ElementExistException, 2577*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2578*cdf0e10cSrcweir { 2579*cdf0e10cSrcweir ScUnoGuard aGuard; 2580*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2581*cdf0e10cSrcweir sal_Bool bIllArg = sal_False; 2582*cdf0e10cSrcweir 2583*cdf0e10cSrcweir //! Type of aElement can be some specific interface instead of XInterface 2584*cdf0e10cSrcweir 2585*cdf0e10cSrcweir if ( pDocShell ) 2586*cdf0e10cSrcweir { 2587*cdf0e10cSrcweir uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY); 2588*cdf0e10cSrcweir if ( xInterface.is() ) 2589*cdf0e10cSrcweir { 2590*cdf0e10cSrcweir ScTableSheetObj* pSheetObj = ScTableSheetObj::getImplementation( xInterface ); 2591*cdf0e10cSrcweir if ( pSheetObj && !pSheetObj->GetDocShell() ) // noch nicht eingefuegt? 2592*cdf0e10cSrcweir { 2593*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2594*cdf0e10cSrcweir String aNamStr(aName); 2595*cdf0e10cSrcweir SCTAB nDummy; 2596*cdf0e10cSrcweir if ( pDoc->GetTable( aNamStr, nDummy ) ) 2597*cdf0e10cSrcweir { 2598*cdf0e10cSrcweir // name already exists 2599*cdf0e10cSrcweir throw container::ElementExistException(); 2600*cdf0e10cSrcweir } 2601*cdf0e10cSrcweir else 2602*cdf0e10cSrcweir { 2603*cdf0e10cSrcweir SCTAB nPosition = pDoc->GetTableCount(); 2604*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2605*cdf0e10cSrcweir bDone = aFunc.InsertTable( nPosition, aNamStr, sal_True, sal_True ); 2606*cdf0e10cSrcweir if (bDone) 2607*cdf0e10cSrcweir pSheetObj->InitInsertSheet( pDocShell, nPosition ); 2608*cdf0e10cSrcweir // Dokument und neuen Range am Objekt setzen 2609*cdf0e10cSrcweir } 2610*cdf0e10cSrcweir } 2611*cdf0e10cSrcweir else 2612*cdf0e10cSrcweir bIllArg = sal_True; 2613*cdf0e10cSrcweir } 2614*cdf0e10cSrcweir else 2615*cdf0e10cSrcweir bIllArg = sal_True; 2616*cdf0e10cSrcweir } 2617*cdf0e10cSrcweir 2618*cdf0e10cSrcweir if (!bDone) 2619*cdf0e10cSrcweir { 2620*cdf0e10cSrcweir if (bIllArg) 2621*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2622*cdf0e10cSrcweir else 2623*cdf0e10cSrcweir throw uno::RuntimeException(); // ElementExistException is handled above 2624*cdf0e10cSrcweir } 2625*cdf0e10cSrcweir } 2626*cdf0e10cSrcweir 2627*cdf0e10cSrcweir void SAL_CALL ScTableSheetsObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement ) 2628*cdf0e10cSrcweir throw(lang::IllegalArgumentException, container::NoSuchElementException, 2629*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2630*cdf0e10cSrcweir { 2631*cdf0e10cSrcweir ScUnoGuard aGuard; 2632*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2633*cdf0e10cSrcweir sal_Bool bIllArg = sal_False; 2634*cdf0e10cSrcweir 2635*cdf0e10cSrcweir //! Type of aElement can be some specific interface instead of XInterface 2636*cdf0e10cSrcweir 2637*cdf0e10cSrcweir if ( pDocShell ) 2638*cdf0e10cSrcweir { 2639*cdf0e10cSrcweir uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY); 2640*cdf0e10cSrcweir if ( xInterface.is() ) 2641*cdf0e10cSrcweir { 2642*cdf0e10cSrcweir ScTableSheetObj* pSheetObj = ScTableSheetObj::getImplementation( xInterface ); 2643*cdf0e10cSrcweir if ( pSheetObj && !pSheetObj->GetDocShell() ) // noch nicht eingefuegt? 2644*cdf0e10cSrcweir { 2645*cdf0e10cSrcweir String aNamStr(aName); 2646*cdf0e10cSrcweir SCTAB nPosition; 2647*cdf0e10cSrcweir if ( pDocShell->GetDocument()->GetTable( aNamStr, nPosition ) ) 2648*cdf0e10cSrcweir { 2649*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2650*cdf0e10cSrcweir if ( aFunc.DeleteTable( nPosition, sal_True, sal_True ) ) 2651*cdf0e10cSrcweir { 2652*cdf0e10cSrcweir // InsertTable kann jetzt eigentlich nicht schiefgehen... 2653*cdf0e10cSrcweir bDone = aFunc.InsertTable( nPosition, aNamStr, sal_True, sal_True ); 2654*cdf0e10cSrcweir if (bDone) 2655*cdf0e10cSrcweir pSheetObj->InitInsertSheet( pDocShell, nPosition ); 2656*cdf0e10cSrcweir } 2657*cdf0e10cSrcweir } 2658*cdf0e10cSrcweir else 2659*cdf0e10cSrcweir { 2660*cdf0e10cSrcweir // not found 2661*cdf0e10cSrcweir throw container::NoSuchElementException(); 2662*cdf0e10cSrcweir } 2663*cdf0e10cSrcweir } 2664*cdf0e10cSrcweir else 2665*cdf0e10cSrcweir bIllArg = sal_True; 2666*cdf0e10cSrcweir } 2667*cdf0e10cSrcweir else 2668*cdf0e10cSrcweir bIllArg = sal_True; 2669*cdf0e10cSrcweir } 2670*cdf0e10cSrcweir 2671*cdf0e10cSrcweir if (!bDone) 2672*cdf0e10cSrcweir { 2673*cdf0e10cSrcweir if (bIllArg) 2674*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2675*cdf0e10cSrcweir else 2676*cdf0e10cSrcweir throw uno::RuntimeException(); // NoSuchElementException is handled above 2677*cdf0e10cSrcweir } 2678*cdf0e10cSrcweir } 2679*cdf0e10cSrcweir 2680*cdf0e10cSrcweir void SAL_CALL ScTableSheetsObj::removeByName( const rtl::OUString& aName ) 2681*cdf0e10cSrcweir throw(container::NoSuchElementException, 2682*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2683*cdf0e10cSrcweir { 2684*cdf0e10cSrcweir ScUnoGuard aGuard; 2685*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2686*cdf0e10cSrcweir if (pDocShell) 2687*cdf0e10cSrcweir { 2688*cdf0e10cSrcweir SCTAB nIndex; 2689*cdf0e10cSrcweir String aString(aName); 2690*cdf0e10cSrcweir if ( pDocShell->GetDocument()->GetTable( aString, nIndex ) ) 2691*cdf0e10cSrcweir { 2692*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2693*cdf0e10cSrcweir bDone = aFunc.DeleteTable( nIndex, sal_True, sal_True ); 2694*cdf0e10cSrcweir } 2695*cdf0e10cSrcweir else 2696*cdf0e10cSrcweir { 2697*cdf0e10cSrcweir // not found 2698*cdf0e10cSrcweir throw container::NoSuchElementException(); 2699*cdf0e10cSrcweir } 2700*cdf0e10cSrcweir } 2701*cdf0e10cSrcweir 2702*cdf0e10cSrcweir if (!bDone) 2703*cdf0e10cSrcweir throw uno::RuntimeException(); // NoSuchElementException is handled above 2704*cdf0e10cSrcweir } 2705*cdf0e10cSrcweir 2706*cdf0e10cSrcweir // XCellRangesAccess 2707*cdf0e10cSrcweir 2708*cdf0e10cSrcweir uno::Reference< table::XCell > SAL_CALL ScTableSheetsObj::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow, sal_Int32 nSheet ) 2709*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2710*cdf0e10cSrcweir { 2711*cdf0e10cSrcweir ScUnoGuard aGuard; 2712*cdf0e10cSrcweir uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((sal_uInt16)nSheet))); 2713*cdf0e10cSrcweir if (! xSheet.is()) 2714*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 2715*cdf0e10cSrcweir 2716*cdf0e10cSrcweir return xSheet->getCellByPosition(nColumn, nRow); 2717*cdf0e10cSrcweir } 2718*cdf0e10cSrcweir 2719*cdf0e10cSrcweir uno::Reference< table::XCellRange > SAL_CALL ScTableSheetsObj::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom, sal_Int32 nSheet ) 2720*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2721*cdf0e10cSrcweir { 2722*cdf0e10cSrcweir ScUnoGuard aGuard; 2723*cdf0e10cSrcweir uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((sal_uInt16)nSheet))); 2724*cdf0e10cSrcweir if (! xSheet.is()) 2725*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 2726*cdf0e10cSrcweir 2727*cdf0e10cSrcweir return xSheet->getCellRangeByPosition(nLeft, nTop, nRight, nBottom); 2728*cdf0e10cSrcweir } 2729*cdf0e10cSrcweir 2730*cdf0e10cSrcweir uno::Sequence < uno::Reference< table::XCellRange > > SAL_CALL ScTableSheetsObj::getCellRangesByName( const rtl::OUString& aRange ) 2731*cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException) 2732*cdf0e10cSrcweir { 2733*cdf0e10cSrcweir ScUnoGuard aGuard; 2734*cdf0e10cSrcweir uno::Sequence < uno::Reference < table::XCellRange > > xRet; 2735*cdf0e10cSrcweir 2736*cdf0e10cSrcweir ScRangeList aRangeList; 2737*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2738*cdf0e10cSrcweir if (ScRangeStringConverter::GetRangeListFromString( aRangeList, aRange, pDoc, ::formula::FormulaGrammar::CONV_OOO, ';' )) 2739*cdf0e10cSrcweir { 2740*cdf0e10cSrcweir sal_Int32 nCount = aRangeList.Count(); 2741*cdf0e10cSrcweir if (nCount) 2742*cdf0e10cSrcweir { 2743*cdf0e10cSrcweir xRet.realloc(nCount); 2744*cdf0e10cSrcweir for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) 2745*cdf0e10cSrcweir { 2746*cdf0e10cSrcweir const ScRange* pRange = aRangeList.GetObject( nIndex ); 2747*cdf0e10cSrcweir if( pRange ) 2748*cdf0e10cSrcweir xRet[nIndex] = new ScCellRangeObj(pDocShell, *pRange); 2749*cdf0e10cSrcweir } 2750*cdf0e10cSrcweir } 2751*cdf0e10cSrcweir else 2752*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2753*cdf0e10cSrcweir } 2754*cdf0e10cSrcweir else 2755*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2756*cdf0e10cSrcweir return xRet; 2757*cdf0e10cSrcweir } 2758*cdf0e10cSrcweir 2759*cdf0e10cSrcweir // XEnumerationAccess 2760*cdf0e10cSrcweir 2761*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScTableSheetsObj::createEnumeration() 2762*cdf0e10cSrcweir throw(uno::RuntimeException) 2763*cdf0e10cSrcweir { 2764*cdf0e10cSrcweir ScUnoGuard aGuard; 2765*cdf0e10cSrcweir return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetsEnumeration"))); 2766*cdf0e10cSrcweir } 2767*cdf0e10cSrcweir 2768*cdf0e10cSrcweir // XIndexAccess 2769*cdf0e10cSrcweir 2770*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTableSheetsObj::getCount() throw(uno::RuntimeException) 2771*cdf0e10cSrcweir { 2772*cdf0e10cSrcweir ScUnoGuard aGuard; 2773*cdf0e10cSrcweir if (pDocShell) 2774*cdf0e10cSrcweir return pDocShell->GetDocument()->GetTableCount(); 2775*cdf0e10cSrcweir return 0; 2776*cdf0e10cSrcweir } 2777*cdf0e10cSrcweir 2778*cdf0e10cSrcweir uno::Any SAL_CALL ScTableSheetsObj::getByIndex( sal_Int32 nIndex ) 2779*cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, 2780*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2781*cdf0e10cSrcweir { 2782*cdf0e10cSrcweir ScUnoGuard aGuard; 2783*cdf0e10cSrcweir uno::Reference<sheet::XSpreadsheet> xSheet(GetObjectByIndex_Impl(nIndex)); 2784*cdf0e10cSrcweir if (xSheet.is()) 2785*cdf0e10cSrcweir return uno::makeAny(xSheet); 2786*cdf0e10cSrcweir else 2787*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 2788*cdf0e10cSrcweir // return uno::Any(); 2789*cdf0e10cSrcweir } 2790*cdf0e10cSrcweir 2791*cdf0e10cSrcweir uno::Type SAL_CALL ScTableSheetsObj::getElementType() throw(uno::RuntimeException) 2792*cdf0e10cSrcweir { 2793*cdf0e10cSrcweir ScUnoGuard aGuard; 2794*cdf0e10cSrcweir return getCppuType((uno::Reference<sheet::XSpreadsheet>*)0); 2795*cdf0e10cSrcweir } 2796*cdf0e10cSrcweir 2797*cdf0e10cSrcweir sal_Bool SAL_CALL ScTableSheetsObj::hasElements() throw(uno::RuntimeException) 2798*cdf0e10cSrcweir { 2799*cdf0e10cSrcweir ScUnoGuard aGuard; 2800*cdf0e10cSrcweir return ( getCount() != 0 ); 2801*cdf0e10cSrcweir } 2802*cdf0e10cSrcweir 2803*cdf0e10cSrcweir // XNameAccess 2804*cdf0e10cSrcweir 2805*cdf0e10cSrcweir uno::Any SAL_CALL ScTableSheetsObj::getByName( const rtl::OUString& aName ) 2806*cdf0e10cSrcweir throw(container::NoSuchElementException, 2807*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2808*cdf0e10cSrcweir { 2809*cdf0e10cSrcweir ScUnoGuard aGuard; 2810*cdf0e10cSrcweir uno::Reference<sheet::XSpreadsheet> xSheet(GetObjectByName_Impl(aName)); 2811*cdf0e10cSrcweir if (xSheet.is()) 2812*cdf0e10cSrcweir return uno::makeAny(xSheet); 2813*cdf0e10cSrcweir else 2814*cdf0e10cSrcweir throw container::NoSuchElementException(); 2815*cdf0e10cSrcweir // return uno::Any(); 2816*cdf0e10cSrcweir } 2817*cdf0e10cSrcweir 2818*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScTableSheetsObj::getElementNames() 2819*cdf0e10cSrcweir throw(uno::RuntimeException) 2820*cdf0e10cSrcweir { 2821*cdf0e10cSrcweir ScUnoGuard aGuard; 2822*cdf0e10cSrcweir if (pDocShell) 2823*cdf0e10cSrcweir { 2824*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2825*cdf0e10cSrcweir SCTAB nCount = pDoc->GetTableCount(); 2826*cdf0e10cSrcweir String aName; 2827*cdf0e10cSrcweir uno::Sequence<rtl::OUString> aSeq(nCount); 2828*cdf0e10cSrcweir rtl::OUString* pAry = aSeq.getArray(); 2829*cdf0e10cSrcweir for (SCTAB i=0; i<nCount; i++) 2830*cdf0e10cSrcweir { 2831*cdf0e10cSrcweir pDoc->GetName( i, aName ); 2832*cdf0e10cSrcweir pAry[i] = aName; 2833*cdf0e10cSrcweir } 2834*cdf0e10cSrcweir return aSeq; 2835*cdf0e10cSrcweir } 2836*cdf0e10cSrcweir return uno::Sequence<rtl::OUString>(); 2837*cdf0e10cSrcweir } 2838*cdf0e10cSrcweir 2839*cdf0e10cSrcweir sal_Bool SAL_CALL ScTableSheetsObj::hasByName( const rtl::OUString& aName ) 2840*cdf0e10cSrcweir throw(uno::RuntimeException) 2841*cdf0e10cSrcweir { 2842*cdf0e10cSrcweir ScUnoGuard aGuard; 2843*cdf0e10cSrcweir if (pDocShell) 2844*cdf0e10cSrcweir { 2845*cdf0e10cSrcweir SCTAB nIndex; 2846*cdf0e10cSrcweir if ( pDocShell->GetDocument()->GetTable( String(aName), nIndex ) ) 2847*cdf0e10cSrcweir return sal_True; 2848*cdf0e10cSrcweir } 2849*cdf0e10cSrcweir return sal_False; 2850*cdf0e10cSrcweir } 2851*cdf0e10cSrcweir 2852*cdf0e10cSrcweir //------------------------------------------------------------------------ 2853*cdf0e10cSrcweir 2854*cdf0e10cSrcweir ScTableColumnsObj::ScTableColumnsObj(ScDocShell* pDocSh, SCTAB nT, SCCOL nSC, SCCOL nEC) : 2855*cdf0e10cSrcweir pDocShell( pDocSh ), 2856*cdf0e10cSrcweir nTab ( nT ), 2857*cdf0e10cSrcweir nStartCol( nSC ), 2858*cdf0e10cSrcweir nEndCol ( nEC ) 2859*cdf0e10cSrcweir { 2860*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 2861*cdf0e10cSrcweir } 2862*cdf0e10cSrcweir 2863*cdf0e10cSrcweir ScTableColumnsObj::~ScTableColumnsObj() 2864*cdf0e10cSrcweir { 2865*cdf0e10cSrcweir if (pDocShell) 2866*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 2867*cdf0e10cSrcweir } 2868*cdf0e10cSrcweir 2869*cdf0e10cSrcweir void ScTableColumnsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 2870*cdf0e10cSrcweir { 2871*cdf0e10cSrcweir if ( rHint.ISA( ScUpdateRefHint ) ) 2872*cdf0e10cSrcweir { 2873*cdf0e10cSrcweir // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint; 2874*cdf0e10cSrcweir 2875*cdf0e10cSrcweir //! Referenz-Update fuer Tab und Start/Ende 2876*cdf0e10cSrcweir } 2877*cdf0e10cSrcweir else if ( rHint.ISA( SfxSimpleHint ) && 2878*cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 2879*cdf0e10cSrcweir { 2880*cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 2881*cdf0e10cSrcweir } 2882*cdf0e10cSrcweir } 2883*cdf0e10cSrcweir 2884*cdf0e10cSrcweir // XTableColumns 2885*cdf0e10cSrcweir 2886*cdf0e10cSrcweir ScTableColumnObj* ScTableColumnsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const 2887*cdf0e10cSrcweir { 2888*cdf0e10cSrcweir SCCOL nCol = static_cast<SCCOL>(nIndex) + nStartCol; 2889*cdf0e10cSrcweir if ( pDocShell && nCol <= nEndCol ) 2890*cdf0e10cSrcweir return new ScTableColumnObj( pDocShell, nCol, nTab ); 2891*cdf0e10cSrcweir 2892*cdf0e10cSrcweir return NULL; // falscher Index 2893*cdf0e10cSrcweir } 2894*cdf0e10cSrcweir 2895*cdf0e10cSrcweir ScTableColumnObj* ScTableColumnsObj::GetObjectByName_Impl(const rtl::OUString& aName) const 2896*cdf0e10cSrcweir { 2897*cdf0e10cSrcweir SCCOL nCol = 0; 2898*cdf0e10cSrcweir String aString(aName); 2899*cdf0e10cSrcweir if ( ::AlphaToCol( nCol, aString) ) 2900*cdf0e10cSrcweir if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol ) 2901*cdf0e10cSrcweir return new ScTableColumnObj( pDocShell, nCol, nTab ); 2902*cdf0e10cSrcweir 2903*cdf0e10cSrcweir return NULL; 2904*cdf0e10cSrcweir } 2905*cdf0e10cSrcweir 2906*cdf0e10cSrcweir void SAL_CALL ScTableColumnsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 nCount ) 2907*cdf0e10cSrcweir throw(uno::RuntimeException) 2908*cdf0e10cSrcweir { 2909*cdf0e10cSrcweir ScUnoGuard aGuard; 2910*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2911*cdf0e10cSrcweir if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartCol+nPosition <= nEndCol && 2912*cdf0e10cSrcweir nStartCol+nPosition+nCount-1 <= MAXCOL ) 2913*cdf0e10cSrcweir { 2914*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2915*cdf0e10cSrcweir ScRange aRange( (SCCOL)(nStartCol+nPosition), 0, nTab, 2916*cdf0e10cSrcweir (SCCOL)(nStartCol+nPosition+nCount-1), MAXROW, nTab ); 2917*cdf0e10cSrcweir bDone = aFunc.InsertCells( aRange, NULL, INS_INSCOLS, sal_True, sal_True ); 2918*cdf0e10cSrcweir } 2919*cdf0e10cSrcweir if (!bDone) 2920*cdf0e10cSrcweir throw uno::RuntimeException(); // no other exceptions specified 2921*cdf0e10cSrcweir } 2922*cdf0e10cSrcweir 2923*cdf0e10cSrcweir void SAL_CALL ScTableColumnsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) 2924*cdf0e10cSrcweir throw(uno::RuntimeException) 2925*cdf0e10cSrcweir { 2926*cdf0e10cSrcweir ScUnoGuard aGuard; 2927*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2928*cdf0e10cSrcweir // Der zu loeschende Bereich muss innerhalb des Objekts liegen 2929*cdf0e10cSrcweir if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartCol+nIndex+nCount-1 <= nEndCol ) 2930*cdf0e10cSrcweir { 2931*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 2932*cdf0e10cSrcweir ScRange aRange( (SCCOL)(nStartCol+nIndex), 0, nTab, 2933*cdf0e10cSrcweir (SCCOL)(nStartCol+nIndex+nCount-1), MAXROW, nTab ); 2934*cdf0e10cSrcweir bDone = aFunc.DeleteCells( aRange, NULL, DEL_DELCOLS, sal_True, sal_True ); 2935*cdf0e10cSrcweir } 2936*cdf0e10cSrcweir if (!bDone) 2937*cdf0e10cSrcweir throw uno::RuntimeException(); // no other exceptions specified 2938*cdf0e10cSrcweir } 2939*cdf0e10cSrcweir 2940*cdf0e10cSrcweir // XEnumerationAccess 2941*cdf0e10cSrcweir 2942*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScTableColumnsObj::createEnumeration() 2943*cdf0e10cSrcweir throw(uno::RuntimeException) 2944*cdf0e10cSrcweir { 2945*cdf0e10cSrcweir ScUnoGuard aGuard; 2946*cdf0e10cSrcweir return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableColumnsEnumeration"))); 2947*cdf0e10cSrcweir } 2948*cdf0e10cSrcweir 2949*cdf0e10cSrcweir // XIndexAccess 2950*cdf0e10cSrcweir 2951*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTableColumnsObj::getCount() throw(uno::RuntimeException) 2952*cdf0e10cSrcweir { 2953*cdf0e10cSrcweir ScUnoGuard aGuard; 2954*cdf0e10cSrcweir return nEndCol - nStartCol + 1; 2955*cdf0e10cSrcweir } 2956*cdf0e10cSrcweir 2957*cdf0e10cSrcweir uno::Any SAL_CALL ScTableColumnsObj::getByIndex( sal_Int32 nIndex ) 2958*cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, 2959*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2960*cdf0e10cSrcweir { 2961*cdf0e10cSrcweir ScUnoGuard aGuard; 2962*cdf0e10cSrcweir uno::Reference<table::XCellRange> xColumn(GetObjectByIndex_Impl(nIndex)); 2963*cdf0e10cSrcweir if (xColumn.is()) 2964*cdf0e10cSrcweir return uno::makeAny(xColumn); 2965*cdf0e10cSrcweir else 2966*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 2967*cdf0e10cSrcweir // return uno::Any(); 2968*cdf0e10cSrcweir } 2969*cdf0e10cSrcweir 2970*cdf0e10cSrcweir uno::Type SAL_CALL ScTableColumnsObj::getElementType() throw(uno::RuntimeException) 2971*cdf0e10cSrcweir { 2972*cdf0e10cSrcweir ScUnoGuard aGuard; 2973*cdf0e10cSrcweir return getCppuType((uno::Reference<table::XCellRange>*)0); 2974*cdf0e10cSrcweir } 2975*cdf0e10cSrcweir 2976*cdf0e10cSrcweir sal_Bool SAL_CALL ScTableColumnsObj::hasElements() throw(uno::RuntimeException) 2977*cdf0e10cSrcweir { 2978*cdf0e10cSrcweir ScUnoGuard aGuard; 2979*cdf0e10cSrcweir return ( getCount() != 0 ); 2980*cdf0e10cSrcweir } 2981*cdf0e10cSrcweir 2982*cdf0e10cSrcweir uno::Any SAL_CALL ScTableColumnsObj::getByName( const rtl::OUString& aName ) 2983*cdf0e10cSrcweir throw(container::NoSuchElementException, 2984*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 2985*cdf0e10cSrcweir { 2986*cdf0e10cSrcweir ScUnoGuard aGuard; 2987*cdf0e10cSrcweir uno::Reference<table::XCellRange> xColumn(GetObjectByName_Impl(aName)); 2988*cdf0e10cSrcweir if (xColumn.is()) 2989*cdf0e10cSrcweir return uno::makeAny(xColumn); 2990*cdf0e10cSrcweir else 2991*cdf0e10cSrcweir throw container::NoSuchElementException(); 2992*cdf0e10cSrcweir // return uno::Any(); 2993*cdf0e10cSrcweir } 2994*cdf0e10cSrcweir 2995*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScTableColumnsObj::getElementNames() 2996*cdf0e10cSrcweir throw(uno::RuntimeException) 2997*cdf0e10cSrcweir { 2998*cdf0e10cSrcweir ScUnoGuard aGuard; 2999*cdf0e10cSrcweir SCCOL nCount = nEndCol - nStartCol + 1; 3000*cdf0e10cSrcweir uno::Sequence<rtl::OUString> aSeq(nCount); 3001*cdf0e10cSrcweir rtl::OUString* pAry = aSeq.getArray(); 3002*cdf0e10cSrcweir for (SCCOL i=0; i<nCount; i++) 3003*cdf0e10cSrcweir pAry[i] = ::ScColToAlpha( nStartCol + i ); 3004*cdf0e10cSrcweir 3005*cdf0e10cSrcweir return aSeq; 3006*cdf0e10cSrcweir } 3007*cdf0e10cSrcweir 3008*cdf0e10cSrcweir sal_Bool SAL_CALL ScTableColumnsObj::hasByName( const rtl::OUString& aName ) 3009*cdf0e10cSrcweir throw(uno::RuntimeException) 3010*cdf0e10cSrcweir { 3011*cdf0e10cSrcweir ScUnoGuard aGuard; 3012*cdf0e10cSrcweir SCCOL nCol = 0; 3013*cdf0e10cSrcweir String aString(aName); 3014*cdf0e10cSrcweir if ( ::AlphaToCol( nCol, aString) ) 3015*cdf0e10cSrcweir if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol ) 3016*cdf0e10cSrcweir return sal_True; 3017*cdf0e10cSrcweir 3018*cdf0e10cSrcweir return sal_False; // nicht gefunden 3019*cdf0e10cSrcweir } 3020*cdf0e10cSrcweir 3021*cdf0e10cSrcweir // XPropertySet 3022*cdf0e10cSrcweir 3023*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnsObj::getPropertySetInfo() 3024*cdf0e10cSrcweir throw(uno::RuntimeException) 3025*cdf0e10cSrcweir { 3026*cdf0e10cSrcweir ScUnoGuard aGuard; 3027*cdf0e10cSrcweir static uno::Reference<beans::XPropertySetInfo> aRef( 3028*cdf0e10cSrcweir new SfxItemPropertySetInfo( lcl_GetColumnsPropertyMap() )); 3029*cdf0e10cSrcweir return aRef; 3030*cdf0e10cSrcweir } 3031*cdf0e10cSrcweir 3032*cdf0e10cSrcweir void SAL_CALL ScTableColumnsObj::setPropertyValue( 3033*cdf0e10cSrcweir const rtl::OUString& aPropertyName, const uno::Any& aValue ) 3034*cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, 3035*cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException, 3036*cdf0e10cSrcweir uno::RuntimeException) 3037*cdf0e10cSrcweir { 3038*cdf0e10cSrcweir ScUnoGuard aGuard; 3039*cdf0e10cSrcweir if (!pDocShell) 3040*cdf0e10cSrcweir throw uno::RuntimeException(); 3041*cdf0e10cSrcweir 3042*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 3043*cdf0e10cSrcweir SCCOLROW nColArr[2]; 3044*cdf0e10cSrcweir nColArr[0] = nStartCol; 3045*cdf0e10cSrcweir nColArr[1] = nEndCol; 3046*cdf0e10cSrcweir String aNameString(aPropertyName); 3047*cdf0e10cSrcweir 3048*cdf0e10cSrcweir if ( aNameString.EqualsAscii( SC_UNONAME_CELLWID ) ) 3049*cdf0e10cSrcweir { 3050*cdf0e10cSrcweir sal_Int32 nNewWidth = 0; 3051*cdf0e10cSrcweir if ( aValue >>= nNewWidth ) 3052*cdf0e10cSrcweir aFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab, SC_SIZE_ORIGINAL, 3053*cdf0e10cSrcweir (sal_uInt16)HMMToTwips(nNewWidth), sal_True, sal_True ); 3054*cdf0e10cSrcweir } 3055*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) ) 3056*cdf0e10cSrcweir { 3057*cdf0e10cSrcweir sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 3058*cdf0e10cSrcweir ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT; 3059*cdf0e10cSrcweir aFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab, eMode, 0, sal_True, sal_True ); 3060*cdf0e10cSrcweir // SC_SIZE_DIRECT with size 0: hide 3061*cdf0e10cSrcweir } 3062*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) ) 3063*cdf0e10cSrcweir { 3064*cdf0e10cSrcweir sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 3065*cdf0e10cSrcweir if (bOpt) 3066*cdf0e10cSrcweir aFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab, 3067*cdf0e10cSrcweir SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, sal_True, sal_True ); 3068*cdf0e10cSrcweir // sal_False for columns currently has no effect 3069*cdf0e10cSrcweir } 3070*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) ) 3071*cdf0e10cSrcweir { 3072*cdf0e10cSrcweir //! single function to set/remove all breaks? 3073*cdf0e10cSrcweir sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 3074*cdf0e10cSrcweir for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++) 3075*cdf0e10cSrcweir if (bSet) 3076*cdf0e10cSrcweir aFunc.InsertPageBreak( sal_True, ScAddress(nCol,0,nTab), sal_True, sal_True, sal_True ); 3077*cdf0e10cSrcweir else 3078*cdf0e10cSrcweir aFunc.RemovePageBreak( sal_True, ScAddress(nCol,0,nTab), sal_True, sal_True, sal_True ); 3079*cdf0e10cSrcweir } 3080*cdf0e10cSrcweir } 3081*cdf0e10cSrcweir 3082*cdf0e10cSrcweir uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const rtl::OUString& aPropertyName ) 3083*cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, 3084*cdf0e10cSrcweir uno::RuntimeException) 3085*cdf0e10cSrcweir { 3086*cdf0e10cSrcweir ScUnoGuard aGuard; 3087*cdf0e10cSrcweir if (!pDocShell) 3088*cdf0e10cSrcweir throw uno::RuntimeException(); 3089*cdf0e10cSrcweir 3090*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 3091*cdf0e10cSrcweir String aNameString(aPropertyName); 3092*cdf0e10cSrcweir uno::Any aAny; 3093*cdf0e10cSrcweir 3094*cdf0e10cSrcweir //! loop over all columns for current state? 3095*cdf0e10cSrcweir 3096*cdf0e10cSrcweir if ( aNameString.EqualsAscii( SC_UNONAME_CELLWID ) ) 3097*cdf0e10cSrcweir { 3098*cdf0e10cSrcweir // for hidden column, return original height 3099*cdf0e10cSrcweir sal_uInt16 nWidth = pDoc->GetOriginalWidth( nStartCol, nTab ); 3100*cdf0e10cSrcweir aAny <<= (sal_Int32)TwipsToHMM(nWidth); 3101*cdf0e10cSrcweir } 3102*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) ) 3103*cdf0e10cSrcweir { 3104*cdf0e10cSrcweir SCCOL nLastCol; 3105*cdf0e10cSrcweir bool bVis = !pDoc->ColHidden(nStartCol, nTab, nLastCol); 3106*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, bVis ); 3107*cdf0e10cSrcweir } 3108*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) ) 3109*cdf0e10cSrcweir { 3110*cdf0e10cSrcweir sal_Bool bOpt = !(pDoc->GetColFlags( nStartCol, nTab ) & CR_MANUALSIZE); 3111*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, bOpt ); 3112*cdf0e10cSrcweir } 3113*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) ) 3114*cdf0e10cSrcweir { 3115*cdf0e10cSrcweir ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab); 3116*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak ); 3117*cdf0e10cSrcweir } 3118*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) ) 3119*cdf0e10cSrcweir { 3120*cdf0e10cSrcweir ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab); 3121*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) ); 3122*cdf0e10cSrcweir } 3123*cdf0e10cSrcweir 3124*cdf0e10cSrcweir return aAny; 3125*cdf0e10cSrcweir } 3126*cdf0e10cSrcweir 3127*cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableColumnsObj ) 3128*cdf0e10cSrcweir 3129*cdf0e10cSrcweir //------------------------------------------------------------------------ 3130*cdf0e10cSrcweir 3131*cdf0e10cSrcweir ScTableRowsObj::ScTableRowsObj(ScDocShell* pDocSh, SCTAB nT, SCROW nSR, SCROW nER) : 3132*cdf0e10cSrcweir pDocShell( pDocSh ), 3133*cdf0e10cSrcweir nTab ( nT ), 3134*cdf0e10cSrcweir nStartRow( nSR ), 3135*cdf0e10cSrcweir nEndRow ( nER ) 3136*cdf0e10cSrcweir { 3137*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 3138*cdf0e10cSrcweir } 3139*cdf0e10cSrcweir 3140*cdf0e10cSrcweir ScTableRowsObj::~ScTableRowsObj() 3141*cdf0e10cSrcweir { 3142*cdf0e10cSrcweir if (pDocShell) 3143*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 3144*cdf0e10cSrcweir } 3145*cdf0e10cSrcweir 3146*cdf0e10cSrcweir void ScTableRowsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 3147*cdf0e10cSrcweir { 3148*cdf0e10cSrcweir if ( rHint.ISA( ScUpdateRefHint ) ) 3149*cdf0e10cSrcweir { 3150*cdf0e10cSrcweir // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint; 3151*cdf0e10cSrcweir 3152*cdf0e10cSrcweir //! Referenz-Update fuer Tab und Start/Ende 3153*cdf0e10cSrcweir } 3154*cdf0e10cSrcweir else if ( rHint.ISA( SfxSimpleHint ) && 3155*cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 3156*cdf0e10cSrcweir { 3157*cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 3158*cdf0e10cSrcweir } 3159*cdf0e10cSrcweir } 3160*cdf0e10cSrcweir 3161*cdf0e10cSrcweir // XTableRows 3162*cdf0e10cSrcweir 3163*cdf0e10cSrcweir ScTableRowObj* ScTableRowsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const 3164*cdf0e10cSrcweir { 3165*cdf0e10cSrcweir SCROW nRow = static_cast<SCROW>(nIndex) + nStartRow; 3166*cdf0e10cSrcweir if ( pDocShell && nRow <= nEndRow ) 3167*cdf0e10cSrcweir return new ScTableRowObj( pDocShell, nRow, nTab ); 3168*cdf0e10cSrcweir 3169*cdf0e10cSrcweir return NULL; // falscher Index 3170*cdf0e10cSrcweir } 3171*cdf0e10cSrcweir 3172*cdf0e10cSrcweir void SAL_CALL ScTableRowsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 nCount ) 3173*cdf0e10cSrcweir throw(uno::RuntimeException) 3174*cdf0e10cSrcweir { 3175*cdf0e10cSrcweir ScUnoGuard aGuard; 3176*cdf0e10cSrcweir sal_Bool bDone = sal_False; 3177*cdf0e10cSrcweir if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartRow+nPosition <= nEndRow && 3178*cdf0e10cSrcweir nStartRow+nPosition+nCount-1 <= MAXROW ) 3179*cdf0e10cSrcweir { 3180*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 3181*cdf0e10cSrcweir ScRange aRange( 0, (SCROW)(nStartRow+nPosition), nTab, 3182*cdf0e10cSrcweir MAXCOL, (SCROW)(nStartRow+nPosition+nCount-1), nTab ); 3183*cdf0e10cSrcweir bDone = aFunc.InsertCells( aRange, NULL, INS_INSROWS, sal_True, sal_True ); 3184*cdf0e10cSrcweir } 3185*cdf0e10cSrcweir if (!bDone) 3186*cdf0e10cSrcweir throw uno::RuntimeException(); // no other exceptions specified 3187*cdf0e10cSrcweir } 3188*cdf0e10cSrcweir 3189*cdf0e10cSrcweir void SAL_CALL ScTableRowsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) 3190*cdf0e10cSrcweir throw(uno::RuntimeException) 3191*cdf0e10cSrcweir { 3192*cdf0e10cSrcweir ScUnoGuard aGuard; 3193*cdf0e10cSrcweir sal_Bool bDone = sal_False; 3194*cdf0e10cSrcweir // Der zu loeschende Bereich muss innerhalb des Objekts liegen 3195*cdf0e10cSrcweir if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartRow+nIndex+nCount-1 <= nEndRow ) 3196*cdf0e10cSrcweir { 3197*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 3198*cdf0e10cSrcweir ScRange aRange( 0, (SCROW)(nStartRow+nIndex), nTab, 3199*cdf0e10cSrcweir MAXCOL, (SCROW)(nStartRow+nIndex+nCount-1), nTab ); 3200*cdf0e10cSrcweir bDone = aFunc.DeleteCells( aRange, NULL, DEL_DELROWS, sal_True, sal_True ); 3201*cdf0e10cSrcweir } 3202*cdf0e10cSrcweir if (!bDone) 3203*cdf0e10cSrcweir throw uno::RuntimeException(); // no other exceptions specified 3204*cdf0e10cSrcweir } 3205*cdf0e10cSrcweir 3206*cdf0e10cSrcweir // XEnumerationAccess 3207*cdf0e10cSrcweir 3208*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScTableRowsObj::createEnumeration() 3209*cdf0e10cSrcweir throw(uno::RuntimeException) 3210*cdf0e10cSrcweir { 3211*cdf0e10cSrcweir ScUnoGuard aGuard; 3212*cdf0e10cSrcweir return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableRowsEnumeration"))); 3213*cdf0e10cSrcweir } 3214*cdf0e10cSrcweir 3215*cdf0e10cSrcweir // XIndexAccess 3216*cdf0e10cSrcweir 3217*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTableRowsObj::getCount() throw(uno::RuntimeException) 3218*cdf0e10cSrcweir { 3219*cdf0e10cSrcweir ScUnoGuard aGuard; 3220*cdf0e10cSrcweir return nEndRow - nStartRow + 1; 3221*cdf0e10cSrcweir } 3222*cdf0e10cSrcweir 3223*cdf0e10cSrcweir uno::Any SAL_CALL ScTableRowsObj::getByIndex( sal_Int32 nIndex ) 3224*cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, 3225*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 3226*cdf0e10cSrcweir { 3227*cdf0e10cSrcweir ScUnoGuard aGuard; 3228*cdf0e10cSrcweir uno::Reference<table::XCellRange> xRow(GetObjectByIndex_Impl(nIndex)); 3229*cdf0e10cSrcweir if (xRow.is()) 3230*cdf0e10cSrcweir return uno::makeAny(xRow); 3231*cdf0e10cSrcweir else 3232*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 3233*cdf0e10cSrcweir // return uno::Any(); 3234*cdf0e10cSrcweir } 3235*cdf0e10cSrcweir 3236*cdf0e10cSrcweir uno::Type SAL_CALL ScTableRowsObj::getElementType() throw(uno::RuntimeException) 3237*cdf0e10cSrcweir { 3238*cdf0e10cSrcweir ScUnoGuard aGuard; 3239*cdf0e10cSrcweir return getCppuType((uno::Reference<table::XCellRange>*)0); 3240*cdf0e10cSrcweir } 3241*cdf0e10cSrcweir 3242*cdf0e10cSrcweir sal_Bool SAL_CALL ScTableRowsObj::hasElements() throw(uno::RuntimeException) 3243*cdf0e10cSrcweir { 3244*cdf0e10cSrcweir ScUnoGuard aGuard; 3245*cdf0e10cSrcweir return ( getCount() != 0 ); 3246*cdf0e10cSrcweir } 3247*cdf0e10cSrcweir 3248*cdf0e10cSrcweir // XPropertySet 3249*cdf0e10cSrcweir 3250*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowsObj::getPropertySetInfo() 3251*cdf0e10cSrcweir throw(uno::RuntimeException) 3252*cdf0e10cSrcweir { 3253*cdf0e10cSrcweir ScUnoGuard aGuard; 3254*cdf0e10cSrcweir static uno::Reference<beans::XPropertySetInfo> aRef( 3255*cdf0e10cSrcweir new SfxItemPropertySetInfo( lcl_GetRowsPropertyMap() )); 3256*cdf0e10cSrcweir return aRef; 3257*cdf0e10cSrcweir } 3258*cdf0e10cSrcweir 3259*cdf0e10cSrcweir void SAL_CALL ScTableRowsObj::setPropertyValue( 3260*cdf0e10cSrcweir const rtl::OUString& aPropertyName, const uno::Any& aValue ) 3261*cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, 3262*cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException, 3263*cdf0e10cSrcweir uno::RuntimeException) 3264*cdf0e10cSrcweir { 3265*cdf0e10cSrcweir ScUnoGuard aGuard; 3266*cdf0e10cSrcweir if (!pDocShell) 3267*cdf0e10cSrcweir throw uno::RuntimeException(); 3268*cdf0e10cSrcweir 3269*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 3270*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 3271*cdf0e10cSrcweir SCCOLROW nRowArr[2]; 3272*cdf0e10cSrcweir nRowArr[0] = nStartRow; 3273*cdf0e10cSrcweir nRowArr[1] = nEndRow; 3274*cdf0e10cSrcweir String aNameString(aPropertyName); 3275*cdf0e10cSrcweir 3276*cdf0e10cSrcweir if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) ) 3277*cdf0e10cSrcweir { 3278*cdf0e10cSrcweir sal_Int32 nNewHeight = 0; 3279*cdf0e10cSrcweir if ( pDoc->IsImportingXML() && ( aValue >>= nNewHeight ) ) 3280*cdf0e10cSrcweir { 3281*cdf0e10cSrcweir // used to set the stored row height for rows with optimal height when loading. 3282*cdf0e10cSrcweir 3283*cdf0e10cSrcweir // TODO: It's probably cleaner to use a different property name 3284*cdf0e10cSrcweir // for this. 3285*cdf0e10cSrcweir pDoc->SetRowHeightOnly( nStartRow, nEndRow, nTab, (sal_uInt16)HMMToTwips(nNewHeight) ); 3286*cdf0e10cSrcweir } 3287*cdf0e10cSrcweir else 3288*cdf0e10cSrcweir { 3289*cdf0e10cSrcweir sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 3290*cdf0e10cSrcweir if (bOpt) 3291*cdf0e10cSrcweir aFunc.SetWidthOrHeight( sal_False, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, sal_True, sal_True ); 3292*cdf0e10cSrcweir else 3293*cdf0e10cSrcweir { 3294*cdf0e10cSrcweir //! manually set old heights again? 3295*cdf0e10cSrcweir } 3296*cdf0e10cSrcweir } 3297*cdf0e10cSrcweir } 3298*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLHGT ) ) 3299*cdf0e10cSrcweir { 3300*cdf0e10cSrcweir sal_Int32 nNewHeight = 0; 3301*cdf0e10cSrcweir if ( aValue >>= nNewHeight ) 3302*cdf0e10cSrcweir aFunc.SetWidthOrHeight( sal_False, 1, nRowArr, nTab, SC_SIZE_ORIGINAL, 3303*cdf0e10cSrcweir (sal_uInt16)HMMToTwips(nNewHeight), sal_True, sal_True ); 3304*cdf0e10cSrcweir } 3305*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) ) 3306*cdf0e10cSrcweir { 3307*cdf0e10cSrcweir sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 3308*cdf0e10cSrcweir ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT; 3309*cdf0e10cSrcweir aFunc.SetWidthOrHeight( sal_False, 1, nRowArr, nTab, eMode, 0, sal_True, sal_True ); 3310*cdf0e10cSrcweir // SC_SIZE_DIRECT with size 0: hide 3311*cdf0e10cSrcweir } 3312*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_VISFLAG ) ) 3313*cdf0e10cSrcweir { 3314*cdf0e10cSrcweir // #i116460# Shortcut to only set the flag, without drawing layer update etc. 3315*cdf0e10cSrcweir // Should only be used from import filters. 3316*cdf0e10cSrcweir pDoc->SetRowHidden(nStartRow, nEndRow, nTab, !ScUnoHelpFunctions::GetBoolFromAny( aValue )); 3317*cdf0e10cSrcweir } 3318*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) ) 3319*cdf0e10cSrcweir { 3320*cdf0e10cSrcweir //! undo etc. 3321*cdf0e10cSrcweir if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) 3322*cdf0e10cSrcweir pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, true); 3323*cdf0e10cSrcweir else 3324*cdf0e10cSrcweir pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, false); 3325*cdf0e10cSrcweir } 3326*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE) ) 3327*cdf0e10cSrcweir { 3328*cdf0e10cSrcweir //! single function to set/remove all breaks? 3329*cdf0e10cSrcweir sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue ); 3330*cdf0e10cSrcweir for (SCROW nRow=nStartRow; nRow<=nEndRow; nRow++) 3331*cdf0e10cSrcweir if (bSet) 3332*cdf0e10cSrcweir aFunc.InsertPageBreak( sal_False, ScAddress(0,nRow,nTab), sal_True, sal_True, sal_True ); 3333*cdf0e10cSrcweir else 3334*cdf0e10cSrcweir aFunc.RemovePageBreak( sal_False, ScAddress(0,nRow,nTab), sal_True, sal_True, sal_True ); 3335*cdf0e10cSrcweir } 3336*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) ) 3337*cdf0e10cSrcweir { 3338*cdf0e10cSrcweir // #i57867# Background color is specified for row styles in the file format, 3339*cdf0e10cSrcweir // so it has to be supported along with the row properties (import only). 3340*cdf0e10cSrcweir 3341*cdf0e10cSrcweir // Use ScCellRangeObj to set the property for all cells in the rows 3342*cdf0e10cSrcweir // (this means, the "row attribute" must be set before individual cell attributes). 3343*cdf0e10cSrcweir 3344*cdf0e10cSrcweir ScRange aRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab ); 3345*cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xRangeObj = new ScCellRangeObj( pDocShell, aRange ); 3346*cdf0e10cSrcweir xRangeObj->setPropertyValue( aPropertyName, aValue ); 3347*cdf0e10cSrcweir } 3348*cdf0e10cSrcweir } 3349*cdf0e10cSrcweir 3350*cdf0e10cSrcweir uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const rtl::OUString& aPropertyName ) 3351*cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, 3352*cdf0e10cSrcweir uno::RuntimeException) 3353*cdf0e10cSrcweir { 3354*cdf0e10cSrcweir ScUnoGuard aGuard; 3355*cdf0e10cSrcweir if (!pDocShell) 3356*cdf0e10cSrcweir throw uno::RuntimeException(); 3357*cdf0e10cSrcweir 3358*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 3359*cdf0e10cSrcweir String aNameString(aPropertyName); 3360*cdf0e10cSrcweir uno::Any aAny; 3361*cdf0e10cSrcweir 3362*cdf0e10cSrcweir //! loop over all rows for current state? 3363*cdf0e10cSrcweir 3364*cdf0e10cSrcweir if ( aNameString.EqualsAscii( SC_UNONAME_CELLHGT ) ) 3365*cdf0e10cSrcweir { 3366*cdf0e10cSrcweir // for hidden row, return original height 3367*cdf0e10cSrcweir sal_uInt16 nHeight = pDoc->GetOriginalHeight( nStartRow, nTab ); 3368*cdf0e10cSrcweir aAny <<= (sal_Int32)TwipsToHMM(nHeight); 3369*cdf0e10cSrcweir } 3370*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) ) 3371*cdf0e10cSrcweir { 3372*cdf0e10cSrcweir SCROW nLastRow; 3373*cdf0e10cSrcweir bool bVis = !pDoc->RowHidden(nStartRow, nTab, nLastRow); 3374*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, bVis ); 3375*cdf0e10cSrcweir } 3376*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) ) 3377*cdf0e10cSrcweir { 3378*cdf0e10cSrcweir bool bVis = pDoc->RowFiltered(nStartRow, nTab); 3379*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, bVis ); 3380*cdf0e10cSrcweir } 3381*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) ) 3382*cdf0e10cSrcweir { 3383*cdf0e10cSrcweir sal_Bool bOpt = !(pDoc->GetRowFlags( nStartRow, nTab ) & CR_MANUALSIZE); 3384*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, bOpt ); 3385*cdf0e10cSrcweir } 3386*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) ) 3387*cdf0e10cSrcweir { 3388*cdf0e10cSrcweir ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab); 3389*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak ); 3390*cdf0e10cSrcweir } 3391*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) ) 3392*cdf0e10cSrcweir { 3393*cdf0e10cSrcweir ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab); 3394*cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) ); 3395*cdf0e10cSrcweir } 3396*cdf0e10cSrcweir else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) ) 3397*cdf0e10cSrcweir { 3398*cdf0e10cSrcweir // Use ScCellRangeObj to get the property from the cell range 3399*cdf0e10cSrcweir // (for completeness only, this is not used by the XML filter). 3400*cdf0e10cSrcweir 3401*cdf0e10cSrcweir ScRange aRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab ); 3402*cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xRangeObj = new ScCellRangeObj( pDocShell, aRange ); 3403*cdf0e10cSrcweir aAny = xRangeObj->getPropertyValue( aPropertyName ); 3404*cdf0e10cSrcweir } 3405*cdf0e10cSrcweir 3406*cdf0e10cSrcweir return aAny; 3407*cdf0e10cSrcweir } 3408*cdf0e10cSrcweir 3409*cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableRowsObj ) 3410*cdf0e10cSrcweir 3411*cdf0e10cSrcweir //------------------------------------------------------------------------ 3412*cdf0e10cSrcweir 3413*cdf0e10cSrcweir //UNUSED2008-05 ScSpreadsheetSettingsObj::ScSpreadsheetSettingsObj(ScDocShell* pDocSh) : 3414*cdf0e10cSrcweir //UNUSED2008-05 pDocShell( pDocSh ) 3415*cdf0e10cSrcweir //UNUSED2008-05 { 3416*cdf0e10cSrcweir //UNUSED2008-05 pDocShell->GetDocument()->AddUnoObject(*this); 3417*cdf0e10cSrcweir //UNUSED2008-05 } 3418*cdf0e10cSrcweir 3419*cdf0e10cSrcweir ScSpreadsheetSettingsObj::~ScSpreadsheetSettingsObj() 3420*cdf0e10cSrcweir { 3421*cdf0e10cSrcweir if (pDocShell) 3422*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 3423*cdf0e10cSrcweir } 3424*cdf0e10cSrcweir 3425*cdf0e10cSrcweir void ScSpreadsheetSettingsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 3426*cdf0e10cSrcweir { 3427*cdf0e10cSrcweir // Referenz-Update interessiert hier nicht 3428*cdf0e10cSrcweir 3429*cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) && 3430*cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 3431*cdf0e10cSrcweir { 3432*cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 3433*cdf0e10cSrcweir } 3434*cdf0e10cSrcweir } 3435*cdf0e10cSrcweir 3436*cdf0e10cSrcweir // XPropertySet 3437*cdf0e10cSrcweir 3438*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettingsObj::getPropertySetInfo() 3439*cdf0e10cSrcweir throw(uno::RuntimeException) 3440*cdf0e10cSrcweir { 3441*cdf0e10cSrcweir //! muss noch 3442*cdf0e10cSrcweir return NULL; 3443*cdf0e10cSrcweir } 3444*cdf0e10cSrcweir 3445*cdf0e10cSrcweir void SAL_CALL ScSpreadsheetSettingsObj::setPropertyValue( 3446*cdf0e10cSrcweir const rtl::OUString& /* aPropertyName */, const uno::Any& /* aValue */ ) 3447*cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, 3448*cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException, 3449*cdf0e10cSrcweir uno::RuntimeException) 3450*cdf0e10cSrcweir { 3451*cdf0e10cSrcweir //! muss noch 3452*cdf0e10cSrcweir } 3453*cdf0e10cSrcweir 3454*cdf0e10cSrcweir uno::Any SAL_CALL ScSpreadsheetSettingsObj::getPropertyValue( const rtl::OUString& /* aPropertyName */ ) 3455*cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, 3456*cdf0e10cSrcweir uno::RuntimeException) 3457*cdf0e10cSrcweir { 3458*cdf0e10cSrcweir //! muss noch 3459*cdf0e10cSrcweir return uno::Any(); 3460*cdf0e10cSrcweir } 3461*cdf0e10cSrcweir 3462*cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettingsObj ) 3463*cdf0e10cSrcweir 3464*cdf0e10cSrcweir //------------------------------------------------------------------------ 3465*cdf0e10cSrcweir 3466*cdf0e10cSrcweir ScAnnotationsObj::ScAnnotationsObj(ScDocShell* pDocSh, SCTAB nT) : 3467*cdf0e10cSrcweir pDocShell( pDocSh ), 3468*cdf0e10cSrcweir nTab( nT ) 3469*cdf0e10cSrcweir { 3470*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 3471*cdf0e10cSrcweir } 3472*cdf0e10cSrcweir 3473*cdf0e10cSrcweir ScAnnotationsObj::~ScAnnotationsObj() 3474*cdf0e10cSrcweir { 3475*cdf0e10cSrcweir if (pDocShell) 3476*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 3477*cdf0e10cSrcweir } 3478*cdf0e10cSrcweir 3479*cdf0e10cSrcweir void ScAnnotationsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 3480*cdf0e10cSrcweir { 3481*cdf0e10cSrcweir //! nTab bei Referenz-Update anpassen!!! 3482*cdf0e10cSrcweir 3483*cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) && 3484*cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 3485*cdf0e10cSrcweir { 3486*cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 3487*cdf0e10cSrcweir } 3488*cdf0e10cSrcweir } 3489*cdf0e10cSrcweir 3490*cdf0e10cSrcweir bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ) const 3491*cdf0e10cSrcweir { 3492*cdf0e10cSrcweir if (pDocShell) 3493*cdf0e10cSrcweir { 3494*cdf0e10cSrcweir sal_Int32 nFound = 0; 3495*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 3496*cdf0e10cSrcweir ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); 3497*cdf0e10cSrcweir for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) 3498*cdf0e10cSrcweir { 3499*cdf0e10cSrcweir if (pCell->HasNote()) 3500*cdf0e10cSrcweir { 3501*cdf0e10cSrcweir if (nFound == nIndex) 3502*cdf0e10cSrcweir { 3503*cdf0e10cSrcweir rPos = ScAddress( aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab() ); 3504*cdf0e10cSrcweir return true; 3505*cdf0e10cSrcweir } 3506*cdf0e10cSrcweir ++nFound; 3507*cdf0e10cSrcweir } 3508*cdf0e10cSrcweir } 3509*cdf0e10cSrcweir } 3510*cdf0e10cSrcweir return false; 3511*cdf0e10cSrcweir } 3512*cdf0e10cSrcweir 3513*cdf0e10cSrcweir ScAnnotationObj* ScAnnotationsObj::GetObjectByIndex_Impl( sal_Int32 nIndex ) const 3514*cdf0e10cSrcweir { 3515*cdf0e10cSrcweir if (pDocShell) 3516*cdf0e10cSrcweir { 3517*cdf0e10cSrcweir ScAddress aPos; 3518*cdf0e10cSrcweir if ( GetAddressByIndex_Impl( nIndex, aPos ) ) 3519*cdf0e10cSrcweir return new ScAnnotationObj( pDocShell, aPos ); 3520*cdf0e10cSrcweir } 3521*cdf0e10cSrcweir return NULL; 3522*cdf0e10cSrcweir } 3523*cdf0e10cSrcweir 3524*cdf0e10cSrcweir // XSheetAnnotations 3525*cdf0e10cSrcweir 3526*cdf0e10cSrcweir void SAL_CALL ScAnnotationsObj::insertNew( 3527*cdf0e10cSrcweir const table::CellAddress& aPosition, const ::rtl::OUString& rText ) 3528*cdf0e10cSrcweir throw(uno::RuntimeException) 3529*cdf0e10cSrcweir { 3530*cdf0e10cSrcweir ScUnoGuard aGuard; 3531*cdf0e10cSrcweir if (pDocShell) 3532*cdf0e10cSrcweir { 3533*cdf0e10cSrcweir DBG_ASSERT( aPosition.Sheet == nTab, "addAnnotation mit falschem Sheet" ); 3534*cdf0e10cSrcweir ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab ); 3535*cdf0e10cSrcweir 3536*cdf0e10cSrcweir ScDocFunc aFunc( *pDocShell ); 3537*cdf0e10cSrcweir aFunc.ReplaceNote( aPos, rText, 0, 0, sal_True ); 3538*cdf0e10cSrcweir } 3539*cdf0e10cSrcweir } 3540*cdf0e10cSrcweir 3541*cdf0e10cSrcweir void SAL_CALL ScAnnotationsObj::removeByIndex( sal_Int32 nIndex ) throw(uno::RuntimeException) 3542*cdf0e10cSrcweir { 3543*cdf0e10cSrcweir ScUnoGuard aGuard; 3544*cdf0e10cSrcweir if (pDocShell) 3545*cdf0e10cSrcweir { 3546*cdf0e10cSrcweir ScAddress aPos; 3547*cdf0e10cSrcweir if ( GetAddressByIndex_Impl( nIndex, aPos ) ) 3548*cdf0e10cSrcweir { 3549*cdf0e10cSrcweir ScMarkData aMarkData; 3550*cdf0e10cSrcweir aMarkData.SelectTable( aPos.Tab(), sal_True ); 3551*cdf0e10cSrcweir aMarkData.SetMultiMarkArea( ScRange(aPos) ); 3552*cdf0e10cSrcweir 3553*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 3554*cdf0e10cSrcweir aFunc.DeleteContents( aMarkData, IDF_NOTE, sal_True, sal_True ); 3555*cdf0e10cSrcweir } 3556*cdf0e10cSrcweir } 3557*cdf0e10cSrcweir } 3558*cdf0e10cSrcweir 3559*cdf0e10cSrcweir // XEnumerationAccess 3560*cdf0e10cSrcweir 3561*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScAnnotationsObj::createEnumeration() 3562*cdf0e10cSrcweir throw(uno::RuntimeException) 3563*cdf0e10cSrcweir { 3564*cdf0e10cSrcweir //! iterate directly (more efficiently)? 3565*cdf0e10cSrcweir 3566*cdf0e10cSrcweir ScUnoGuard aGuard; 3567*cdf0e10cSrcweir return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.CellAnnotationsEnumeration"))); 3568*cdf0e10cSrcweir } 3569*cdf0e10cSrcweir 3570*cdf0e10cSrcweir // XIndexAccess 3571*cdf0e10cSrcweir 3572*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException) 3573*cdf0e10cSrcweir { 3574*cdf0e10cSrcweir ScUnoGuard aGuard; 3575*cdf0e10cSrcweir sal_uLong nCount = 0; 3576*cdf0e10cSrcweir if (pDocShell) 3577*cdf0e10cSrcweir { 3578*cdf0e10cSrcweir ScCellIterator aCellIter( pDocShell->GetDocument(), 0,0, nTab, MAXCOL,MAXROW, nTab ); 3579*cdf0e10cSrcweir for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() ) 3580*cdf0e10cSrcweir if (pCell->HasNote()) 3581*cdf0e10cSrcweir ++nCount; 3582*cdf0e10cSrcweir } 3583*cdf0e10cSrcweir return nCount; 3584*cdf0e10cSrcweir } 3585*cdf0e10cSrcweir 3586*cdf0e10cSrcweir uno::Any SAL_CALL ScAnnotationsObj::getByIndex( sal_Int32 nIndex ) 3587*cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, 3588*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 3589*cdf0e10cSrcweir { 3590*cdf0e10cSrcweir ScUnoGuard aGuard; 3591*cdf0e10cSrcweir uno::Reference<sheet::XSheetAnnotation> xAnnotation(GetObjectByIndex_Impl(nIndex)); 3592*cdf0e10cSrcweir if (xAnnotation.is()) 3593*cdf0e10cSrcweir return uno::makeAny(xAnnotation); 3594*cdf0e10cSrcweir else 3595*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 3596*cdf0e10cSrcweir // return uno::Any(); 3597*cdf0e10cSrcweir } 3598*cdf0e10cSrcweir 3599*cdf0e10cSrcweir uno::Type SAL_CALL ScAnnotationsObj::getElementType() throw(uno::RuntimeException) 3600*cdf0e10cSrcweir { 3601*cdf0e10cSrcweir ScUnoGuard aGuard; 3602*cdf0e10cSrcweir return getCppuType((uno::Reference<sheet::XSheetAnnotation>*)0); 3603*cdf0e10cSrcweir } 3604*cdf0e10cSrcweir 3605*cdf0e10cSrcweir sal_Bool SAL_CALL ScAnnotationsObj::hasElements() throw(uno::RuntimeException) 3606*cdf0e10cSrcweir { 3607*cdf0e10cSrcweir ScUnoGuard aGuard; 3608*cdf0e10cSrcweir return ( getCount() != 0 ); 3609*cdf0e10cSrcweir } 3610*cdf0e10cSrcweir 3611*cdf0e10cSrcweir //------------------------------------------------------------------------ 3612*cdf0e10cSrcweir 3613*cdf0e10cSrcweir ScScenariosObj::ScScenariosObj(ScDocShell* pDocSh, SCTAB nT) : 3614*cdf0e10cSrcweir pDocShell( pDocSh ), 3615*cdf0e10cSrcweir nTab ( nT ) 3616*cdf0e10cSrcweir { 3617*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 3618*cdf0e10cSrcweir } 3619*cdf0e10cSrcweir 3620*cdf0e10cSrcweir ScScenariosObj::~ScScenariosObj() 3621*cdf0e10cSrcweir { 3622*cdf0e10cSrcweir if (pDocShell) 3623*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 3624*cdf0e10cSrcweir } 3625*cdf0e10cSrcweir 3626*cdf0e10cSrcweir void ScScenariosObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 3627*cdf0e10cSrcweir { 3628*cdf0e10cSrcweir if ( rHint.ISA( ScUpdateRefHint ) ) 3629*cdf0e10cSrcweir { 3630*cdf0e10cSrcweir // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint; 3631*cdf0e10cSrcweir 3632*cdf0e10cSrcweir //! Referenz-Update fuer Tab und Start/Ende 3633*cdf0e10cSrcweir } 3634*cdf0e10cSrcweir else if ( rHint.ISA( SfxSimpleHint ) && 3635*cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 3636*cdf0e10cSrcweir { 3637*cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 3638*cdf0e10cSrcweir } 3639*cdf0e10cSrcweir } 3640*cdf0e10cSrcweir 3641*cdf0e10cSrcweir // XScenarios 3642*cdf0e10cSrcweir 3643*cdf0e10cSrcweir sal_Bool ScScenariosObj::GetScenarioIndex_Impl( const rtl::OUString& rName, SCTAB& rIndex ) 3644*cdf0e10cSrcweir { 3645*cdf0e10cSrcweir //! Case-insensitiv ???? 3646*cdf0e10cSrcweir 3647*cdf0e10cSrcweir if ( pDocShell ) 3648*cdf0e10cSrcweir { 3649*cdf0e10cSrcweir String aString(rName); 3650*cdf0e10cSrcweir 3651*cdf0e10cSrcweir String aTabName; 3652*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 3653*cdf0e10cSrcweir SCTAB nCount = (SCTAB)getCount(); 3654*cdf0e10cSrcweir for (SCTAB i=0; i<nCount; i++) 3655*cdf0e10cSrcweir if (pDoc->GetName( nTab+i+1, aTabName )) 3656*cdf0e10cSrcweir if ( aTabName == aString ) 3657*cdf0e10cSrcweir { 3658*cdf0e10cSrcweir rIndex = i; 3659*cdf0e10cSrcweir return sal_True; 3660*cdf0e10cSrcweir } 3661*cdf0e10cSrcweir } 3662*cdf0e10cSrcweir 3663*cdf0e10cSrcweir return sal_False; 3664*cdf0e10cSrcweir } 3665*cdf0e10cSrcweir 3666*cdf0e10cSrcweir ScTableSheetObj* ScScenariosObj::GetObjectByIndex_Impl(sal_Int32 nIndex) 3667*cdf0e10cSrcweir { 3668*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16)getCount(); 3669*cdf0e10cSrcweir if ( pDocShell && nIndex >= 0 && nIndex < nCount ) 3670*cdf0e10cSrcweir return new ScTableSheetObj( pDocShell, nTab+static_cast<SCTAB>(nIndex)+1 ); 3671*cdf0e10cSrcweir 3672*cdf0e10cSrcweir return NULL; // kein Dokument oder falscher Index 3673*cdf0e10cSrcweir } 3674*cdf0e10cSrcweir 3675*cdf0e10cSrcweir ScTableSheetObj* ScScenariosObj::GetObjectByName_Impl(const rtl::OUString& aName) 3676*cdf0e10cSrcweir { 3677*cdf0e10cSrcweir SCTAB nIndex; 3678*cdf0e10cSrcweir if ( pDocShell && GetScenarioIndex_Impl( aName, nIndex ) ) 3679*cdf0e10cSrcweir return new ScTableSheetObj( pDocShell, nTab+nIndex+1 ); 3680*cdf0e10cSrcweir 3681*cdf0e10cSrcweir return NULL; // nicht gefunden 3682*cdf0e10cSrcweir } 3683*cdf0e10cSrcweir 3684*cdf0e10cSrcweir void SAL_CALL ScScenariosObj::addNewByName( const rtl::OUString& aName, 3685*cdf0e10cSrcweir const uno::Sequence<table::CellRangeAddress>& aRanges, 3686*cdf0e10cSrcweir const rtl::OUString& aComment ) 3687*cdf0e10cSrcweir throw(uno::RuntimeException) 3688*cdf0e10cSrcweir { 3689*cdf0e10cSrcweir ScUnoGuard aGuard; 3690*cdf0e10cSrcweir if ( pDocShell ) 3691*cdf0e10cSrcweir { 3692*cdf0e10cSrcweir ScMarkData aMarkData; 3693*cdf0e10cSrcweir aMarkData.SelectTable( nTab, sal_True ); 3694*cdf0e10cSrcweir 3695*cdf0e10cSrcweir sal_uInt16 nRangeCount = (sal_uInt16)aRanges.getLength(); 3696*cdf0e10cSrcweir if (nRangeCount) 3697*cdf0e10cSrcweir { 3698*cdf0e10cSrcweir const table::CellRangeAddress* pAry = aRanges.getConstArray(); 3699*cdf0e10cSrcweir for (sal_uInt16 i=0; i<nRangeCount; i++) 3700*cdf0e10cSrcweir { 3701*cdf0e10cSrcweir DBG_ASSERT( pAry[i].Sheet == nTab, "addScenario mit falscher Tab" ); 3702*cdf0e10cSrcweir ScRange aRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab, 3703*cdf0e10cSrcweir (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab ); 3704*cdf0e10cSrcweir 3705*cdf0e10cSrcweir aMarkData.SetMultiMarkArea( aRange ); 3706*cdf0e10cSrcweir } 3707*cdf0e10cSrcweir } 3708*cdf0e10cSrcweir 3709*cdf0e10cSrcweir String aNameStr(aName); 3710*cdf0e10cSrcweir String aCommStr(aComment); 3711*cdf0e10cSrcweir 3712*cdf0e10cSrcweir Color aColor( COL_LIGHTGRAY ); // Default 3713*cdf0e10cSrcweir sal_uInt16 nFlags = SC_SCENARIO_SHOWFRAME | SC_SCENARIO_PRINTFRAME | SC_SCENARIO_TWOWAY | SC_SCENARIO_PROTECT; 3714*cdf0e10cSrcweir 3715*cdf0e10cSrcweir pDocShell->MakeScenario( nTab, aNameStr, aCommStr, aColor, nFlags, aMarkData ); 3716*cdf0e10cSrcweir } 3717*cdf0e10cSrcweir } 3718*cdf0e10cSrcweir 3719*cdf0e10cSrcweir void SAL_CALL ScScenariosObj::removeByName( const rtl::OUString& aName ) 3720*cdf0e10cSrcweir throw(uno::RuntimeException) 3721*cdf0e10cSrcweir { 3722*cdf0e10cSrcweir ScUnoGuard aGuard; 3723*cdf0e10cSrcweir SCTAB nIndex; 3724*cdf0e10cSrcweir if ( pDocShell && GetScenarioIndex_Impl( aName, nIndex ) ) 3725*cdf0e10cSrcweir { 3726*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 3727*cdf0e10cSrcweir aFunc.DeleteTable( nTab+nIndex+1, sal_True, sal_True ); 3728*cdf0e10cSrcweir } 3729*cdf0e10cSrcweir } 3730*cdf0e10cSrcweir 3731*cdf0e10cSrcweir // XEnumerationAccess 3732*cdf0e10cSrcweir 3733*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScScenariosObj::createEnumeration() 3734*cdf0e10cSrcweir throw(uno::RuntimeException) 3735*cdf0e10cSrcweir { 3736*cdf0e10cSrcweir ScUnoGuard aGuard; 3737*cdf0e10cSrcweir return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.ScenariosEnumeration"))); 3738*cdf0e10cSrcweir } 3739*cdf0e10cSrcweir 3740*cdf0e10cSrcweir // XIndexAccess 3741*cdf0e10cSrcweir 3742*cdf0e10cSrcweir sal_Int32 SAL_CALL ScScenariosObj::getCount() throw(uno::RuntimeException) 3743*cdf0e10cSrcweir { 3744*cdf0e10cSrcweir ScUnoGuard aGuard; 3745*cdf0e10cSrcweir SCTAB nCount = 0; 3746*cdf0e10cSrcweir if ( pDocShell ) 3747*cdf0e10cSrcweir { 3748*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 3749*cdf0e10cSrcweir if (!pDoc->IsScenario(nTab)) 3750*cdf0e10cSrcweir { 3751*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 3752*cdf0e10cSrcweir SCTAB nNext = nTab + 1; 3753*cdf0e10cSrcweir while (nNext < nTabCount && pDoc->IsScenario(nNext)) 3754*cdf0e10cSrcweir { 3755*cdf0e10cSrcweir ++nCount; 3756*cdf0e10cSrcweir ++nNext; 3757*cdf0e10cSrcweir } 3758*cdf0e10cSrcweir } 3759*cdf0e10cSrcweir } 3760*cdf0e10cSrcweir return nCount; 3761*cdf0e10cSrcweir } 3762*cdf0e10cSrcweir 3763*cdf0e10cSrcweir uno::Any SAL_CALL ScScenariosObj::getByIndex( sal_Int32 nIndex ) 3764*cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, 3765*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 3766*cdf0e10cSrcweir { 3767*cdf0e10cSrcweir ScUnoGuard aGuard; 3768*cdf0e10cSrcweir uno::Reference<sheet::XScenario> xScen(GetObjectByIndex_Impl(nIndex)); 3769*cdf0e10cSrcweir if (xScen.is()) 3770*cdf0e10cSrcweir return uno::makeAny(xScen); 3771*cdf0e10cSrcweir else 3772*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 3773*cdf0e10cSrcweir // return uno::Any(); 3774*cdf0e10cSrcweir } 3775*cdf0e10cSrcweir 3776*cdf0e10cSrcweir uno::Type SAL_CALL ScScenariosObj::getElementType() throw(uno::RuntimeException) 3777*cdf0e10cSrcweir { 3778*cdf0e10cSrcweir ScUnoGuard aGuard; 3779*cdf0e10cSrcweir return getCppuType((uno::Reference<sheet::XScenario>*)0); 3780*cdf0e10cSrcweir } 3781*cdf0e10cSrcweir 3782*cdf0e10cSrcweir sal_Bool SAL_CALL ScScenariosObj::hasElements() throw(uno::RuntimeException) 3783*cdf0e10cSrcweir { 3784*cdf0e10cSrcweir ScUnoGuard aGuard; 3785*cdf0e10cSrcweir return ( getCount() != 0 ); 3786*cdf0e10cSrcweir } 3787*cdf0e10cSrcweir 3788*cdf0e10cSrcweir uno::Any SAL_CALL ScScenariosObj::getByName( const rtl::OUString& aName ) 3789*cdf0e10cSrcweir throw(container::NoSuchElementException, 3790*cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 3791*cdf0e10cSrcweir { 3792*cdf0e10cSrcweir ScUnoGuard aGuard; 3793*cdf0e10cSrcweir uno::Reference<sheet::XScenario> xScen(GetObjectByName_Impl(aName)); 3794*cdf0e10cSrcweir if (xScen.is()) 3795*cdf0e10cSrcweir return uno::makeAny(xScen); 3796*cdf0e10cSrcweir else 3797*cdf0e10cSrcweir throw container::NoSuchElementException(); 3798*cdf0e10cSrcweir // return uno::Any(); 3799*cdf0e10cSrcweir } 3800*cdf0e10cSrcweir 3801*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScScenariosObj::getElementNames() 3802*cdf0e10cSrcweir throw(uno::RuntimeException) 3803*cdf0e10cSrcweir { 3804*cdf0e10cSrcweir ScUnoGuard aGuard; 3805*cdf0e10cSrcweir SCTAB nCount = (SCTAB)getCount(); 3806*cdf0e10cSrcweir uno::Sequence<rtl::OUString> aSeq(nCount); 3807*cdf0e10cSrcweir 3808*cdf0e10cSrcweir if ( pDocShell ) // sonst ist auch Count = 0 3809*cdf0e10cSrcweir { 3810*cdf0e10cSrcweir String aTabName; 3811*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 3812*cdf0e10cSrcweir rtl::OUString* pAry = aSeq.getArray(); 3813*cdf0e10cSrcweir for (SCTAB i=0; i<nCount; i++) 3814*cdf0e10cSrcweir if (pDoc->GetName( nTab+i+1, aTabName )) 3815*cdf0e10cSrcweir pAry[i] = aTabName; 3816*cdf0e10cSrcweir } 3817*cdf0e10cSrcweir 3818*cdf0e10cSrcweir return aSeq; 3819*cdf0e10cSrcweir } 3820*cdf0e10cSrcweir 3821*cdf0e10cSrcweir sal_Bool SAL_CALL ScScenariosObj::hasByName( const rtl::OUString& aName ) 3822*cdf0e10cSrcweir throw(uno::RuntimeException) 3823*cdf0e10cSrcweir { 3824*cdf0e10cSrcweir ScUnoGuard aGuard; 3825*cdf0e10cSrcweir SCTAB nIndex; 3826*cdf0e10cSrcweir return GetScenarioIndex_Impl( aName, nIndex ); 3827*cdf0e10cSrcweir } 3828*cdf0e10cSrcweir 3829*cdf0e10cSrcweir 3830*cdf0e10cSrcweir 3831*cdf0e10cSrcweir 3832*cdf0e10cSrcweir 3833