LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - cellsuno.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 4227 5388 78.5 %
Date: 2014-04-11 Functions: 382 474 80.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "scitems.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : #include <svx/svdpool.hxx>
      23             : 
      24             : #include <svx/algitem.hxx>
      25             : #include <editeng/boxitem.hxx>
      26             : #include <editeng/brushitem.hxx>
      27             : #include <editeng/editeng.hxx>
      28             : #include <editeng/flditem.hxx>
      29             : #include <editeng/justifyitem.hxx>
      30             : #include "editeng/editobj.hxx"
      31             : #include <svx/fmdpage.hxx>
      32             : #include <editeng/langitem.hxx>
      33             : #include <sfx2/linkmgr.hxx>
      34             : #include <svl/srchitem.hxx>
      35             : #include "svl/sharedstringpool.hxx"
      36             : #include <svx/unomid.hxx>
      37             : #include <editeng/unoprnms.hxx>
      38             : #include <editeng/unotext.hxx>
      39             : #include <svx/svdpage.hxx>
      40             : #include <sfx2/bindings.hxx>
      41             : #include <svl/zforlist.hxx>
      42             : #include <svl/zformat.hxx>
      43             : #include <comphelper/servicehelper.hxx>
      44             : #include <cppuhelper/supportsservice.hxx>
      45             : #include <float.h>
      46             : 
      47             : #include <com/sun/star/awt/XBitmap.hpp>
      48             : #include <com/sun/star/util/CellProtection.hpp>
      49             : #include <com/sun/star/table/CellHoriJustify.hpp>
      50             : #include <com/sun/star/table/CellOrientation.hpp>
      51             : #include <com/sun/star/table/CellVertJustify2.hpp>
      52             : #include <com/sun/star/table/ShadowFormat.hpp>
      53             : #include <com/sun/star/table/TableBorder.hpp>
      54             : #include <com/sun/star/table/BorderLineStyle.hpp>
      55             : #include <com/sun/star/sheet/CellFlags.hpp>
      56             : #include <com/sun/star/sheet/FormulaResult.hpp>
      57             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      58             : #include <com/sun/star/lang/Locale.hpp>
      59             : #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
      60             : #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
      61             : #include <com/sun/star/text/WritingMode2.hpp>
      62             : #include <com/sun/star/text/textfield/Type.hpp>
      63             : 
      64             : #include "autoform.hxx"
      65             : #include "cellmergeoption.hxx"
      66             : #include "cellsuno.hxx"
      67             : #include "cursuno.hxx"
      68             : #include "textuno.hxx"
      69             : #include "editsrc.hxx"
      70             : #include "notesuno.hxx"
      71             : #include "fielduno.hxx"
      72             : #include "docuno.hxx"
      73             : #include "datauno.hxx"
      74             : #include "dapiuno.hxx"
      75             : #include "chartuno.hxx"
      76             : #include "fmtuno.hxx"
      77             : #include "miscuno.hxx"
      78             : #include "convuno.hxx"
      79             : #include "srchuno.hxx"
      80             : #include "nameuno.hxx"
      81             : #include "targuno.hxx"
      82             : #include "tokenuno.hxx"
      83             : #include "eventuno.hxx"
      84             : #include "docsh.hxx"
      85             : #include "markdata.hxx"
      86             : #include "patattr.hxx"
      87             : #include "docpool.hxx"
      88             : #include "docfunc.hxx"
      89             : #include "dbdocfun.hxx"
      90             : #include "olinefun.hxx"
      91             : #include "hints.hxx"
      92             : #include "formulacell.hxx"
      93             : #include "undocell.hxx"
      94             : #include "undotab.hxx"
      95             : #include "undoblk.hxx"
      96             : #include "stlsheet.hxx"
      97             : #include "dbdata.hxx"
      98             : #include "attrib.hxx"
      99             : #include "chartarr.hxx"
     100             : #include "chartlis.hxx"
     101             : #include "drwlayer.hxx"
     102             : #include "printfun.hxx"
     103             : #include "prnsave.hxx"
     104             : #include "tablink.hxx"
     105             : #include "dociter.hxx"
     106             : #include "rangeutl.hxx"
     107             : #include "conditio.hxx"
     108             : #include "validat.hxx"
     109             : #include "sc.hrc"
     110             : #include "brdcst.hxx"
     111             : #include "cellform.hxx"
     112             : #include "globstr.hrc"
     113             : #include "unonames.hxx"
     114             : #include "styleuno.hxx"
     115             : #include "rangeseq.hxx"
     116             : #include "unowids.hxx"
     117             : #include "paramisc.hxx"
     118             : #include "queryentry.hxx"
     119             : #include "formula/errorcodes.hxx"
     120             : #include "unoreflist.hxx"
     121             : #include "formula/grammar.hxx"
     122             : #include "editeng/escapementitem.hxx"
     123             : #include "stringutil.hxx"
     124             : #include "formulaiter.hxx"
     125             : #include "tokenarray.hxx"
     126             : #include "stylehelper.hxx"
     127             : #include "dputil.hxx"
     128             : 
     129             : #include <list>
     130             : #include <boost/scoped_ptr.hpp>
     131             : 
     132             : using namespace com::sun::star;
     133             : 
     134          35 : class ScNamedEntry
     135             : {
     136             :     OUString  aName;
     137             :     ScRange   aRange;
     138             : 
     139             : public:
     140          35 :             ScNamedEntry(const OUString& rN, const ScRange& rR) :
     141          35 :                 aName(rN), aRange(rR) {}
     142             : 
     143         144 :     const OUString& GetName() const     { return aName; }
     144          79 :     const ScRange&  GetRange() const    { return aRange; }
     145             : };
     146             : 
     147             : //  The names in the maps must be sorted according to strcmp!
     148             : //! Instead of Which-ID 0 use special IDs and do not compare via names!
     149             : 
     150             : //  Left/Right/Top/BottomBorder are mapped directly to the core items,
     151             : //  not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
     152             : 
     153       27679 : static const SfxItemPropertySet* lcl_GetCellsPropertySet()
     154             : {
     155             :     static const SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
     156             :     {
     157          27 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, getCppuType((OUString*)0),        0 | beans::PropertyAttribute::READONLY, 0 },
     158          27 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     159          27 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     160          27 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     161          27 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    getCppuType((sal_Int32*)0),            0, MID_BACK_COLOR },
     162          27 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    getCppuType((util::CellProtection*)0), 0, 0 },
     163          27 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,getCppuType((OUString*)0),        0, 0 },
     164          27 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    getCppuType((sal_Int32*)0),            0, 0 },
     165          27 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     166          27 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     167          27 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,getCppuType((sal_Int16*)0),         0, MID_EMPHASIS },
     168          27 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     169          27 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     170          27 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     171          27 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     172          27 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     173          27 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     174          27 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     175          27 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     176          27 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     177          27 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     178          27 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     179          27 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     180          27 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     181          27 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     182          27 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     183          27 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     184          27 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   getCppuType((float*)0),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     185          27 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     186          27 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     187          27 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, getCppuType((lang::Locale*)0),         0, MID_LANG_LOCALE },
     188          27 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     189          27 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     190          27 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     191          27 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     192          27 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     193          27 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  getCppuType((awt::FontSlant*)0),       0, MID_POSTURE },
     194          27 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     195          27 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     196          27 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   getCppuType((sal_Int16*)0),            0, MID_RELIEF },
     197          27 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     198          27 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,getCppuType((sal_Int16*)0),           0, MID_CROSS_OUT },
     199          27 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     200          27 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     201          27 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     202          27 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   getCppuType((float*)0),                0, MID_WEIGHT },
     203          27 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     204          27 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     205          27 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     206          27 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     207          27 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     208          27 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     209          27 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     210          27 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     211          27 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     212          27 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     213          27 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     214          27 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     215          27 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
     216          27 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     217          27 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     218          27 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     219          27 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     220          27 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     221          27 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  getCppuType((sal_Int32*)0),            0, 0 },
     222          27 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
     223          27 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       getCppuType((table::CellOrientation*)0), 0, 0 },
     224          27 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     225          27 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     226          27 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        getCppuType((sal_Int16*)0),            0, 0 }, //! CONVERT_TWIPS
     227          27 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     228          27 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     229          27 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     230          27 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     231          27 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     232          27 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     233          27 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     234          27 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     235          27 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     236          27 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     237          27 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  getCppuType((sal_Int32*)0),            0, 0 },
     238          27 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   getCppuType((sal_Int32*)0), 0, 0 },
     239          27 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        getCppuType((table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
     240          27 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     241          27 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, getCppuType((table::TableBorder*)0),   0, 0 | CONVERT_TWIPS },
     242          27 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, getCppuType((table::TableBorder2*)0),   0, 0 | CONVERT_TWIPS },
     243          27 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     244          27 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     245          27 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
     246          27 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     247          27 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     248          27 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     249          27 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   getCppuType((sal_Int32*)0), 0, 0 },
     250          27 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     251          27 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    getCppuType((sal_Int16*)0),            0, 0 },
     252          27 :         {OUString(SC_UNONAME_HYPERLINK),  ATTR_HYPERLINK, getCppuType((OUString*)0),        0, 0 },
     253             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     254       30298 :     };
     255       27679 :     static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
     256       27679 :     return &aCellsPropertySet;
     257             : }
     258             : 
     259             : //  CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
     260             : //  mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
     261             : 
     262       22638 : static const SfxItemPropertySet* lcl_GetRangePropertySet()
     263             : {
     264             :     static const SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
     265             :     {
     266          27 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, getCppuType((OUString*)0),        0 | beans::PropertyAttribute::READONLY, 0 },
     267          27 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     268          27 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     269          27 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     270          27 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    getCppuType((sal_Int32*)0),            0, MID_BACK_COLOR },
     271          27 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    getCppuType((util::CellProtection*)0), 0, 0 },
     272          27 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,getCppuType((OUString*)0),        0, 0 },
     273          27 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    getCppuType((sal_Int32*)0),            0, 0 },
     274          27 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     275          27 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     276          27 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,getCppuType((sal_Int16*)0),         0, MID_EMPHASIS },
     277          27 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     278          27 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     279          27 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     280          27 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     281          27 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     282          27 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     283          27 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     284          27 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     285          27 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     286          27 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     287          27 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     288          27 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     289          27 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     290          27 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     291          27 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     292          27 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     293          27 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   getCppuType((float*)0),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     294          27 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     295          27 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     296          27 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, getCppuType((lang::Locale*)0),         0, MID_LANG_LOCALE },
     297          27 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     298          27 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     299          27 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     300          27 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     301          27 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     302          27 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  getCppuType((awt::FontSlant*)0),       0, MID_POSTURE },
     303          27 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     304          27 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     305          27 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   getCppuType((sal_Int16*)0),            0, MID_RELIEF },
     306          27 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     307          27 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,getCppuType((sal_Int16*)0),           0, MID_CROSS_OUT },
     308          27 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     309          27 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     310          27 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     311          27 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   getCppuType((float*)0),                0, MID_WEIGHT },
     312          27 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     313          27 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     314          27 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     315          27 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     316          27 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     317          27 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     318          27 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     319          27 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     320          27 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     321          27 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     322          27 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     323          27 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     324          27 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   getCppuType((table::CellHoriJustify*)0),   0, MID_HORJUST_HORJUST },
     325          27 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     326          27 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     327          27 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     328          27 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     329          27 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     330          27 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  getCppuType((sal_Int32*)0),            0, 0 },
     331          27 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
     332          27 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       getCppuType((table::CellOrientation*)0), 0, 0 },
     333          27 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     334          27 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     335          27 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        getCppuType((sal_Int16*)0),            0, 0 }, //! CONVERT_TWIPS
     336          27 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     337          27 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     338          27 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     339          27 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     340          27 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     341          27 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     342          27 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     343          27 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     344          27 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     getCppuType((awt::Point*)0),           0 | beans::PropertyAttribute::READONLY, 0 },
     345          27 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     346          27 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     347          27 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  getCppuType((sal_Int32*)0),            0, 0 },
     348          27 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   getCppuType((sal_Int32*)0), 0, 0 },
     349          27 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        getCppuType((table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
     350          27 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     351          27 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    getCppuType((awt::Size*)0),            0 | beans::PropertyAttribute::READONLY, 0 },
     352          27 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, getCppuType((table::TableBorder*)0),   0, 0 | CONVERT_TWIPS },
     353          27 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, getCppuType((table::TableBorder2*)0),   0, 0 | CONVERT_TWIPS },
     354          27 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     355          27 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     356          27 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
     357          27 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     358          27 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     359          27 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     360          27 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   getCppuType((sal_Int32*)0), 0, 0 },
     361          27 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     362          27 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    getCppuType((sal_Int16*)0),            0, 0 },
     363             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     364       25284 :     };
     365       22638 :     static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
     366       22638 :     return &aRangePropertySet;
     367             : }
     368             : 
     369             : //  Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
     370             : //  mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
     371             : 
     372       12584 : static const SfxItemPropertySet* lcl_GetCellPropertySet()
     373             : {
     374             :     static const SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
     375             :     {
     376          21 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, getCppuType((OUString*)0),        0 | beans::PropertyAttribute::READONLY, 0 },
     377          21 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     378          21 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     379          21 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     380          21 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    getCppuType((sal_Int32*)0),            0, MID_BACK_COLOR },
     381          21 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    getCppuType((util::CellProtection*)0), 0, 0 },
     382          21 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,getCppuType((OUString*)0),        0, 0 },
     383          21 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    getCppuType((sal_Int32*)0),            0, 0 },
     384          21 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     385          21 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     386          21 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,getCppuType((sal_Int16*)0),         0, MID_EMPHASIS },
     387          21 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     388          21 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     389          21 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     390          21 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     391          21 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     392          21 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     393          21 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     394          21 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     395          21 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     396          21 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     397          21 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     398          21 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     399          21 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     400          21 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     401          21 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     402          21 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     403          21 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   getCppuType((float*)0),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     404          21 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     405          21 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     406          21 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, getCppuType((lang::Locale*)0),         0, MID_LANG_LOCALE },
     407          21 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     408          21 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     409          21 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     410          21 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     411          21 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     412          21 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  getCppuType((awt::FontSlant*)0),       0, MID_POSTURE },
     413          21 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     414          21 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     415          21 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   getCppuType((sal_Int16*)0),            0, MID_RELIEF },
     416          21 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     417          21 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,getCppuType((sal_Int16*)0),           0, MID_CROSS_OUT },
     418          21 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     419          21 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     420          21 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     421          21 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   getCppuType((float*)0),                0, MID_WEIGHT },
     422          21 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     423          21 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     424          21 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     425          21 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     426          21 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     427          21 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     428          21 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     429          21 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     430          21 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     431          21 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     432          21 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     433          21 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     434          21 :         {OUString(SC_UNONAME_FORMLOC),  SC_WID_UNO_FORMLOC, getCppuType((OUString*)0),        0, 0 },
     435          21 :         {OUString(SC_UNONAME_FORMRT),   SC_WID_UNO_FORMRT,  getCppuType((table::CellContentType*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
     436          21 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
     437          21 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     438          21 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     439          21 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     440          21 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     441          21 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     442          21 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  getCppuType((sal_Int32*)0),            0, 0 },
     443          21 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
     444          21 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       getCppuType((table::CellOrientation*)0), 0, 0 },
     445          21 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     446          21 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     447          21 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        getCppuType((sal_Int16*)0),            0, 0 }, //! CONVERT_TWIPS
     448          21 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     449          21 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     450          21 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     451          21 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     452          21 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     453          21 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     454          21 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     455          21 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     456          21 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     getCppuType((awt::Point*)0),           0 | beans::PropertyAttribute::READONLY, 0 },
     457          21 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     458          21 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     459          21 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  getCppuType((sal_Int32*)0),            0, 0 },
     460          21 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   getCppuType((sal_Int32*)0), 0, 0 },
     461          21 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        getCppuType((table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
     462          21 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     463          21 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    getCppuType((awt::Size*)0),            0 | beans::PropertyAttribute::READONLY, 0 },
     464          21 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, getCppuType((table::TableBorder*)0),   0, 0 | CONVERT_TWIPS },
     465          21 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, getCppuType((table::TableBorder2*)0),   0, 0 | CONVERT_TWIPS },
     466          21 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     467          21 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     468          21 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
     469          21 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     470          21 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     471          21 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     472          21 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   getCppuType((sal_Int32*)0), 0, 0 },
     473          21 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     474          21 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    getCppuType((sal_Int16*)0),            0, 0 },
     475          21 :         {OUString(UNO_NAME_EDIT_CHAR_ESCAPEMENT),   EE_CHAR_ESCAPEMENT, getCppuType((sal_Int32*)0),            0, 0 },
     476          21 :         {OUString(SC_UNONAME_HYPERLINK),  ATTR_HYPERLINK, getCppuType((OUString*)0),        0, 0 },
     477             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     478       14726 :     };
     479       12584 :     static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
     480       12584 :     return &aCellPropertySet;
     481             : }
     482             : 
     483             : //  Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
     484             : //  mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
     485             : 
     486        1088 : static const SfxItemPropertySet* lcl_GetColumnPropertySet()
     487             : {
     488             :     static const SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
     489             :     {
     490           6 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, getCppuType((OUString*)0),        0 | beans::PropertyAttribute::READONLY, 0 },
     491           6 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     492           6 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     493           6 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     494           6 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    getCppuType((sal_Int32*)0),            0, MID_BACK_COLOR },
     495           6 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    getCppuType((util::CellProtection*)0), 0, 0 },
     496           6 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,getCppuType((OUString*)0),        0, 0 },
     497           6 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    getCppuType((sal_Int32*)0),            0, 0 },
     498           6 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     499           6 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     500           6 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,getCppuType((sal_Int16*)0),         0, MID_EMPHASIS },
     501           6 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     502           6 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     503           6 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     504           6 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     505           6 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     506           6 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     507           6 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     508           6 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     509           6 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     510           6 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     511           6 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     512           6 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     513           6 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     514           6 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     515           6 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     516           6 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     517           6 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   getCppuType((float*)0),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     518           6 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     519           6 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     520           6 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, getCppuType((lang::Locale*)0),         0, MID_LANG_LOCALE },
     521           6 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     522           6 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     523           6 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     524           6 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     525           6 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     526           6 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  getCppuType((awt::FontSlant*)0),       0, MID_POSTURE },
     527           6 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     528           6 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     529           6 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   getCppuType((sal_Int16*)0),            0, MID_RELIEF },
     530           6 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     531           6 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,getCppuType((sal_Int16*)0),           0, MID_CROSS_OUT },
     532           6 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     533           6 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     534           6 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     535           6 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   getCppuType((float*)0),                0, MID_WEIGHT },
     536           6 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     537           6 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     538           6 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     539           6 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     540           6 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     541           6 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     542           6 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     543           6 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     544           6 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     545           6 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     546           6 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     547           6 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     548           6 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
     549           6 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     550           6 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     551           6 :         {OUString(SC_UNONAME_MANPAGE),  SC_WID_UNO_MANPAGE, getBooleanCppuType(),                  0, 0 },
     552           6 :         {OUString(SC_UNONAME_NEWPAGE),  SC_WID_UNO_NEWPAGE, getBooleanCppuType(),                  0, 0 },
     553           6 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     554           6 :         {OUString(SC_UNONAME_CELLVIS),  SC_WID_UNO_CELLVIS, getBooleanCppuType(),                  0, 0 },
     555           6 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     556           6 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     557           6 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  getCppuType((sal_Int32*)0),            0, 0 },
     558           6 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
     559           6 :         {OUString(SC_UNONAME_OWIDTH),   SC_WID_UNO_OWIDTH,  getBooleanCppuType(),                  0, 0 },
     560           6 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       getCppuType((table::CellOrientation*)0), 0, 0 },
     561           6 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     562           6 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     563           6 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        getCppuType((sal_Int16*)0),            0, 0 }, //! CONVERT_TWIPS
     564           6 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     565           6 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     566           6 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     567           6 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     568           6 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     569           6 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     570           6 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     571           6 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     572           6 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     getCppuType((awt::Point*)0),           0 | beans::PropertyAttribute::READONLY, 0 },
     573           6 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     574           6 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     575           6 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  getCppuType((sal_Int32*)0),            0, 0 },
     576           6 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   getCppuType((sal_Int32*)0), 0, 0 },
     577           6 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        getCppuType((table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
     578           6 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     579           6 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    getCppuType((awt::Size*)0),            0 | beans::PropertyAttribute::READONLY, 0 },
     580           6 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, getCppuType((table::TableBorder*)0),   0, 0 | CONVERT_TWIPS },
     581           6 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, getCppuType((table::TableBorder2*)0),   0, 0 | CONVERT_TWIPS },
     582           6 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     583           6 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     584           6 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
     585           6 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     586           6 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     587           6 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     588           6 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   getCppuType((sal_Int32*)0), 0, 0 },
     589           6 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     590           6 :         {OUString(SC_UNONAME_CELLWID),  SC_WID_UNO_CELLWID, getCppuType((sal_Int32*)0),            0, 0 },
     591           6 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    getCppuType((sal_Int16*)0),            0, 0 },
     592             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     593        1706 :     };
     594        1088 :     static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
     595        1088 :     return &aColumnPropertySet;
     596             : }
     597             : 
     598         107 : static const SfxItemPropertySet* lcl_GetRowPropertySet()
     599             : {
     600             :     static const SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
     601             :     {
     602           7 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, getCppuType((OUString*)0),        0 | beans::PropertyAttribute::READONLY, 0 },
     603           7 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     604           7 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     605           7 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     606           7 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    getCppuType((sal_Int32*)0),            0, MID_BACK_COLOR },
     607           7 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    getCppuType((util::CellProtection*)0), 0, 0 },
     608           7 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,getCppuType((OUString*)0),        0, 0 },
     609           7 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    getCppuType((sal_Int32*)0),            0, 0 },
     610           7 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     611           7 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     612           7 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,getCppuType((sal_Int16*)0),         0, MID_EMPHASIS },
     613           7 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     614           7 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     615           7 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     616           7 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     617           7 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     618           7 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     619           7 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     620           7 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     621           7 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     622           7 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     623           7 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     624           7 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     625           7 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     626           7 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     627           7 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     628           7 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     629           7 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   getCppuType((float*)0),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     630           7 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     631           7 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     632           7 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, getCppuType((lang::Locale*)0),         0, MID_LANG_LOCALE },
     633           7 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     634           7 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     635           7 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     636           7 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     637           7 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     638           7 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  getCppuType((awt::FontSlant*)0),       0, MID_POSTURE },
     639           7 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     640           7 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     641           7 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   getCppuType((sal_Int16*)0),            0, MID_RELIEF },
     642           7 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     643           7 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,getCppuType((sal_Int16*)0),           0, MID_CROSS_OUT },
     644           7 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     645           7 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     646           7 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     647           7 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   getCppuType((float*)0),                0, MID_WEIGHT },
     648           7 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     649           7 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     650           7 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     651           7 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     652           7 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     653           7 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     654           7 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     655           7 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     656           7 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     657           7 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     658           7 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     659           7 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     660           7 :         {OUString(SC_UNONAME_CELLHGT),  SC_WID_UNO_CELLHGT, getCppuType((sal_Int32*)0),            0, 0 },
     661           7 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
     662           7 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     663           7 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     664           7 :         {OUString(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,getBooleanCppuType(),                  0, 0 },
     665           7 :         {OUString(SC_UNONAME_MANPAGE),  SC_WID_UNO_MANPAGE, getBooleanCppuType(),                  0, 0 },
     666           7 :         {OUString(SC_UNONAME_NEWPAGE),  SC_WID_UNO_NEWPAGE, getBooleanCppuType(),                  0, 0 },
     667           7 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     668           7 :         {OUString(SC_UNONAME_CELLVIS),  SC_WID_UNO_CELLVIS, getBooleanCppuType(),                  0, 0 },
     669           7 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     670           7 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     671           7 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  getCppuType((sal_Int32*)0),            0, 0 },
     672           7 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
     673           7 :         {OUString(SC_UNONAME_OHEIGHT),  SC_WID_UNO_OHEIGHT, getBooleanCppuType(),                  0, 0 },
     674           7 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       getCppuType((table::CellOrientation*)0), 0, 0 },
     675           7 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     676           7 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     677           7 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        getCppuType((sal_Int16*)0),            0, 0 }, //! CONVERT_TWIPS
     678           7 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     679           7 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     680           7 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     681           7 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     682           7 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     683           7 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     684           7 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     685           7 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     686           7 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     getCppuType((awt::Point*)0),           0 | beans::PropertyAttribute::READONLY, 0 },
     687           7 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     688           7 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     689           7 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  getCppuType((sal_Int32*)0),            0, 0 },
     690           7 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   getCppuType((sal_Int32*)0), 0, 0 },
     691           7 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        getCppuType((table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
     692           7 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     693           7 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    getCppuType((awt::Size*)0),            0 | beans::PropertyAttribute::READONLY, 0 },
     694           7 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, getCppuType((table::TableBorder*)0),   0, 0 | CONVERT_TWIPS },
     695           7 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, getCppuType((table::TableBorder2*)0),   0, 0 | CONVERT_TWIPS },
     696           7 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     697           7 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     698           7 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
     699           7 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     700           7 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     701           7 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     702           7 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   getCppuType((sal_Int32*)0), 0, 0 },
     703           7 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     704           7 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    getCppuType((sal_Int16*)0),            0, 0 },
     705             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     706         835 :     };
     707         107 :     static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
     708         107 :     return &aRowPropertySet;
     709             : }
     710             : 
     711        2891 : static const SfxItemPropertySet* lcl_GetSheetPropertySet()
     712             : {
     713             :     static const SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
     714             :     {
     715          27 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, getCppuType((OUString*)0),        0 | beans::PropertyAttribute::READONLY, 0 },
     716          27 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     717          27 :         {OUString(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,getBooleanCppuType(),                 0, 0 },
     718          27 :         {OUString(SC_UNONAME_BORDCOL),  SC_WID_UNO_BORDCOL, getCppuType((sal_Int32*)0),            0, 0 },
     719          27 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     720          27 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     721          27 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    getCppuType((sal_Int32*)0),            0, MID_BACK_COLOR },
     722          27 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    getCppuType((util::CellProtection*)0), 0, 0 },
     723          27 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,getCppuType((OUString*)0),        0, 0 },
     724          27 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    getCppuType((sal_Int32*)0),            0, 0 },
     725          27 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     726          27 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     727          27 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,getCppuType((sal_Int16*)0),         0, MID_EMPHASIS },
     728          27 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     729          27 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     730          27 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     731          27 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
     732          27 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     733          27 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     734          27 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
     735          27 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     736          27 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     737          27 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_FAMILY_NAME },
     738          27 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     739          27 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     740          27 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
     741          27 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     742          27 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     743          27 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      getCppuType((OUString*)0),        0, MID_FONT_STYLE_NAME },
     744          27 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   getCppuType((float*)0),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     745          27 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     746          27 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,getCppuType((float*)0),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     747          27 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, getCppuType((lang::Locale*)0),         0, MID_LANG_LOCALE },
     748          27 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     749          27 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,getCppuType((lang::Locale*)0),          0, MID_LANG_LOCALE },
     750          27 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     751          27 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     752          27 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     753          27 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  getCppuType((awt::FontSlant*)0),       0, MID_POSTURE },
     754          27 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     755          27 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,getCppuType((awt::FontSlant*)0),     0, MID_POSTURE },
     756          27 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   getCppuType((sal_Int16*)0),            0, MID_RELIEF },
     757          27 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     758          27 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,getCppuType((sal_Int16*)0),           0, MID_CROSS_OUT },
     759          27 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,getCppuType((sal_Int16*)0),            0, MID_TL_STYLE },
     760          27 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
     761          27 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     762          27 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   getCppuType((float*)0),                0, MID_WEIGHT },
     763          27 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     764          27 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,getCppuType((float*)0),               0, MID_WEIGHT },
     765          27 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     766          27 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     767          27 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     768          27 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     769          27 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     770          27 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
     771          27 :         {OUString(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,getBooleanCppuType(),                  0, 0 },
     772          27 :         {OUString(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,getBooleanCppuType(),                  0, 0 },
     773          27 :         {OUString(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,getBooleanCppuType(),                  0, 0 },
     774          27 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     775          27 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     776          27 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
     777          27 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
     778          27 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
     779          27 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     780          27 :         {OUString(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,getBooleanCppuType(),                  0, 0 },
     781          27 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     782          27 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     783          27 :         {OUString(SC_UNONAME_CELLVIS),  SC_WID_UNO_CELLVIS, getBooleanCppuType(),                  0, 0 },
     784          27 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     785          27 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
     786          27 :         {OUString(SC_UNO_LINKDISPBIT),  SC_WID_UNO_LINKDISPBIT,getCppuType((uno::Reference<awt::XBitmap>*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
     787          27 :         {OUString(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,getCppuType((OUString*)0),    0 | beans::PropertyAttribute::READONLY, 0 },
     788          27 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  getCppuType((sal_Int32*)0),            0, 0 },
     789          27 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
     790          27 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       getCppuType((table::CellOrientation*)0), 0, 0 },
     791          27 :         {OUString(SC_UNONAME_PAGESTL),  SC_WID_UNO_PAGESTL, getCppuType((OUString*)0),        0, 0 },
     792          27 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     793          27 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     794          27 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        getCppuType((sal_Int16*)0),            0, 0 }, //! CONVERT_TWIPS
     795          27 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     796          27 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     797          27 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     798          27 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     799          27 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
     800          27 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     801          27 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     802          27 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        getCppuType((sal_Int32*)0),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     803          27 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     getCppuType((awt::Point*)0),           0 | beans::PropertyAttribute::READONLY, 0 },
     804          27 :         {OUString(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,getBooleanCppuType(),                 0, 0 },
     805          27 :         {OUString(SC_UNONAME_PROTECT),  SC_WID_UNO_PROTECT, getBooleanCppuType(),                  0, 0 },
     806          27 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     807          27 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
     808          27 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  getCppuType((sal_Int32*)0),            0, 0 },
     809          27 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   getCppuType((sal_Int32*)0), 0, 0 },
     810          27 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        getCppuType((table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
     811          27 :         {OUString(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,getBooleanCppuType(),                  0, 0 },
     812          27 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     813          27 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    getCppuType((awt::Size*)0),            0 | beans::PropertyAttribute::READONLY, 0 },
     814          27 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, getCppuType((table::TableBorder*)0),   0, 0 | CONVERT_TWIPS },
     815          27 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, getCppuType((table::TableBorder2*)0),   0, 0 | CONVERT_TWIPS },
     816          27 :         {OUString(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,getCppuType((sal_Int16*)0),           0, 0 },
     817          27 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     818          27 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
     819          27 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
     820          27 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     821          27 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     822          27 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
     823          27 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   getCppuType((sal_Int32*)0), 0, 0 },
     824          27 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::getCppuType((const sal_Int32*)0),   0, 0 },
     825          27 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    getCppuType((sal_Int16*)0),            0, 0 },
     826          27 :         {OUString(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, getCppuType((sal_Int32*)0), 0, 0 },
     827          27 :         {OUString(SC_UNO_CODENAME),        SC_WID_UNO_CODENAME, getCppuType(static_cast< const OUString * >(0)),    0, 0},
     828          27 :         {OUString(SC_UNO_NAMEDRANGES), SC_WID_UNO_NAMES, getCppuType((uno::Reference<sheet::XNamedRanges>*)0), 0, 0 },
     829             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     830        5996 :     };
     831        2891 :     static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
     832        2891 :     return &aSheetPropertySet;
     833             : }
     834             : 
     835           2 : static const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
     836             : {
     837             :     static const SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
     838             :     {
     839          96 :         SVX_UNOEDIT_CHAR_PROPERTIES,
     840           2 :         SVX_UNOEDIT_FONT_PROPERTIES,
     841          28 :         SVX_UNOEDIT_PARA_PROPERTIES,
     842           4 :         SVX_UNOEDIT_NUMBERING_PROPERTIE,    // for completeness of service ParagraphProperties
     843           2 :         {OUString(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
     844           2 :         {OUString(SC_UNONAME_USERDEF),  EE_PARA_XMLATTRIBS, getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
     845             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     846         138 :     };
     847           2 :     return aEditPropertyMap_Impl;
     848             : }
     849          10 : static const SvxItemPropertySet* lcl_GetEditPropertySet()
     850             : {
     851          10 :     static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() );
     852          10 :     return &aEditPropertySet;
     853             : }
     854             : 
     855             : using sc::HMMToTwips;
     856             : using sc::TwipsToHMM;
     857             : 
     858             : #define SCCHARPROPERTIES_SERVICE    "com.sun.star.style.CharacterProperties"
     859             : #define SCPARAPROPERTIES_SERVICE    "com.sun.star.style.ParagraphProperties"
     860             : #define SCCELLPROPERTIES_SERVICE    "com.sun.star.table.CellProperties"
     861             : #define SCCELLRANGE_SERVICE         "com.sun.star.table.CellRange"
     862             : #define SCCELL_SERVICE              "com.sun.star.table.Cell"
     863             : #define SCSHEETCELLRANGES_SERVICE   "com.sun.star.sheet.SheetCellRanges"
     864             : #define SCSHEETCELLRANGE_SERVICE    "com.sun.star.sheet.SheetCellRange"
     865             : #define SCSPREADSHEET_SERVICE       "com.sun.star.sheet.Spreadsheet"
     866             : #define SCSHEETCELL_SERVICE         "com.sun.star.sheet.SheetCell"
     867             : 
     868           0 : SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
     869           0 : SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
     870           1 : SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
     871           1 : SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
     872           0 : SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
     873           0 : SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
     874           0 : SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
     875           0 : SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
     876           0 : SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
     877             : 
     878             : //! ScLinkListener in anderes File verschieben !!!
     879             : 
     880        6082 : ScLinkListener::~ScLinkListener()
     881             : {
     882        6082 : }
     883             : 
     884         357 : void ScLinkListener::Notify( const SfxHint& rHint )
     885             : {
     886         357 :     aLink.Call( (SfxHint*)&rHint );
     887         357 : }
     888             : 
     889           1 : static void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
     890             : {
     891           1 :     uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
     892           1 :     if (xInfo.is())
     893             :     {
     894           1 :         uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
     895           1 :         const beans::Property* pAry = aSeq.getConstArray();
     896           1 :         sal_uLong nCount = aSeq.getLength();
     897          10 :         for (sal_uLong i=0; i<nCount; i++)
     898             :         {
     899           9 :             OUString aName(pAry[i].Name);
     900           9 :             rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
     901          10 :         }
     902           1 :     }
     903           1 : }
     904             : 
     905          57 : static SCTAB lcl_FirstTab( const ScRangeList& rRanges )
     906             : {
     907             :     OSL_ENSURE(rRanges.size() >= 1, "was fuer Ranges ?!?!");
     908          57 :     const ScRange* pFirst = rRanges[ 0 ];
     909          57 :     if (pFirst)
     910          57 :         return pFirst->aStart.Tab();
     911             : 
     912           0 :     return 0;   // soll nicht sein
     913             : }
     914             : 
     915          71 : static sal_Bool lcl_WholeSheet( const ScRangeList& rRanges )
     916             : {
     917          71 :     if ( rRanges.size() == 1 )
     918             :     {
     919          64 :         const ScRange* pRange = rRanges[0];
     920         140 :         if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
     921          88 :                        pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
     922          12 :             return sal_True;
     923             :     }
     924          59 :     return false;
     925             : }
     926             : 
     927             : namespace {
     928             : template<typename BorderLineType>
     929          36 : const ::editeng::SvxBorderLine* lcl_getBorderLine(
     930             :         ::editeng::SvxBorderLine& rLine, const BorderLineType& rStruct )
     931             : {
     932             :     // Convert from 1/100mm to Twips.
     933          36 :     if (!SvxBoxItem::LineToSvxLine( rStruct, rLine, true))
     934          36 :         return NULL;
     935             : 
     936           0 :     if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
     937           0 :         return &rLine;
     938             :     else
     939           0 :         return NULL;
     940             : }
     941             : }
     942             : 
     943          36 : const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
     944             :         ::editeng::SvxBorderLine& rLine, const table::BorderLine& rStruct )
     945             : {
     946          36 :     return lcl_getBorderLine( rLine, rStruct);
     947             : }
     948             : 
     949           0 : const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
     950             :         ::editeng::SvxBorderLine& rLine, const table::BorderLine2& rStruct )
     951             : {
     952           0 :     return lcl_getBorderLine( rLine, rStruct);
     953             : }
     954             : 
     955             : 
     956             : namespace {
     957             : template<typename TableBorderType>
     958           6 : void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder )
     959             : {
     960           6 :     ::editeng::SvxBorderLine aLine;
     961           6 :     rOuter.SetDistance( (sal_uInt16)HMMToTwips( rBorder.Distance ) );
     962           6 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ),         BOX_LINE_TOP );
     963           6 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ),      BOX_LINE_BOTTOM );
     964           6 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ),        BOX_LINE_LEFT );
     965           6 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ),       BOX_LINE_RIGHT );
     966           6 :     rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ),  BOXINFO_LINE_HORI );
     967           6 :     rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ),    BOXINFO_LINE_VERT );
     968           6 :     rInner.SetValid( VALID_TOP,      rBorder.IsTopLineValid );
     969           6 :     rInner.SetValid( VALID_BOTTOM,   rBorder.IsBottomLineValid );
     970           6 :     rInner.SetValid( VALID_LEFT,     rBorder.IsLeftLineValid );
     971           6 :     rInner.SetValid( VALID_RIGHT,    rBorder.IsRightLineValid );
     972           6 :     rInner.SetValid( VALID_HORI,     rBorder.IsHorizontalLineValid );
     973           6 :     rInner.SetValid( VALID_VERT,     rBorder.IsVerticalLineValid );
     974           6 :     rInner.SetValid( VALID_DISTANCE, rBorder.IsDistanceValid );
     975           6 :     rInner.SetTable( true );
     976           6 : }
     977             : }
     978             : 
     979           6 : void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
     980             : {
     981           6 :     lcl_fillBoxItems( rOuter, rInner, rBorder);
     982           6 : }
     983             : 
     984           0 : void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder2& rBorder )
     985             : {
     986           0 :     lcl_fillBoxItems( rOuter, rInner, rBorder);
     987           0 : }
     988             : 
     989             : 
     990         186 : void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine )
     991             : {
     992             :     // Convert from Twips to 1/100mm.
     993         186 :     table::BorderLine2 aStruct( SvxBoxItem::SvxLineToLine( pLine, true));
     994         186 :     rStruct = aStruct;
     995         186 : }
     996             : 
     997          90 : void ScHelperFunctions::FillBorderLine( table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine )
     998             : {
     999          90 :     rStruct = SvxBoxItem::SvxLineToLine( pLine, true);
    1000          90 : }
    1001             : 
    1002             : 
    1003             : namespace {
    1004             : template<typename TableBorderItem>
    1005          46 : void lcl_fillTableBorder( TableBorderItem& rBorder, const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner,
    1006             :         bool bInvalidateHorVerDist )
    1007             : {
    1008          46 :     ScHelperFunctions::FillBorderLine( rBorder.TopLine,         rOuter.GetTop() );
    1009          46 :     ScHelperFunctions::FillBorderLine( rBorder.BottomLine,      rOuter.GetBottom() );
    1010          46 :     ScHelperFunctions::FillBorderLine( rBorder.LeftLine,        rOuter.GetLeft() );
    1011          46 :     ScHelperFunctions::FillBorderLine( rBorder.RightLine,       rOuter.GetRight() );
    1012          46 :     ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine,  rInner.GetHori() );
    1013          46 :     ScHelperFunctions::FillBorderLine( rBorder.VerticalLine,    rInner.GetVert() );
    1014             : 
    1015          46 :     rBorder.Distance                = rOuter.GetDistance();
    1016          46 :     rBorder.IsTopLineValid          = rInner.IsValid(VALID_TOP);
    1017          46 :     rBorder.IsBottomLineValid       = rInner.IsValid(VALID_BOTTOM);
    1018          46 :     rBorder.IsLeftLineValid         = rInner.IsValid(VALID_LEFT);
    1019          46 :     rBorder.IsRightLineValid        = rInner.IsValid(VALID_RIGHT);
    1020          46 :     rBorder.IsHorizontalLineValid   = !bInvalidateHorVerDist && rInner.IsValid(VALID_HORI);
    1021          46 :     rBorder.IsVerticalLineValid     = !bInvalidateHorVerDist && rInner.IsValid(VALID_VERT);
    1022          46 :     rBorder.IsDistanceValid         = !bInvalidateHorVerDist && rInner.IsValid(VALID_DISTANCE);
    1023          46 : }
    1024             : }
    1025             : 
    1026          31 : void ScHelperFunctions::AssignTableBorderToAny( uno::Any& rAny,
    1027             :         const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
    1028             : {
    1029          31 :     table::TableBorder aBorder;
    1030          31 :     lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
    1031          31 :     rAny <<= aBorder;
    1032          31 : }
    1033             : 
    1034          15 : void ScHelperFunctions::AssignTableBorder2ToAny( uno::Any& rAny,
    1035             :         const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
    1036             : {
    1037          15 :     table::TableBorder2 aBorder;
    1038          15 :     lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
    1039          15 :     rAny <<= aBorder;
    1040          15 : }
    1041             : 
    1042             : //! lcl_ApplyBorder nach docfunc verschieben!
    1043             : 
    1044           4 : void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
    1045             :                         const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
    1046             : {
    1047           4 :     ScDocument* pDoc = pDocShell->GetDocument();
    1048           4 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    1049           4 :     ScDocument* pUndoDoc = NULL;
    1050           4 :     if (bUndo)
    1051           4 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1052           4 :     size_t nCount = rRanges.size();
    1053           8 :     for (size_t i = 0; i < nCount; ++i)
    1054             :     {
    1055           4 :         ScRange aRange( *rRanges[ i ] );
    1056           4 :         SCTAB nTab = aRange.aStart.Tab();
    1057             : 
    1058           4 :         if (bUndo)
    1059             :         {
    1060           4 :             if ( i==0 )
    1061           4 :                 pUndoDoc->InitUndo( pDoc, nTab, nTab );
    1062             :             else
    1063           0 :                 pUndoDoc->AddUndoTab( nTab, nTab );
    1064           4 :             pDoc->CopyToDocument( aRange, IDF_ATTRIB, false, pUndoDoc );
    1065             :         }
    1066             : 
    1067           4 :         ScMarkData aMark;
    1068           4 :         aMark.SetMarkArea( aRange );
    1069           4 :         aMark.SelectTable( nTab, true );
    1070             : 
    1071           4 :         pDoc->ApplySelectionFrame( aMark, &rOuter, &rInner );
    1072             :         // RowHeight bei Umrandung alleine nicht noetig
    1073           4 :     }
    1074             : 
    1075           4 :     if (bUndo)
    1076             :     {
    1077           4 :         pDocShell->GetUndoManager()->AddUndoAction(
    1078           4 :                 new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
    1079             :     }
    1080             : 
    1081           8 :     for (size_t i = 0; i < nCount; ++i )
    1082           4 :         pDocShell->PostPaint( *rRanges[ i ], PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
    1083             : 
    1084           4 :     pDocShell->SetDocumentModified();
    1085           4 : }
    1086             : 
    1087             : //! move lcl_PutDataArray to docfunc?
    1088             : //! merge loop with ScFunctionAccess::callFunction
    1089             : 
    1090           8 : static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
    1091             :                         const uno::Sequence< uno::Sequence<uno::Any> >& aData )
    1092             : {
    1093           8 :     ScDocument* pDoc = rDocShell.GetDocument();
    1094           8 :     SCTAB nTab = rRange.aStart.Tab();
    1095           8 :     SCCOL nStartCol = rRange.aStart.Col();
    1096           8 :     SCROW nStartRow = rRange.aStart.Row();
    1097           8 :     SCCOL nEndCol = rRange.aEnd.Col();
    1098           8 :     SCROW nEndRow = rRange.aEnd.Row();
    1099           8 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    1100             : 
    1101           8 :     if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
    1102             :     {
    1103             :         //! error message
    1104           0 :         return false;
    1105             :     }
    1106             : 
    1107           8 :     long nCols = 0;
    1108           8 :     long nRows = aData.getLength();
    1109           8 :     const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
    1110           8 :     if ( nRows )
    1111           8 :         nCols = pArray[0].getLength();
    1112             : 
    1113           8 :     if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
    1114             :     {
    1115             :         //! error message?
    1116           0 :         return false;
    1117             :     }
    1118             : 
    1119           8 :     ScDocument* pUndoDoc = NULL;
    1120           8 :     if ( bUndo )
    1121             :     {
    1122           8 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1123           8 :         pUndoDoc->InitUndo( pDoc, nTab, nTab );
    1124           8 :         pDoc->CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, false, pUndoDoc );
    1125             :     }
    1126             : 
    1127           8 :     pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
    1128             : 
    1129           8 :     sal_Bool bError = false;
    1130           8 :     SCROW nDocRow = nStartRow;
    1131         416 :     for (long nRow=0; nRow<nRows; nRow++)
    1132             :     {
    1133         408 :         const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
    1134         408 :         if ( rColSeq.getLength() == nCols )
    1135             :         {
    1136         408 :             SCCOL nDocCol = nStartCol;
    1137         408 :             const uno::Any* pColArr = rColSeq.getConstArray();
    1138       20440 :             for (long nCol=0; nCol<nCols; nCol++)
    1139             :             {
    1140       20032 :                 ScAddress aPos(nDocCol, nDocRow, nTab);
    1141             : 
    1142       20032 :                 const uno::Any& rElement = pColArr[nCol];
    1143       20032 :                 switch( rElement.getValueTypeClass() )
    1144             :                 {
    1145             :                     case uno::TypeClass_VOID:
    1146             :                     {
    1147             :                         // void = "no value"
    1148           0 :                         pDoc->SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
    1149             :                     }
    1150           0 :                     break;
    1151             : 
    1152             :                     //  #87871# accept integer types because Basic passes a floating point
    1153             :                     //  variable as byte, short or long if it's an integer number.
    1154             :                     case uno::TypeClass_BYTE:
    1155             :                     case uno::TypeClass_SHORT:
    1156             :                     case uno::TypeClass_UNSIGNED_SHORT:
    1157             :                     case uno::TypeClass_LONG:
    1158             :                     case uno::TypeClass_UNSIGNED_LONG:
    1159             :                     case uno::TypeClass_FLOAT:
    1160             :                     case uno::TypeClass_DOUBLE:
    1161             :                     {
    1162       20032 :                         double fVal(0.0);
    1163       20032 :                         rElement >>= fVal;
    1164       20032 :                         pDoc->SetValue(aPos, fVal);
    1165             :                     }
    1166       20032 :                     break;
    1167             : 
    1168             :                     case uno::TypeClass_STRING:
    1169             :                     {
    1170           0 :                         OUString aUStr;
    1171           0 :                         rElement >>= aUStr;
    1172           0 :                         if ( !aUStr.isEmpty() )
    1173             :                         {
    1174           0 :                             ScSetStringParam aParam;
    1175           0 :                             aParam.setTextInput();
    1176           0 :                             pDoc->SetString(aPos, aUStr, &aParam);
    1177           0 :                         }
    1178             :                     }
    1179           0 :                     break;
    1180             : 
    1181             :                     // accept Sequence<FormulaToken> for formula cells
    1182             :                     case uno::TypeClass_SEQUENCE:
    1183             :                     {
    1184           0 :                         uno::Sequence< sheet::FormulaToken > aTokens;
    1185           0 :                         if ( rElement >>= aTokens )
    1186             :                         {
    1187           0 :                             ScTokenArray aTokenArray;
    1188           0 :                             ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, aTokens );
    1189           0 :                             pDoc->SetFormula(aPos, aTokenArray);
    1190             :                         }
    1191             :                         else
    1192           0 :                             bError = true;
    1193             :                     }
    1194           0 :                     break;
    1195             : 
    1196             :                     default:
    1197           0 :                         bError = true;      // invalid type
    1198             :                 }
    1199       20032 :                 ++nDocCol;
    1200             :             }
    1201             :         }
    1202             :         else
    1203           0 :             bError = sal_True;                          // wrong size
    1204             : 
    1205         408 :         ++nDocRow;
    1206             :     }
    1207             : 
    1208           8 :     sal_Bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
    1209             : 
    1210           8 :     if ( pUndoDoc )
    1211             :     {
    1212           8 :         ScMarkData aDestMark;
    1213           8 :         aDestMark.SelectOneTable( nTab );
    1214           8 :         rDocShell.GetUndoManager()->AddUndoAction(
    1215             :             new ScUndoPaste(
    1216             :                 &rDocShell, ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab),
    1217           8 :                 aDestMark, pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
    1218             :     }
    1219             : 
    1220           8 :     if (!bHeight)
    1221           8 :         rDocShell.PostPaint( rRange, PAINT_GRID );      // AdjustRowHeight may have painted already
    1222             : 
    1223           8 :     rDocShell.SetDocumentModified();
    1224             : 
    1225           8 :     return !bError;
    1226             : }
    1227             : 
    1228           2 : static sal_Bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
    1229             :         const uno::Sequence< uno::Sequence<OUString> >& aData,
    1230             :         const formula::FormulaGrammar::Grammar eGrammar )
    1231             : {
    1232           2 :     ScDocument* pDoc = rDocShell.GetDocument();
    1233           2 :     SCTAB nTab = rRange.aStart.Tab();
    1234           2 :     SCCOL nStartCol = rRange.aStart.Col();
    1235           2 :     SCROW nStartRow = rRange.aStart.Row();
    1236           2 :     SCCOL nEndCol = rRange.aEnd.Col();
    1237           2 :     SCROW nEndRow = rRange.aEnd.Row();
    1238           2 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    1239             : 
    1240           2 :     if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
    1241             :     {
    1242             :         //! error message
    1243           0 :         return false;
    1244             :     }
    1245             : 
    1246           2 :     long nCols = 0;
    1247           2 :     long nRows = aData.getLength();
    1248           2 :     const uno::Sequence<OUString>* pArray = aData.getConstArray();
    1249           2 :     if ( nRows )
    1250           2 :         nCols = pArray[0].getLength();
    1251             : 
    1252           2 :     if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
    1253             :     {
    1254             :         //! error message?
    1255           0 :         return false;
    1256             :     }
    1257             : 
    1258           2 :     ScDocument* pUndoDoc = NULL;
    1259           2 :     if ( bUndo )
    1260             :     {
    1261           2 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1262           2 :         pUndoDoc->InitUndo( pDoc, nTab, nTab );
    1263           2 :         pDoc->CopyToDocument( rRange, IDF_CONTENTS, false, pUndoDoc );
    1264             :     }
    1265             : 
    1266           2 :     pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
    1267             : 
    1268           2 :     bool bError = false;
    1269           2 :     SCROW nDocRow = nStartRow;
    1270          12 :     for (long nRow=0; nRow<nRows; nRow++)
    1271             :     {
    1272          10 :         const uno::Sequence<OUString>& rColSeq = pArray[nRow];
    1273          10 :         if ( rColSeq.getLength() == nCols )
    1274             :         {
    1275          10 :             SCCOL nDocCol = nStartCol;
    1276          10 :             const OUString* pColArr = rColSeq.getConstArray();
    1277          50 :             for (long nCol=0; nCol<nCols; nCol++)
    1278             :             {
    1279          40 :                 OUString aText(pColArr[nCol]);
    1280          40 :                 ScAddress aPos( nDocCol, nDocRow, nTab );
    1281             : 
    1282             :                 ScInputStringType aRes =
    1283             :                     ScStringUtil::parseInputString(
    1284          80 :                         *pDoc->GetFormatTable(), aText, LANGUAGE_ENGLISH_US);
    1285          40 :                 switch (aRes.meType)
    1286             :                 {
    1287             :                     case ScInputStringType::Formula:
    1288           0 :                         pDoc->SetFormula(aPos, aRes.maText, eGrammar);
    1289           0 :                     break;
    1290             :                     case ScInputStringType::Number:
    1291           0 :                         pDoc->SetValue(aPos, aRes.mfValue);
    1292           0 :                     break;
    1293             :                     case ScInputStringType::Text:
    1294           1 :                         pDoc->SetTextCell(aPos, aRes.maText);
    1295           1 :                     break;
    1296             :                     default:
    1297             :                         ;
    1298             :                 }
    1299             : 
    1300          40 :                 ++nDocCol;
    1301          40 :             }
    1302             :         }
    1303             :         else
    1304           0 :             bError = true;                          // wrong size
    1305             : 
    1306          10 :         ++nDocRow;
    1307             :     }
    1308             : 
    1309           2 :     sal_Bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
    1310             : 
    1311           2 :     if ( pUndoDoc )
    1312             :     {
    1313           2 :         ScMarkData aDestMark;
    1314           2 :         aDestMark.SelectOneTable( nTab );
    1315           2 :         rDocShell.GetUndoManager()->AddUndoAction(
    1316             :             new ScUndoPaste( &rDocShell,
    1317             :                 ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark,
    1318           2 :                 pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
    1319             :     }
    1320             : 
    1321           2 :     if (!bHeight)
    1322           2 :         rDocShell.PostPaint( rRange, PAINT_GRID );      // AdjustRowHeight may have painted already
    1323             : 
    1324           2 :     rDocShell.SetDocumentModified();
    1325             : 
    1326           2 :     return !bError;
    1327             : }
    1328             : 
    1329             : //  used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
    1330         226 : static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, sal_Bool bEnglish )
    1331             : {
    1332         226 :     if (!pDoc)
    1333           0 :         return EMPTY_OUSTRING;
    1334             : 
    1335         226 :     ScRefCellValue aCell;
    1336         226 :     aCell.assign(*pDoc, rPos);
    1337         226 :     if (aCell.isEmpty())
    1338         111 :         return EMPTY_OUSTRING;
    1339             : 
    1340         230 :     OUString aVal;
    1341             : 
    1342         115 :     CellType eType = aCell.meType;
    1343         115 :     if (eType == CELLTYPE_FORMULA)
    1344             :     {
    1345          61 :         ScFormulaCell* pForm = aCell.mpFormula;
    1346          61 :         pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
    1347          61 :         return aVal;
    1348             :     }
    1349             : 
    1350             :     SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
    1351          54 :                                                 pDoc->GetFormatTable();
    1352             :     // Since the English formatter was constructed with
    1353             :     // LANGUAGE_ENGLISH_US the "General" format has index key 0,
    1354             :     // we don't have to query.
    1355          54 :     sal_uInt32 nNumFmt = bEnglish ? 0 : pDoc->GetNumberFormat(rPos);
    1356             : 
    1357          54 :     if (eType == CELLTYPE_EDIT)
    1358             :     {
    1359             :         //  GetString an der EditCell macht Leerzeichen aus Umbruechen,
    1360             :         //  hier werden die Umbrueche aber gebraucht
    1361           0 :         const EditTextObject* pData = aCell.mpEditText;
    1362           0 :         if (pData)
    1363             :         {
    1364           0 :             EditEngine& rEngine = pDoc->GetEditEngine();
    1365           0 :             rEngine.SetText(*pData);
    1366           0 :             aVal = rEngine.GetText(LINEEND_LF);
    1367             :         }
    1368             :     }
    1369             :     else
    1370          54 :         ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, pDoc);
    1371             : 
    1372             :     //  ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
    1373          54 :     if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
    1374             :     {
    1375             :         double fDummy;
    1376          24 :         OUString aTempString = aVal;
    1377          24 :         sal_Bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
    1378          24 :         if ( bIsNumberFormat )
    1379           0 :             aTempString = "'" + aTempString;
    1380          24 :         else if ( aTempString.startsWith("'") )
    1381             :         {
    1382             :             //  if the string starts with a "'", add another one because setFormula
    1383             :             //  strips one (like text input, except for "text" number formats)
    1384           0 :             if ( bEnglish || ( pFormatter->GetType(nNumFmt) != NUMBERFORMAT_TEXT ) )
    1385           0 :                 aTempString = "'" + aTempString;
    1386             :         }
    1387          24 :         aVal = aTempString;
    1388             :     }
    1389         280 :     return aVal;
    1390             : }
    1391             : 
    1392       22638 : ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
    1393       22638 :     pPropSet(lcl_GetCellsPropertySet()),
    1394             :     pDocShell( pDocSh ),
    1395             :     pValueListener( NULL ),
    1396             :     pCurrentFlat( NULL ),
    1397             :     pCurrentDeep( NULL ),
    1398             :     pCurrentDataSet( NULL ),
    1399             :     pNoDfltCurrentDataSet( NULL ),
    1400             :     pMarkData( NULL ),
    1401             :     nObjectId( 0 ),
    1402             :     bChartColAsHdr( false ),
    1403             :     bChartRowAsHdr( false ),
    1404             :     bCursorOnly( false ),
    1405             :     bGotDataChangedHint( false ),
    1406       45276 :     aValueListeners( 0 )
    1407             : {
    1408       22638 :     ScRange aCellRange(rR);
    1409       22638 :     aCellRange.Justify();
    1410       22638 :     aRanges.Append( aCellRange );
    1411             : 
    1412       22638 :     if (pDocShell)  // Null if created with createInstance
    1413             :     {
    1414       22637 :         ScDocument* pDoc = pDocShell->GetDocument();
    1415       22637 :         pDoc->AddUnoObject(*this);
    1416       22637 :         nObjectId = pDoc->GetNewUnoId();
    1417             :     }
    1418       22638 : }
    1419             : 
    1420        1112 : ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
    1421        1112 :     pPropSet(lcl_GetCellsPropertySet()),
    1422             :     pDocShell( pDocSh ),
    1423             :     pValueListener( NULL ),
    1424             :     pCurrentFlat( NULL ),
    1425             :     pCurrentDeep( NULL ),
    1426             :     pCurrentDataSet( NULL ),
    1427             :     pNoDfltCurrentDataSet( NULL ),
    1428             :     pMarkData( NULL ),
    1429             :     aRanges( rR ),
    1430             :     nObjectId( 0 ),
    1431             :     bChartColAsHdr( false ),
    1432             :     bChartRowAsHdr( false ),
    1433             :     bCursorOnly( false ),
    1434             :     bGotDataChangedHint( false ),
    1435        2224 :     aValueListeners( 0 )
    1436             : {
    1437        1112 :     if (pDocShell)  // Null if created with createInstance
    1438             :     {
    1439        1112 :         ScDocument* pDoc = pDocShell->GetDocument();
    1440        1112 :         pDoc->AddUnoObject(*this);
    1441        1112 :         nObjectId = pDoc->GetNewUnoId();
    1442             :     }
    1443        1112 : }
    1444             : 
    1445       47268 : ScCellRangesBase::~ScCellRangesBase()
    1446             : {
    1447             :     //  call RemoveUnoObject first, so no notification can happen
    1448             :     //  during ForgetCurrentAttrs
    1449             : 
    1450       23634 :     if (pDocShell)
    1451       20010 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    1452             : 
    1453       23634 :     ForgetCurrentAttrs();
    1454       23634 :     ForgetMarkData();
    1455             : 
    1456       23634 :     delete pValueListener;
    1457             : 
    1458             :     //! XChartDataChangeEventListener abmelden ??
    1459             :     //! (ChartCollection haelt dann auch dieses Objekt fest!)
    1460       23634 : }
    1461             : 
    1462      192742 : void ScCellRangesBase::ForgetCurrentAttrs()
    1463             : {
    1464      192742 :     delete pCurrentFlat;
    1465      192742 :     delete pCurrentDeep;
    1466      192742 :     delete pCurrentDataSet;
    1467      192742 :     delete pNoDfltCurrentDataSet;
    1468      192742 :     pCurrentFlat = NULL;
    1469      192742 :     pCurrentDeep = NULL;
    1470      192742 :     pCurrentDataSet = NULL;
    1471      192742 :     pNoDfltCurrentDataSet = NULL;
    1472             : 
    1473             :     // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
    1474      192742 : }
    1475             : 
    1476       29142 : void ScCellRangesBase::ForgetMarkData()
    1477             : {
    1478       29142 :     delete pMarkData;
    1479       29142 :     pMarkData = NULL;
    1480       29142 : }
    1481             : 
    1482        6278 : const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
    1483             : {
    1484             :     //  get and cache direct cell attributes for this object's range
    1485             : 
    1486        6278 :     if ( !pCurrentFlat && pDocShell )
    1487             :     {
    1488         150 :         ScDocument* pDoc = pDocShell->GetDocument();
    1489         150 :         pCurrentFlat = pDoc->CreateSelectionPattern( *GetMarkData(), false );
    1490             :     }
    1491        6278 :     return pCurrentFlat;
    1492             : }
    1493             : 
    1494        6314 : const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
    1495             : {
    1496             :     //  get and cache cell attributes (incl. styles) for this object's range
    1497             : 
    1498        6314 :     if ( !pCurrentDeep && pDocShell )
    1499             :     {
    1500        5862 :         ScDocument* pDoc = pDocShell->GetDocument();
    1501        5862 :         pCurrentDeep = pDoc->CreateSelectionPattern( *GetMarkData(), true );
    1502             :     }
    1503        6314 :     return pCurrentDeep;
    1504             : }
    1505             : 
    1506        9317 : SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
    1507             : {
    1508        9317 :     if(!pCurrentDataSet)
    1509             :     {
    1510        5327 :         const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
    1511        5327 :         if ( pPattern )
    1512             :         {
    1513             :             //  Dontcare durch Default ersetzen, damit man immer eine Reflection hat
    1514        5327 :             pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
    1515        5327 :             pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
    1516        5327 :             pCurrentDataSet->ClearInvalidItems();
    1517             :         }
    1518             :     }
    1519        9317 :     return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
    1520             : }
    1521             : 
    1522        8056 : const ScMarkData* ScCellRangesBase::GetMarkData()
    1523             : {
    1524        8056 :     if (!pMarkData)
    1525             :     {
    1526        5835 :         pMarkData = new ScMarkData();
    1527        5835 :         pMarkData->MarkFromRangeList( aRanges, false );
    1528             :     }
    1529        8056 :     return pMarkData;
    1530             : }
    1531             : 
    1532      168694 : void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1533             : {
    1534      168694 :     if ( rHint.ISA( ScUpdateRefHint ) )
    1535             :     {
    1536        3020 :         const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
    1537             : 
    1538        3020 :         ScDocument* pDoc = pDocShell->GetDocument();
    1539        3020 :         ScRangeList* pUndoRanges = NULL;
    1540        3020 :         if ( pDoc->HasUnoRefUndo() )
    1541        1765 :             pUndoRanges = new ScRangeList( aRanges );
    1542             : 
    1543        6040 :         if ( aRanges.UpdateReference( rRef.GetMode(), pDoc, rRef.GetRange(),
    1544        6040 :                                     rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
    1545             :         {
    1546             :             // i#90076; the object "this" was destroyed after calling ScTableSheetObj::getImplementation
    1547             :             // this hack make sure that the object lives a bit longer
    1548        2860 :             uno::Reference<uno::XInterface> xInterface((cppu::OWeakObject*)this, uno::UNO_QUERY);
    1549        8615 :             if (  rRef.GetMode() == URM_INSDEL
    1550        2859 :                && aRanges.size() == 1
    1551       14230 :                && ScTableSheetObj::getImplementation( xInterface )
    1552             :                )
    1553             :             {
    1554             :                 // #101755#; the range size of a sheet does not change
    1555         313 :                 ScRange* pR = aRanges.front();
    1556         313 :                 if (pR)
    1557             :                 {
    1558         313 :                     pR->aStart.SetCol(0);
    1559         313 :                     pR->aStart.SetRow(0);
    1560         313 :                     pR->aEnd.SetCol(MAXCOL);
    1561         313 :                     pR->aEnd.SetRow(MAXROW);
    1562             :                 }
    1563             :             }
    1564        2860 :             RefChanged();
    1565             : 
    1566             :             // any change of the range address is broadcast to value (modify) listeners
    1567        2860 :             if ( !aValueListeners.empty() )
    1568           0 :                 bGotDataChangedHint = true;
    1569             : 
    1570        2860 :             if ( pUndoRanges )
    1571        1638 :                 pDoc->AddUnoRefChange( nObjectId, *pUndoRanges );
    1572             :         }
    1573             : 
    1574        3020 :         delete pUndoRanges;
    1575             :     }
    1576      165674 :     else if ( rHint.ISA( SfxSimpleHint ) )
    1577             :     {
    1578      163981 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
    1579      163981 :         if ( nId == SFX_HINT_DYING )
    1580             :         {
    1581        3739 :             ForgetCurrentAttrs();
    1582        3739 :             pDocShell = NULL;           // invalid
    1583             : 
    1584        3739 :             if ( !aValueListeners.empty() )
    1585             :             {
    1586             :                 //  dispose listeners
    1587             : 
    1588           4 :                 lang::EventObject aEvent;
    1589           4 :                 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
    1590           8 :                 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
    1591           4 :                     aValueListeners[n]->disposing( aEvent );
    1592             : 
    1593           4 :                 aValueListeners.clear();
    1594             : 
    1595             :                 //  The listeners can't have the last ref to this, as it's still held
    1596             :                 //  by the DocShell.
    1597             :             }
    1598             :         }
    1599      160242 :         else if ( nId == SFX_HINT_DATACHANGED )
    1600             :         {
    1601             :             // document content changed -> forget cached attributes
    1602      159861 :             ForgetCurrentAttrs();
    1603             : 
    1604      159861 :             if ( bGotDataChangedHint && pDocShell )
    1605             :             {
    1606             :                 //  This object was notified of content changes, so one call
    1607             :                 //  for each listener is generated now.
    1608             :                 //  The calls can't be executed directly because the document's
    1609             :                 //  UNO broadcaster list must not be modified.
    1610             :                 //  Instead, add to the document's list of listener calls,
    1611             :                 //  which will be executed directly after the broadcast of
    1612             :                 //  SFX_HINT_DATACHANGED.
    1613             : 
    1614           0 :                 lang::EventObject aEvent;
    1615           0 :                 aEvent.Source.set((cppu::OWeakObject*)this);
    1616             : 
    1617             :                 // the EventObject holds a Ref to this object until after the listener calls
    1618             : 
    1619           0 :                 ScDocument* pDoc = pDocShell->GetDocument();
    1620           0 :                 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
    1621           0 :                     pDoc->AddUnoListenerCall( aValueListeners[n], aEvent );
    1622             : 
    1623           0 :                 bGotDataChangedHint = false;
    1624             :             }
    1625             :         }
    1626         381 :         else if ( nId == SC_HINT_CALCALL )
    1627             :         {
    1628             :             // broadcast from DoHardRecalc - set bGotDataChangedHint
    1629             :             // (SFX_HINT_DATACHANGED follows separately)
    1630             : 
    1631         381 :             if ( !aValueListeners.empty() )
    1632           0 :                 bGotDataChangedHint = true;
    1633             :         }
    1634             :     }
    1635        1693 :     else if ( rHint.ISA( ScUnoRefUndoHint ) )
    1636             :     {
    1637           0 :         const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
    1638           0 :         if ( rUndoHint.GetObjectId() == nObjectId )
    1639             :         {
    1640             :             // restore ranges from hint
    1641             : 
    1642           0 :             aRanges = rUndoHint.GetRanges();
    1643             : 
    1644           0 :             RefChanged();
    1645           0 :             if ( !aValueListeners.empty() )
    1646           0 :                 bGotDataChangedHint = true;     // need to broadcast the undo, too
    1647             :         }
    1648             :     }
    1649      168694 : }
    1650             : 
    1651        5508 : void ScCellRangesBase::RefChanged()
    1652             : {
    1653             :     //! adjust XChartDataChangeEventListener
    1654             : 
    1655        5508 :     if ( pValueListener && !aValueListeners.empty() )
    1656             :     {
    1657           0 :         pValueListener->EndListeningAll();
    1658             : 
    1659           0 :         ScDocument* pDoc = pDocShell->GetDocument();
    1660           0 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    1661           0 :             pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
    1662             :     }
    1663             : 
    1664        5508 :     ForgetCurrentAttrs();
    1665        5508 :     ForgetMarkData();
    1666        5508 : }
    1667             : 
    1668           0 : ScDocument* ScCellRangesBase::GetDocument() const
    1669             : {
    1670           0 :     if (pDocShell)
    1671           0 :         return pDocShell->GetDocument();
    1672             :     else
    1673           0 :         return NULL;
    1674             : }
    1675             : 
    1676           0 : void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
    1677             : {
    1678           0 :     if ( !pDocShell && pDocSh )
    1679             :     {
    1680           0 :         pDocShell = pDocSh;
    1681             : 
    1682           0 :         ScRange aCellRange(rR);
    1683           0 :         aCellRange.Justify();
    1684           0 :         aRanges.RemoveAll();
    1685           0 :         aRanges.Append( aCellRange );
    1686             : 
    1687           0 :         pDocShell->GetDocument()->AddUnoObject(*this);
    1688             : 
    1689           0 :         RefChanged();   // Range im Range-Objekt anpassen
    1690             :     }
    1691           0 : }
    1692             : 
    1693        2313 : void ScCellRangesBase::AddRange(const ScRange& rRange, const bool bMergeRanges)
    1694             : {
    1695        2313 :     if (bMergeRanges)
    1696           0 :         aRanges.Join(rRange);
    1697             :     else
    1698        2313 :         aRanges.Append(rRange);
    1699        2313 :     RefChanged();
    1700        2313 : }
    1701             : 
    1702         289 : void ScCellRangesBase::SetNewRange(const ScRange& rNew)
    1703             : {
    1704         289 :     ScRange aCellRange(rNew);
    1705         289 :     aCellRange.Justify();
    1706             : 
    1707         289 :     aRanges.RemoveAll();
    1708         289 :     aRanges.Append( aCellRange );
    1709         289 :     RefChanged();
    1710         289 : }
    1711             : 
    1712          46 : void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
    1713             : {
    1714          46 :     aRanges = rNew;
    1715          46 :     RefChanged();
    1716          46 : }
    1717             : 
    1718         292 : void ScCellRangesBase::SetCursorOnly( bool bSet )
    1719             : {
    1720             :     //  set for a selection object that is created from the cursor position
    1721             :     //  without anything selected (may contain several sheets)
    1722             : 
    1723         292 :     bCursorOnly = bSet;
    1724         292 : }
    1725             : 
    1726       36096 : uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
    1727             :                                                 throw(uno::RuntimeException, std::exception)
    1728             : {
    1729       36096 :     SC_QUERYINTERFACE( beans::XPropertySet )
    1730       24927 :     SC_QUERYINTERFACE( beans::XMultiPropertySet )
    1731       24305 :     SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
    1732       23461 :     SC_QUERYINTERFACE( beans::XPropertyState )
    1733       23385 :     SC_QUERYINTERFACE( sheet::XSheetOperation )
    1734       23312 :     SC_QUERYINTERFACE( chart::XChartDataArray )
    1735       23309 :     SC_QUERYINTERFACE( chart::XChartData )
    1736       23308 :     SC_QUERYINTERFACE( util::XIndent )
    1737       23305 :     SC_QUERYINTERFACE( sheet::XCellRangesQuery )
    1738       23273 :     SC_QUERYINTERFACE( sheet::XFormulaQuery )
    1739       23270 :     SC_QUERYINTERFACE( util::XReplaceable )
    1740       23246 :     SC_QUERYINTERFACE( util::XSearchable )
    1741       23238 :     SC_QUERYINTERFACE( util::XModifyBroadcaster )
    1742       23232 :     SC_QUERYINTERFACE( lang::XServiceInfo )
    1743       23200 :     SC_QUERYINTERFACE( lang::XUnoTunnel )
    1744        8218 :     SC_QUERYINTERFACE( lang::XTypeProvider )
    1745             : 
    1746        8210 :     return OWeakObject::queryInterface( rType );
    1747             : }
    1748             : 
    1749      213586 : void SAL_CALL ScCellRangesBase::acquire() throw()
    1750             : {
    1751      213586 :     OWeakObject::acquire();
    1752      213586 : }
    1753             : 
    1754      213445 : void SAL_CALL ScCellRangesBase::release() throw()
    1755             : {
    1756      213445 :     OWeakObject::release();
    1757      213445 : }
    1758             : 
    1759           2 : uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException, std::exception)
    1760             : {
    1761           2 :     static uno::Sequence<uno::Type> aTypes;
    1762           2 :     if ( aTypes.getLength() == 0 )
    1763             :     {
    1764           2 :         aTypes.realloc(13);
    1765           2 :         uno::Type* pPtr = aTypes.getArray();
    1766           2 :         pPtr[0] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
    1767           2 :         pPtr[1] = getCppuType((const uno::Reference<beans::XMultiPropertySet>*)0);
    1768           2 :         pPtr[2] = getCppuType((const uno::Reference<beans::XPropertyState>*)0);
    1769           2 :         pPtr[3] = getCppuType((const uno::Reference<sheet::XSheetOperation>*)0);
    1770           2 :         pPtr[4] = getCppuType((const uno::Reference<chart::XChartDataArray>*)0);
    1771           2 :         pPtr[5] = getCppuType((const uno::Reference<util::XIndent>*)0);
    1772           2 :         pPtr[6] = getCppuType((const uno::Reference<sheet::XCellRangesQuery>*)0);
    1773           2 :         pPtr[7] = getCppuType((const uno::Reference<sheet::XFormulaQuery>*)0);
    1774           2 :         pPtr[8] = getCppuType((const uno::Reference<util::XReplaceable>*)0);
    1775           2 :         pPtr[9] = getCppuType((const uno::Reference<util::XModifyBroadcaster>*)0);
    1776           2 :         pPtr[10]= getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
    1777           2 :         pPtr[11]= getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
    1778           2 :         pPtr[12]= getCppuType((const uno::Reference<lang::XTypeProvider>*)0);
    1779             :     }
    1780           2 :     return aTypes;
    1781             : }
    1782             : 
    1783           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
    1784             :                                                     throw(uno::RuntimeException, std::exception)
    1785             : {
    1786           0 :     return css::uno::Sequence<sal_Int8>();
    1787             : }
    1788             : 
    1789           8 : void ScCellRangesBase::PaintRanges_Impl( sal_uInt16 nPart )
    1790             : {
    1791          31 :     for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
    1792          23 :         pDocShell->PostPaint( *aRanges[ i ], nPart );
    1793           8 : }
    1794             : 
    1795             : // XSheetOperation
    1796             : 
    1797           4 : double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
    1798             :     throw(uno::Exception, uno::RuntimeException, std::exception)
    1799             : {
    1800           4 :     SolarMutexGuard aGuard;
    1801           8 :     ScMarkData aMark(*GetMarkData());
    1802           4 :     aMark.MarkToSimple();
    1803           4 :     if (!aMark.IsMarked())
    1804           2 :         aMark.SetMarkNegative(true);    // um Dummy Position angeben zu koennen
    1805             : 
    1806           4 :     ScAddress aDummy;                   // wenn nicht Marked, ignoriert wegen Negative
    1807             :     double fVal;
    1808           4 :     ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(nFunction);
    1809           4 :     ScDocument* pDoc = pDocShell->GetDocument();
    1810           4 :     if ( !pDoc->GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
    1811             :     {
    1812           0 :         throw uno::RuntimeException();      //! own exception?
    1813             :     }
    1814             : 
    1815           8 :     return fVal;
    1816             : }
    1817             : 
    1818          73 : void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException, std::exception)
    1819             : {
    1820          73 :     SolarMutexGuard aGuard;
    1821          73 :     if ( !aRanges.empty() )
    1822             :     {
    1823             :         // only for clearContents: EDITATTR is only used if no contents are deleted
    1824          73 :         sal_uInt16 nDelFlags = static_cast< sal_uInt16 >( nContentFlags & IDF_ALL );
    1825          73 :         if ( ( nContentFlags & IDF_EDITATTR ) && ( nContentFlags & IDF_CONTENTS ) == 0 )
    1826           2 :             nDelFlags |= IDF_EDITATTR;
    1827             : 
    1828          73 :         pDocShell->GetDocFunc().DeleteContents( *GetMarkData(), nDelFlags, true, true );
    1829          73 :     }
    1830             :     // sonst ist nichts zu tun
    1831          73 : }
    1832             : 
    1833             : // XPropertyState
    1834             : 
    1835        1274 : const SfxItemPropertyMap& ScCellRangesBase::GetItemPropertyMap()
    1836             : {
    1837        1274 :     return pPropSet->getPropertyMap();
    1838             : }
    1839             : 
    1840        6791 : static void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
    1841             :                                                 sal_uInt16& rItemWhich )
    1842             : {
    1843             :     //  Which-ID des betroffenen Items, auch wenn das Item die Property
    1844             :     //  nicht alleine behandeln kann
    1845        6791 :     if ( pEntry )
    1846             :     {
    1847        6791 :         if ( IsScItemWid( pEntry->nWID ) )
    1848        6034 :             rItemWhich = pEntry->nWID;
    1849             :         else
    1850         757 :             switch ( pEntry->nWID )
    1851             :             {
    1852             :                 case SC_WID_UNO_TBLBORD:
    1853             :                 case SC_WID_UNO_TBLBORD2:
    1854          30 :                     rItemWhich = ATTR_BORDER;
    1855          30 :                     break;
    1856             :                 case SC_WID_UNO_CONDFMT:
    1857             :                 case SC_WID_UNO_CONDLOC:
    1858             :                 case SC_WID_UNO_CONDXML:
    1859         107 :                     rItemWhich = ATTR_CONDITIONAL;
    1860         107 :                     break;
    1861             :                 case SC_WID_UNO_VALIDAT:
    1862             :                 case SC_WID_UNO_VALILOC:
    1863             :                 case SC_WID_UNO_VALIXML:
    1864         107 :                     rItemWhich = ATTR_VALIDDATA;
    1865         107 :                     break;
    1866             :             }
    1867             :     }
    1868             : 
    1869        6791 : }
    1870             : 
    1871        6791 : beans::PropertyState ScCellRangesBase::GetOnePropertyState( sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
    1872             : {
    1873        6791 :     beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
    1874        6791 :     if ( nItemWhich )                   // item wid (from map or special case)
    1875             :     {
    1876             :         //  For items that contain several properties (like background),
    1877             :         //  "ambiguous" is returned too often here
    1878             : 
    1879             :         //  for PropertyState, don't look at styles
    1880        6278 :         const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
    1881        6278 :         if ( pPattern )
    1882             :         {
    1883        6278 :             SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, false );
    1884             : 
    1885        6278 :             if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SFX_ITEM_DEFAULT )
    1886          53 :                 eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, false );
    1887             : 
    1888        6278 :             if ( eState == SFX_ITEM_SET )
    1889        1025 :                 eRet = beans::PropertyState_DIRECT_VALUE;
    1890        5253 :             else if ( eState == SFX_ITEM_DEFAULT )
    1891        5251 :                 eRet = beans::PropertyState_DEFAULT_VALUE;
    1892           2 :             else if ( eState == SFX_ITEM_DONTCARE )
    1893           2 :                 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
    1894             :             else
    1895             :             {
    1896             :                 OSL_FAIL("unbekannter ItemState");
    1897             :             }
    1898             :         }
    1899             :     }
    1900         513 :     else if ( pEntry )
    1901             :     {
    1902         513 :         if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
    1903          45 :             eRet = beans::PropertyState_DIRECT_VALUE;
    1904         468 :         else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    1905             :         {
    1906             :             //  a style is always set, there's no default state
    1907          77 :             const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
    1908          77 :             if (pStyle)
    1909          77 :                 eRet = beans::PropertyState_DIRECT_VALUE;
    1910             :             else
    1911           0 :                 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
    1912             :         }
    1913         391 :         else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
    1914          15 :             eRet = beans::PropertyState_DEFAULT_VALUE;      // numbering rules are always default
    1915             :     }
    1916        6791 :     return eRet;
    1917             : }
    1918             : 
    1919         344 : beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const OUString& aPropertyName )
    1920             :                                 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1921             : {
    1922         344 :     SolarMutexGuard aGuard;
    1923         344 :     if ( aRanges.empty() )
    1924           0 :         throw uno::RuntimeException();
    1925             : 
    1926         344 :     const SfxItemPropertyMap& rMap = GetItemPropertyMap();     // from derived class
    1927         344 :     sal_uInt16 nItemWhich = 0;
    1928         344 :     const SfxItemPropertySimpleEntry* pEntry  = rMap.getByName( aPropertyName );
    1929         344 :     lcl_GetPropertyWhich( pEntry, nItemWhich );
    1930         344 :     return GetOnePropertyState( nItemWhich, pEntry );
    1931             : }
    1932             : 
    1933           0 : uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
    1934             :                                 const uno::Sequence<OUString>& aPropertyNames )
    1935             :                             throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1936             : {
    1937           0 :     SolarMutexGuard aGuard;
    1938             : 
    1939           0 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    1940             : 
    1941           0 :     uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
    1942           0 :     beans::PropertyState* pStates = aRet.getArray();
    1943           0 :     for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
    1944             :     {
    1945           0 :         sal_uInt16 nItemWhich = 0;
    1946           0 :         const SfxItemPropertySimpleEntry* pEntry  = rPropertyMap.getByName( aPropertyNames[i] );
    1947           0 :         lcl_GetPropertyWhich( pEntry, nItemWhich );
    1948           0 :         pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
    1949             :     }
    1950           0 :     return aRet;
    1951             : }
    1952             : 
    1953           0 : void SAL_CALL ScCellRangesBase::setPropertyToDefault( const OUString& aPropertyName )
    1954             :                             throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1955             : {
    1956           0 :     SolarMutexGuard aGuard;
    1957           0 :     if ( pDocShell )
    1958             :     {
    1959           0 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    1960           0 :         sal_uInt16 nItemWhich = 0;
    1961           0 :         const SfxItemPropertySimpleEntry* pEntry  = rPropertyMap.getByName( aPropertyName );
    1962           0 :         lcl_GetPropertyWhich( pEntry, nItemWhich );
    1963           0 :         if ( nItemWhich )               // item wid (from map or special case)
    1964             :         {
    1965           0 :             if ( !aRanges.empty() )     // leer = nichts zu tun
    1966             :             {
    1967             :                 //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
    1968             :                 //! wird hier zuviel zurueckgesetzt
    1969             :                 //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
    1970             : 
    1971             :                 sal_uInt16 aWIDs[3];
    1972           0 :                 aWIDs[0] = nItemWhich;
    1973           0 :                 if ( nItemWhich == ATTR_VALUE_FORMAT )
    1974             :                 {
    1975           0 :                     aWIDs[1] = ATTR_LANGUAGE_FORMAT; // language for number formats
    1976           0 :                     aWIDs[2] = 0;
    1977             :                 }
    1978             :                 else
    1979           0 :                     aWIDs[1] = 0;
    1980           0 :                 pDocShell->GetDocFunc().ClearItems( *GetMarkData(), aWIDs, true );
    1981             :             }
    1982             :         }
    1983           0 :         else if ( pEntry )
    1984             :         {
    1985           0 :             if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
    1986           0 :                 bChartColAsHdr = false;
    1987           0 :             else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
    1988           0 :                 bChartRowAsHdr = false;
    1989           0 :             else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    1990             :             {
    1991           0 :                 OUString aStyleName( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ) );
    1992           0 :                 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aStyleName, true, true );
    1993             :             }
    1994             :         }
    1995           0 :     }
    1996           0 : }
    1997             : 
    1998           0 : uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropertyName )
    1999             :                                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
    2000             :                                         uno::RuntimeException, std::exception)
    2001             : {
    2002             :     //! mit getPropertyValue zusammenfassen
    2003             : 
    2004           0 :     SolarMutexGuard aGuard;
    2005           0 :     uno::Any aAny;
    2006             : 
    2007           0 :     if ( pDocShell )
    2008             :     {
    2009           0 :         ScDocument* pDoc = pDocShell->GetDocument();
    2010           0 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2011           0 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
    2012           0 :         if ( pEntry )
    2013             :         {
    2014           0 :             if ( IsScItemWid( pEntry->nWID ) )
    2015             :             {
    2016           0 :                 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
    2017           0 :                 if ( pPattern )
    2018             :                 {
    2019           0 :                     const SfxItemSet& rSet = pPattern->GetItemSet();
    2020             : 
    2021           0 :                     switch ( pEntry->nWID )     // fuer Item-Spezial-Behandlungen
    2022             :                     {
    2023             :                         case ATTR_VALUE_FORMAT:
    2024             :                             //  default has no language set
    2025           0 :                             aAny <<= (sal_Int32)( ((const SfxUInt32Item&)rSet.Get(pEntry->nWID)).GetValue() );
    2026           0 :                             break;
    2027             :                         case ATTR_INDENT:
    2028           0 :                             aAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
    2029           0 :                                             rSet.Get(pEntry->nWID)).GetValue()) );
    2030           0 :                             break;
    2031             :                         default:
    2032           0 :                             pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
    2033             :                     }
    2034             :                 }
    2035             :             }
    2036             :             else
    2037           0 :                 switch ( pEntry->nWID )
    2038             :                 {
    2039             :                     case SC_WID_UNO_CHCOLHDR:
    2040             :                     case SC_WID_UNO_CHROWHDR:
    2041           0 :                         ScUnoHelpFunctions::SetBoolInAny( aAny, false );
    2042           0 :                         break;
    2043             :                     case SC_WID_UNO_CELLSTYL:
    2044           0 :                         aAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
    2045           0 :                                     ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
    2046           0 :                         break;
    2047             :                     case SC_WID_UNO_TBLBORD:
    2048             :                     case SC_WID_UNO_TBLBORD2:
    2049             :                         {
    2050           0 :                             const ScPatternAttr* pPattern = pDoc->GetDefPattern();
    2051           0 :                             if ( pPattern )
    2052             :                             {
    2053           0 :                                 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
    2054             :                                     ScHelperFunctions::AssignTableBorder2ToAny( aAny,
    2055           0 :                                             (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
    2056           0 :                                             (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
    2057             :                                 else
    2058             :                                     ScHelperFunctions::AssignTableBorderToAny( aAny,
    2059           0 :                                             (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
    2060           0 :                                             (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
    2061             :                             }
    2062             :                         }
    2063           0 :                         break;
    2064             :                     case SC_WID_UNO_CONDFMT:
    2065             :                     case SC_WID_UNO_CONDLOC:
    2066             :                     case SC_WID_UNO_CONDXML:
    2067             :                         {
    2068           0 :                             sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
    2069           0 :                             sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
    2070             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2071             :                                     pDoc->GetStorageGrammar() :
    2072           0 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2073             : 
    2074           0 :                             aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
    2075           0 :                                     new ScTableConditionalFormat( pDoc, 0, aRanges[0]->aStart.Tab(), eGrammar ));
    2076             :                         }
    2077           0 :                         break;
    2078             :                     case SC_WID_UNO_VALIDAT:
    2079             :                     case SC_WID_UNO_VALILOC:
    2080             :                     case SC_WID_UNO_VALIXML:
    2081             :                         {
    2082           0 :                             sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
    2083           0 :                             sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
    2084             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2085             :                                     pDoc->GetStorageGrammar() :
    2086           0 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2087             : 
    2088           0 :                             aAny <<= uno::Reference<beans::XPropertySet>(
    2089           0 :                                     new ScTableValidationObj( pDoc, 0, eGrammar ));
    2090             :                         }
    2091           0 :                         break;
    2092             :                     case SC_WID_UNO_NUMRULES:
    2093             :                         {
    2094           0 :                             aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
    2095             :                         }
    2096           0 :                         break;
    2097             :                 }
    2098             :         }
    2099             :     }
    2100             : 
    2101           0 :     return aAny;
    2102             : }
    2103             : 
    2104             : // XPropertySet
    2105             : 
    2106         205 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
    2107             :                                                         throw(uno::RuntimeException, std::exception)
    2108             : {
    2109         205 :     SolarMutexGuard aGuard;
    2110             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    2111         205 :         new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
    2112         205 :     return aRef;
    2113             : }
    2114             : 
    2115        4180 : static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
    2116             :                             ScPatternAttr& rPattern, ScDocument* pDoc,
    2117             :                             sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId )
    2118             : {
    2119        4180 :     rFirstItemId = rEntry.nWID;
    2120        4180 :     rSecondItemId = 0;
    2121             : 
    2122        4180 :     SfxItemSet& rSet = rPattern.GetItemSet();
    2123        4180 :     switch ( rEntry.nWID )
    2124             :     {
    2125             :         case ATTR_VALUE_FORMAT:
    2126             :             {
    2127             :                 // language for number formats
    2128         144 :                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
    2129         144 :                 sal_uLong nOldFormat = ((const SfxUInt32Item&)rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
    2130         144 :                 LanguageType eOldLang = ((const SvxLanguageItem&)rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
    2131         144 :                 nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
    2132             : 
    2133         144 :                 sal_Int32 nIntVal = 0;
    2134         144 :                 if ( rValue >>= nIntVal )
    2135             :                 {
    2136         144 :                     sal_uLong nNewFormat = (sal_uLong)nIntVal;
    2137         144 :                     rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
    2138             : 
    2139         144 :                     const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
    2140             :                     LanguageType eNewLang =
    2141         144 :                         pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
    2142         144 :                     if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
    2143             :                     {
    2144          14 :                         rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
    2145             : 
    2146             :                         // if only language is changed,
    2147             :                         // don't touch number format attribute
    2148          14 :                         sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
    2149          14 :                         if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
    2150             :                              nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
    2151             :                         {
    2152           0 :                             rFirstItemId = 0;       // don't use ATTR_VALUE_FORMAT value
    2153             :                         }
    2154             : 
    2155          14 :                         rSecondItemId = ATTR_LANGUAGE_FORMAT;
    2156             :                     }
    2157             :                 }
    2158             :                 else
    2159           0 :                     throw lang::IllegalArgumentException();
    2160             :             }
    2161         144 :             break;
    2162             :         case ATTR_INDENT:
    2163             :             {
    2164          52 :                 sal_Int16 nIntVal = 0;
    2165          52 :                 if ( rValue >>= nIntVal )
    2166          52 :                     rSet.Put( SfxUInt16Item( rEntry.nWID, (sal_uInt16)HMMToTwips(nIntVal) ) );
    2167             :                 else
    2168           0 :                     throw lang::IllegalArgumentException();
    2169             :             }
    2170          52 :             break;
    2171             :         case ATTR_ROTATE_VALUE:
    2172             :             {
    2173          26 :                 sal_Int32 nRotVal = 0;
    2174          26 :                 if ( rValue >>= nRotVal )
    2175             :                 {
    2176             :                     //  stored value is always between 0 and 360 deg.
    2177          26 :                     nRotVal %= 36000;
    2178          26 :                     if ( nRotVal < 0 )
    2179           0 :                         nRotVal += 36000;
    2180             : 
    2181          26 :                     rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
    2182             :                 }
    2183             :                 else
    2184           0 :                     throw lang::IllegalArgumentException();
    2185             :             }
    2186          26 :             break;
    2187             :         case ATTR_STACKED:
    2188             :             {
    2189             :                 table::CellOrientation eOrient;
    2190          29 :                 if( rValue >>= eOrient )
    2191             :                 {
    2192          29 :                     switch( eOrient )
    2193             :                     {
    2194             :                         case table::CellOrientation_STANDARD:
    2195          22 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
    2196          22 :                         break;
    2197             :                         case table::CellOrientation_TOPBOTTOM:
    2198           5 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
    2199           5 :                             rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
    2200           5 :                             rSecondItemId = ATTR_ROTATE_VALUE;
    2201           5 :                         break;
    2202             :                         case table::CellOrientation_BOTTOMTOP:
    2203           1 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
    2204           1 :                             rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
    2205           1 :                             rSecondItemId = ATTR_ROTATE_VALUE;
    2206           1 :                         break;
    2207             :                         case table::CellOrientation_STACKED:
    2208           1 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, true ) );
    2209           1 :                         break;
    2210             :                         default:
    2211             :                         {
    2212             :                             // added to avoid warnings
    2213             :                         }
    2214             :                     }
    2215             :                 }
    2216             :             }
    2217          29 :             break;
    2218             :         default:
    2219             :             {
    2220        3929 :                 lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
    2221             :             }
    2222             :     }
    2223        4177 : }
    2224             : 
    2225        1003 : void SAL_CALL ScCellRangesBase::setPropertyValue(
    2226             :                         const OUString& aPropertyName, const uno::Any& aValue )
    2227             :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
    2228             :                         lang::IllegalArgumentException, lang::WrappedTargetException,
    2229             :                         uno::RuntimeException, std::exception)
    2230             : {
    2231        1003 :     SolarMutexGuard aGuard;
    2232             : 
    2233        1003 :     if ( !pDocShell || aRanges.empty() )
    2234           0 :         throw uno::RuntimeException();
    2235             : 
    2236        1003 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2237        1003 :     const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
    2238        1003 :     if ( !pEntry )
    2239           0 :         throw beans::UnknownPropertyException();
    2240             : 
    2241        1004 :     SetOnePropertyValue( pEntry, aValue );
    2242        1002 : }
    2243             : 
    2244        1256 : void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    2245             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    2246             : {
    2247        1256 :     if ( pEntry )
    2248             :     {
    2249        1256 :         if ( IsScItemWid( pEntry->nWID ) )
    2250             :         {
    2251         343 :             if ( !aRanges.empty() )     // leer = nichts zu tun
    2252             :             {
    2253         343 :                 ScDocument* pDoc = pDocShell->GetDocument();
    2254             : 
    2255             :                 //  Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
    2256             :                 //  muss vorher das alte Item aus dem Dokument geholt werden
    2257             :                 //! Das kann hier aber nicht erkannt werden
    2258             :                 //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
    2259             :                 //! Item direkt von einzelner Position im Bereich holen?
    2260             :                 //  ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
    2261             : 
    2262         343 :                 ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
    2263         343 :                 SfxItemSet& rSet = aPattern.GetItemSet();
    2264         343 :                 rSet.ClearInvalidItems();
    2265             : 
    2266             :                 sal_uInt16 nFirstItem, nSecondItem;
    2267         343 :                 lcl_SetCellProperty( *pEntry, aValue, aPattern, pDoc, nFirstItem, nSecondItem );
    2268             : 
    2269       19494 :                 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
    2270       19152 :                     if ( nWhich != nFirstItem && nWhich != nSecondItem )
    2271       18799 :                         rSet.ClearItem(nWhich);
    2272             : 
    2273         343 :                 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
    2274             :             }
    2275             :         }
    2276             :         else        // implemented here
    2277         913 :             switch ( pEntry->nWID )
    2278             :             {
    2279             :                 case EE_CHAR_ESCAPEMENT:    // Specifically for xlsx import
    2280             :                 {
    2281           1 :                     sal_Int32 nValue = 0;
    2282           1 :                     aValue >>= nValue;
    2283           1 :                     if (nValue)
    2284             :                     {
    2285           0 :                         for (size_t i = 0, n = aRanges.size(); i < n; ++i)
    2286             :                         {
    2287           0 :                             ScRange aRange = *aRanges[i];
    2288             : 
    2289             :                             /* TODO: Iterate through the range */
    2290           0 :                             ScAddress aAddr = aRange.aStart;
    2291           0 :                             ScDocument *pDoc = pDocShell->GetDocument();
    2292           0 :                             ScRefCellValue aCell;
    2293           0 :                             aCell.assign(*pDoc, aAddr);
    2294             : 
    2295           0 :                             OUString aStr = aCell.getString(pDoc);
    2296           0 :                             EditEngine aEngine( pDoc->GetEnginePool() );
    2297           0 :                             aEngine.SetEditTextObjectPool(pDoc->GetEditPool());
    2298             : 
    2299             :                             /* EE_CHAR_ESCAPEMENT seems to be set on the cell _only_ when
    2300             :                              * there are no other attribs for the cell.
    2301             :                              * So, it is safe to overwrite the complete attribute set.
    2302             :                              * If there is a need - getting CellType and processing
    2303             :                              * the attributes could be considered.
    2304             :                              */
    2305           0 :                             SfxItemSet aAttr = aEngine.GetEmptyItemSet();
    2306           0 :                             aEngine.SetText(aStr);
    2307           0 :                             if( nValue < 0 )    // Subscript
    2308           0 :                                 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT ) );
    2309             :                             else                // Superscript
    2310           0 :                                 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT ) );
    2311           0 :                             aEngine.QuickSetAttribs(aAttr, ESelection(0, 0, 0, aStr.getLength()));
    2312             : 
    2313             :                             // The cell will own the text object instance.
    2314           0 :                             pDoc->SetEditText(aRanges[0]->aStart, aEngine.CreateTextObject());
    2315           0 :                         }
    2316             :                     }
    2317             :                 }
    2318           1 :                 break;
    2319             :                 case SC_WID_UNO_CHCOLHDR:
    2320             :                     // chart header flags are set for this object, not stored with document
    2321           6 :                     bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    2322           6 :                     break;
    2323             :                 case SC_WID_UNO_CHROWHDR:
    2324           6 :                     bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    2325           6 :                     break;
    2326             :                 case SC_WID_UNO_CELLSTYL:
    2327             :                     {
    2328         852 :                         OUString aStrVal;
    2329         852 :                         aValue >>= aStrVal;
    2330             :                         OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName(
    2331        1704 :                                                             aStrVal, SFX_STYLE_FAMILY_PARA ));
    2332        1704 :                         pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aString, true, true );
    2333             :                     }
    2334         852 :                     break;
    2335             :                 case SC_WID_UNO_TBLBORD:
    2336             :                     {
    2337           4 :                         table::TableBorder aBorder;
    2338           4 :                         if ( !aRanges.empty() && ( aValue >>= aBorder ) )   // empty = nothing to do
    2339             :                         {
    2340           4 :                             SvxBoxItem aOuter(ATTR_BORDER);
    2341           8 :                             SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
    2342           4 :                             ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
    2343             : 
    2344           8 :                             ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner );   //! docfunc
    2345             :                         }
    2346             :                     }
    2347           4 :                     break;
    2348             :                 case SC_WID_UNO_TBLBORD2:
    2349             :                     {
    2350           2 :                         table::TableBorder2 aBorder2;
    2351           2 :                         if ( !aRanges.empty() && ( aValue >>= aBorder2 ) )   // empty = nothing to do
    2352             :                         {
    2353           0 :                             SvxBoxItem aOuter(ATTR_BORDER);
    2354           0 :                             SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
    2355           0 :                             ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 );
    2356             : 
    2357           0 :                             ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner );   //! docfunc
    2358             :                         }
    2359             :                     }
    2360           2 :                     break;
    2361             :                 case SC_WID_UNO_CONDFMT:
    2362             :                 case SC_WID_UNO_CONDLOC:
    2363             :                 case SC_WID_UNO_CONDXML:
    2364             :                     {
    2365          14 :                         uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
    2366          14 :                         if ( !aRanges.empty() && xInterface.is() )  // leer = nichts zu tun
    2367             :                         {
    2368             :                             ScTableConditionalFormat* pFormat =
    2369           8 :                                     ScTableConditionalFormat::getImplementation( xInterface );
    2370           8 :                             if (pFormat)
    2371             :                             {
    2372           8 :                                 ScDocument* pDoc = pDocShell->GetDocument();
    2373           8 :                                 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
    2374           8 :                                 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
    2375             :                                 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2376             :                                        formula::FormulaGrammar::GRAM_UNSPECIFIED :
    2377           8 :                                        formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2378             : 
    2379           8 :                                 ScConditionalFormat* pNew = new ScConditionalFormat( 0, pDoc );    // Index wird beim Einfuegen gesetzt
    2380           8 :                                 pFormat->FillFormat( *pNew, pDoc, eGrammar );
    2381           8 :                                 pNew->AddRange( aRanges );
    2382           8 :                                 SCTAB nTab = aRanges.front()->aStart.Tab();
    2383           8 :                                 pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
    2384             :                             }
    2385          14 :                         }
    2386             :                     }
    2387          14 :                     break;
    2388             :                 case SC_WID_UNO_VALIDAT:
    2389             :                 case SC_WID_UNO_VALILOC:
    2390             :                 case SC_WID_UNO_VALIXML:
    2391             :                     {
    2392          22 :                         uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
    2393          22 :                         if ( !aRanges.empty() && xInterface.is() )  // leer = nichts zu tun
    2394             :                         {
    2395             :                             ScTableValidationObj* pValidObj =
    2396          16 :                                     ScTableValidationObj::getImplementation( xInterface );
    2397          16 :                             if (pValidObj)
    2398             :                             {
    2399          16 :                                 ScDocument* pDoc = pDocShell->GetDocument();
    2400          16 :                                 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
    2401          16 :                                 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
    2402             :                                 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2403             :                                        formula::FormulaGrammar::GRAM_UNSPECIFIED :
    2404          16 :                                        formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2405             : 
    2406             :                                 ScValidationData* pNewData =
    2407          16 :                                         pValidObj->CreateValidationData( pDoc, eGrammar );
    2408          16 :                                 sal_uLong nIndex = pDoc->AddValidationEntry( *pNewData );
    2409          16 :                                 delete pNewData;
    2410             : 
    2411          16 :                                 ScPatternAttr aPattern( pDoc->GetPool() );
    2412          16 :                                 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
    2413          16 :                                 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
    2414             :                             }
    2415          22 :                         }
    2416             :                     }
    2417          22 :                     break;
    2418             :                 // SC_WID_UNO_NUMRULES is ignored...
    2419             :             }
    2420             :     }
    2421        1255 : }
    2422             : 
    2423       10560 : uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const OUString& aPropertyName )
    2424             :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
    2425             :                         uno::RuntimeException, std::exception)
    2426             : {
    2427       10560 :     SolarMutexGuard aGuard;
    2428             : 
    2429       10560 :     if ( !pDocShell || aRanges.empty() )
    2430           0 :         throw uno::RuntimeException();
    2431             : 
    2432       10560 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2433       10560 :     const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
    2434       10560 :     if ( !pEntry )
    2435           4 :         throw beans::UnknownPropertyException();
    2436             : 
    2437       10556 :     uno::Any aAny;
    2438       10556 :     GetOnePropertyValue( pEntry, aAny );
    2439       10560 :     return aAny;
    2440             : }
    2441             : 
    2442        9597 : void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    2443             :     throw(uno::RuntimeException, std::exception)
    2444             : {
    2445        9597 :     if ( pEntry )
    2446             :     {
    2447        9597 :         if ( IsScItemWid( pEntry->nWID ) )
    2448             :         {
    2449        9245 :             SfxItemSet* pDataSet = GetCurrentDataSet();
    2450        9245 :             if ( pDataSet )
    2451             :             {
    2452        9245 :                 switch ( pEntry->nWID )     // fuer Item-Spezial-Behandlungen
    2453             :                 {
    2454             :                     case ATTR_VALUE_FORMAT:
    2455             :                         {
    2456        7306 :                             ScDocument* pDoc = pDocShell->GetDocument();
    2457             : 
    2458             :                             sal_uLong nOldFormat = ((const SfxUInt32Item&)
    2459        7306 :                                     pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
    2460             :                             LanguageType eOldLang = ((const SvxLanguageItem&)
    2461        7306 :                                     pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
    2462             :                             nOldFormat = pDoc->GetFormatTable()->
    2463        7306 :                                     GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
    2464        7306 :                             rAny <<= (sal_Int32)( nOldFormat );
    2465             :                         }
    2466        7306 :                         break;
    2467             :                     case ATTR_INDENT:
    2468          98 :                         rAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
    2469          98 :                                         pDataSet->Get(pEntry->nWID)).GetValue()) );
    2470          49 :                         break;
    2471             :                     case ATTR_STACKED:
    2472             :                         {
    2473          58 :                             sal_Int32 nRot = ((const SfxInt32Item&)pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
    2474          58 :                             sal_Bool bStacked = ((const SfxBoolItem&)pDataSet->Get(pEntry->nWID)).GetValue();
    2475          58 :                             SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
    2476             :                         }
    2477          58 :                         break;
    2478             :                     default:
    2479        1832 :                         pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
    2480             :                 }
    2481             :             }
    2482             :         }
    2483             :         else        // implemented here
    2484         352 :             switch ( pEntry->nWID )
    2485             :             {
    2486             :                 case SC_WID_UNO_CHCOLHDR:
    2487          22 :                     ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
    2488          22 :                     break;
    2489             :                 case SC_WID_UNO_CHROWHDR:
    2490          22 :                     ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
    2491          22 :                     break;
    2492             :                 case SC_WID_UNO_CELLSTYL:
    2493             :                     {
    2494          81 :                         OUString aStyleName;
    2495          81 :                         const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
    2496          81 :                         if (pStyle)
    2497          81 :                             aStyleName = pStyle->GetName();
    2498         162 :                         rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
    2499         162 :                                                                 aStyleName, SFX_STYLE_FAMILY_PARA ) );
    2500             :                     }
    2501          81 :                     break;
    2502             :                 case SC_WID_UNO_TBLBORD:
    2503             :                 case SC_WID_UNO_TBLBORD2:
    2504             :                     {
    2505             :                         //! loop throgh all ranges
    2506          40 :                         if ( !aRanges.empty() )
    2507             :                         {
    2508          40 :                             const ScRange* pFirst = aRanges[ 0 ];
    2509          40 :                             SvxBoxItem aOuter(ATTR_BORDER);
    2510          80 :                             SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
    2511             : 
    2512          40 :                             ScDocument* pDoc = pDocShell->GetDocument();
    2513          80 :                             ScMarkData aMark;
    2514          40 :                             aMark.SetMarkArea( *pFirst );
    2515          40 :                             aMark.SelectTable( pFirst->aStart.Tab(), true );
    2516          40 :                             pDoc->GetSelectionFrame( aMark, aOuter, aInner );
    2517             : 
    2518          40 :                             if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
    2519          14 :                                 ScHelperFunctions::AssignTableBorder2ToAny( rAny, aOuter, aInner);
    2520             :                             else
    2521          66 :                                 ScHelperFunctions::AssignTableBorderToAny( rAny, aOuter, aInner);
    2522             :                         }
    2523             :                     }
    2524          40 :                     break;
    2525             :                 case SC_WID_UNO_CONDFMT:
    2526             :                 case SC_WID_UNO_CONDLOC:
    2527             :                 case SC_WID_UNO_CONDXML:
    2528             :                     {
    2529          75 :                         const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
    2530          75 :                         if ( pPattern )
    2531             :                         {
    2532          75 :                             ScDocument* pDoc = pDocShell->GetDocument();
    2533          75 :                             sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
    2534          75 :                             sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
    2535             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2536             :                                     pDoc->GetStorageGrammar() :
    2537          75 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2538             :                             const std::vector<sal_uInt32>& rIndex = ((const ScCondFormatItem&)
    2539          75 :                                     pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
    2540          75 :                             sal_uLong nIndex = 0;
    2541          75 :                             if(!rIndex.empty())
    2542          47 :                                 nIndex = rIndex[0];
    2543         150 :                             rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
    2544         150 :                                     new ScTableConditionalFormat( pDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar ));
    2545             :                         }
    2546             :                     }
    2547          75 :                     break;
    2548             :                 case SC_WID_UNO_VALIDAT:
    2549             :                 case SC_WID_UNO_VALILOC:
    2550             :                 case SC_WID_UNO_VALIXML:
    2551             :                     {
    2552          75 :                         const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
    2553          75 :                         if ( pPattern )
    2554             :                         {
    2555          75 :                             ScDocument* pDoc = pDocShell->GetDocument();
    2556          75 :                             sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
    2557          75 :                             sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
    2558             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2559             :                                     pDoc->GetStorageGrammar() :
    2560          75 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2561             :                             sal_uLong nIndex = ((const SfxUInt32Item&)
    2562          75 :                                     pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
    2563         150 :                             rAny <<= uno::Reference<beans::XPropertySet>(
    2564         150 :                                     new ScTableValidationObj( pDoc, nIndex, eGrammar ));
    2565             :                         }
    2566             :                     }
    2567          75 :                     break;
    2568             :                 case SC_WID_UNO_NUMRULES:
    2569             :                     {
    2570             :                         // always return empty numbering rules object
    2571          14 :                         rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
    2572             :                     }
    2573          14 :                     break;
    2574             :                 case SC_WID_UNO_ABSNAME:
    2575             :                     {
    2576          15 :                         OUString sRet;
    2577          15 :                         aRanges.Format(sRet, SCR_ABS_3D, pDocShell->GetDocument());
    2578          15 :                         rAny <<= sRet;
    2579             :                     }
    2580             :             }
    2581             :     }
    2582        9597 : }
    2583             : 
    2584           0 : void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const OUString& /* aPropertyName */,
    2585             :                             const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
    2586             :                             throw(beans::UnknownPropertyException,
    2587             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2588             : {
    2589           0 :     SolarMutexGuard aGuard;
    2590           0 :     if ( aRanges.empty() )
    2591           0 :         throw uno::RuntimeException();
    2592             : 
    2593           0 :     OSL_FAIL("not implemented");
    2594           0 : }
    2595             : 
    2596           0 : void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const OUString& /* aPropertyName */,
    2597             :                             const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
    2598             :                             throw(beans::UnknownPropertyException,
    2599             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2600             : {
    2601           0 :     SolarMutexGuard aGuard;
    2602           0 :     if ( aRanges.empty() )
    2603           0 :         throw uno::RuntimeException();
    2604             : 
    2605           0 :     OSL_FAIL("not implemented");
    2606           0 : }
    2607             : 
    2608           0 : void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const OUString&,
    2609             :                             const uno::Reference<beans::XVetoableChangeListener>&)
    2610             :                             throw(beans::UnknownPropertyException,
    2611             :                                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2612             : {
    2613             :     OSL_FAIL("not implemented");
    2614           0 : }
    2615             : 
    2616           0 : void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const OUString&,
    2617             :                             const uno::Reference<beans::XVetoableChangeListener>&)
    2618             :                             throw(beans::UnknownPropertyException,
    2619             :                                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2620             : {
    2621             :     OSL_FAIL("not implemented");
    2622           0 : }
    2623             : 
    2624             : // XMultiPropertySet
    2625             : 
    2626          86 : void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames,
    2627             :                                     const uno::Sequence< uno::Any >& aValues )
    2628             :                                 throw (beans::PropertyVetoException,
    2629             :                                     lang::IllegalArgumentException,
    2630             :                                     lang::WrappedTargetException,
    2631             :                                     uno::RuntimeException, std::exception)
    2632             : {
    2633          86 :     SolarMutexGuard aGuard;
    2634             : 
    2635          86 :     sal_Int32 nCount(aPropertyNames.getLength());
    2636          86 :     sal_Int32 nValues(aValues.getLength());
    2637          86 :     if (nCount != nValues)
    2638           0 :         throw lang::IllegalArgumentException();
    2639             : 
    2640          86 :     if ( pDocShell && nCount )
    2641             :     {
    2642          86 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();      // from derived class
    2643          86 :         const OUString* pNames = aPropertyNames.getConstArray();
    2644          86 :         const uno::Any* pValues = aValues.getConstArray();
    2645             : 
    2646          86 :         const SfxItemPropertySimpleEntry** pEntryArray = new const SfxItemPropertySimpleEntry*[nCount];
    2647             : 
    2648             :         sal_Int32 i;
    2649         279 :         for(i = 0; i < nCount; i++)
    2650             :         {
    2651             :             // first loop: find all properties in map, but handle only CellStyle
    2652             :             // (CellStyle must be set before any other cell properties)
    2653             : 
    2654         193 :             const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
    2655         193 :             pEntryArray[i] = pEntry;
    2656         193 :             if (pEntry)
    2657             :             {
    2658         193 :                 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    2659             :                 {
    2660             :                     try
    2661             :                     {
    2662          86 :                         SetOnePropertyValue( pEntry, pValues[i] );
    2663             :                     }
    2664           0 :                     catch ( lang::IllegalArgumentException& )
    2665             :                     {
    2666             :                         OSL_FAIL("exception when setting cell style");     // not supposed to happen
    2667             :                     }
    2668             :                 }
    2669             :             }
    2670             :         }
    2671             : 
    2672          86 :         ScDocument* pDoc = pDocShell->GetDocument();
    2673          86 :         ScPatternAttr* pOldPattern = NULL;
    2674          86 :         ScPatternAttr* pNewPattern = NULL;
    2675             : 
    2676         279 :         for(i = 0; i < nCount; i++)
    2677             :         {
    2678             :             // second loop: handle other properties
    2679             : 
    2680         193 :             const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
    2681         193 :             if ( pEntry )
    2682             :             {
    2683         193 :                 if ( IsScItemWid( pEntry->nWID ) )  // can be handled by SfxItemPropertySet
    2684             :                 {
    2685         107 :                     if ( !pOldPattern )
    2686             :                     {
    2687          86 :                         pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
    2688          86 :                         pOldPattern->GetItemSet().ClearInvalidItems();
    2689          86 :                         pNewPattern = new ScPatternAttr( pDoc->GetPool() );
    2690             :                     }
    2691             : 
    2692             :                     //  collect items in pNewPattern, apply with one call after the loop
    2693             : 
    2694             :                     sal_uInt16 nFirstItem, nSecondItem;
    2695         107 :                     lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
    2696             : 
    2697             :                     //  put only affected items into new set
    2698         107 :                     if ( nFirstItem )
    2699         107 :                         pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
    2700         107 :                     if ( nSecondItem )
    2701           0 :                         pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
    2702             :                 }
    2703          86 :                 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL )   // CellStyle is handled above
    2704             :                 {
    2705             :                     //  call virtual method to set a single property
    2706           0 :                     SetOnePropertyValue( pEntry, pValues[i] );
    2707             :                 }
    2708             :             }
    2709             :         }
    2710             : 
    2711          86 :         if ( pNewPattern && !aRanges.empty() )
    2712          86 :             pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
    2713             : 
    2714          86 :         delete pNewPattern;
    2715          86 :         delete pOldPattern;
    2716          86 :         delete[] pEntryArray;
    2717          86 :     }
    2718          86 : }
    2719             : 
    2720           0 : uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
    2721             :                                 const uno::Sequence< OUString >& aPropertyNames )
    2722             :                                     throw (uno::RuntimeException, std::exception)
    2723             : {
    2724           0 :     SolarMutexGuard aGuard;
    2725             : 
    2726           0 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2727             : 
    2728           0 :     uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
    2729           0 :     uno::Any* pProperties = aRet.getArray();
    2730           0 :     for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
    2731             :     {
    2732           0 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
    2733           0 :         GetOnePropertyValue( pEntry, pProperties[i] );
    2734             :     }
    2735           0 :     return aRet;
    2736             : }
    2737             : 
    2738           0 : void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */,
    2739             :                                     const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
    2740             :                                 throw (uno::RuntimeException, std::exception)
    2741             : {
    2742             :     OSL_FAIL("not implemented");
    2743           0 : }
    2744             : 
    2745           0 : void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
    2746             :                                 throw (uno::RuntimeException, std::exception)
    2747             : {
    2748             :     OSL_FAIL("not implemented");
    2749           0 : }
    2750             : 
    2751           0 : void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */,
    2752             :                                     const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
    2753             :                                 throw (uno::RuntimeException, std::exception)
    2754             : {
    2755             :     OSL_FAIL("not implemented");
    2756           0 : }
    2757             : 
    2758           8 : IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
    2759             : {
    2760           8 :     if ( pDocShell && pHint && pHint->ISA( SfxSimpleHint ) &&
    2761           4 :             (((const SfxSimpleHint*)pHint)->GetId() & SC_HINT_DATACHANGED))
    2762             :     {
    2763             :         //  This may be called several times for a single change, if several formulas
    2764             :         //  in the range are notified. So only a flag is set that is checked when
    2765             :         //  SFX_HINT_DATACHANGED is received.
    2766             : 
    2767           0 :         bGotDataChangedHint = true;
    2768             :     }
    2769           4 :     return 0;
    2770             : }
    2771             : 
    2772             : // XTolerantMultiPropertySet
    2773         682 : uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames,
    2774             :                                     const uno::Sequence< uno::Any >& aValues )
    2775             :                                     throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    2776             : {
    2777         682 :     SolarMutexGuard aGuard;
    2778             : 
    2779         682 :     sal_Int32 nCount(aPropertyNames.getLength());
    2780         682 :     sal_Int32 nValues(aValues.getLength());
    2781         682 :     if (nCount != nValues)
    2782           0 :         throw lang::IllegalArgumentException();
    2783             : 
    2784         682 :     if ( pDocShell && nCount )
    2785             :     {
    2786         682 :         uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
    2787         682 :         beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
    2788             : 
    2789         682 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2790         682 :         const OUString* pNames = aPropertyNames.getConstArray();
    2791         682 :         const uno::Any* pValues = aValues.getConstArray();
    2792             : 
    2793         682 :         const SfxItemPropertySimpleEntry** pMapArray = new const SfxItemPropertySimpleEntry*[nCount];
    2794             : 
    2795             :         sal_Int32 i;
    2796        5602 :         for(i = 0; i < nCount; i++)
    2797             :         {
    2798             :             // first loop: find all properties in map, but handle only CellStyle
    2799             :             // (CellStyle must be set before any other cell properties)
    2800             : 
    2801        4920 :             const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
    2802        4920 :             pMapArray[i] = pEntry;
    2803        4920 :             if (pEntry)
    2804             :             {
    2805        4872 :                 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    2806             :                 {
    2807             :                     try
    2808             :                     {
    2809         461 :                         SetOnePropertyValue( pEntry, pValues[i] );
    2810             :                     }
    2811           0 :                     catch ( lang::IllegalArgumentException& )
    2812             :                     {
    2813             :                         OSL_FAIL("exception when setting cell style");     // not supposed to happen
    2814             :                     }
    2815             :                 }
    2816             :             }
    2817             :         }
    2818             : 
    2819         682 :         ScDocument* pDoc = pDocShell->GetDocument();
    2820         682 :         ScPatternAttr* pOldPattern = NULL;
    2821         682 :         ScPatternAttr* pNewPattern = NULL;
    2822             : 
    2823         682 :         sal_Int32 nFailed(0);
    2824        5602 :         for(i = 0; i < nCount; i++)
    2825             :         {
    2826             :             // second loop: handle other properties
    2827             : 
    2828        4920 :             const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
    2829        4920 :             if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
    2830             :             {
    2831        4865 :                 if ( IsScItemWid( pEntry->nWID ) )  // can be handled by SfxItemPropertySet
    2832             :                 {
    2833        3730 :                     if ( !pOldPattern )
    2834             :                     {
    2835         408 :                         pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
    2836         408 :                         pOldPattern->GetItemSet().ClearInvalidItems();
    2837         408 :                         pNewPattern = new ScPatternAttr( pDoc->GetPool() );
    2838             :                     }
    2839             : 
    2840             :                     //  collect items in pNewPattern, apply with one call after the loop
    2841             : 
    2842             :                     sal_uInt16 nFirstItem, nSecondItem;
    2843             :                     try
    2844             :                     {
    2845        3730 :                         lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
    2846             : 
    2847             :                         //  put only affected items into new set
    2848        3728 :                         if ( nFirstItem )
    2849        3728 :                             pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
    2850        3728 :                         if ( nSecondItem )
    2851           9 :                             pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
    2852             :                     }
    2853           4 :                     catch ( lang::IllegalArgumentException& )
    2854             :                     {
    2855           2 :                         pReturns[nFailed].Name = pNames[i];
    2856           2 :                         pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
    2857             :                     }
    2858             :                 }
    2859        1135 :                 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL )   // CellStyle is handled above
    2860             :                 {
    2861             :                     //  call virtual method to set a single property
    2862             :                     try
    2863             :                     {
    2864         674 :                         SetOnePropertyValue( pEntry, pValues[i] );
    2865             :                     }
    2866           0 :                     catch ( lang::IllegalArgumentException& )
    2867             :                     {
    2868           0 :                         pReturns[nFailed].Name = pNames[i];
    2869           0 :                         pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
    2870             :                     }
    2871        4865 :                 }
    2872             :             }
    2873             :             else
    2874             :             {
    2875          55 :                 pReturns[nFailed].Name = pNames[i];
    2876          55 :                 if (pEntry)
    2877           7 :                     pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
    2878             :                 else
    2879          48 :                     pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
    2880             :             }
    2881             :         }
    2882             : 
    2883         682 :         if ( pNewPattern && !aRanges.empty() )
    2884         408 :             pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
    2885             : 
    2886         682 :         delete pNewPattern;
    2887         682 :         delete pOldPattern;
    2888         682 :         delete[] pMapArray;
    2889             : 
    2890         682 :         aReturns.realloc(nFailed);
    2891             : 
    2892         682 :         return aReturns;
    2893             :     }
    2894           0 :     return uno::Sequence < beans::SetPropertyTolerantFailed >();
    2895             : }
    2896             : 
    2897          11 : uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
    2898             :                                     throw (uno::RuntimeException, std::exception)
    2899             : {
    2900          11 :     SolarMutexGuard aGuard;
    2901             : 
    2902          11 :     sal_Int32 nCount(aPropertyNames.getLength());
    2903          11 :     uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
    2904          11 :     beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
    2905             : 
    2906          11 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2907             : 
    2908        1102 :     for(sal_Int32 i = 0; i < nCount; i++)
    2909             :     {
    2910        1091 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
    2911        1091 :         if (!pEntry)
    2912             :         {
    2913           0 :             pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
    2914             :         }
    2915             :         else
    2916             :         {
    2917        1091 :             sal_uInt16 nItemWhich = 0;
    2918        1091 :             lcl_GetPropertyWhich( pEntry, nItemWhich );
    2919        1091 :             pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
    2920        1091 :             GetOnePropertyValue( pEntry, pReturns[i].Value );
    2921        1091 :             pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
    2922             :         }
    2923             :     }
    2924          11 :     return aReturns;
    2925             : }
    2926             : 
    2927         164 : uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
    2928             :                                     throw (uno::RuntimeException, std::exception)
    2929             : {
    2930         164 :     SolarMutexGuard aGuard;
    2931             : 
    2932         164 :     sal_Int32 nCount(aPropertyNames.getLength());
    2933         164 :     uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
    2934         164 :     beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
    2935             : 
    2936         164 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2937             : 
    2938         164 :     sal_Int32 j = 0;
    2939        5520 :     for(sal_Int32 i = 0; i < nCount; i++)
    2940             :     {
    2941        5356 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
    2942        5356 :         if (!pEntry)
    2943             :         {
    2944           0 :             pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
    2945             :         }
    2946             :         else
    2947             :         {
    2948        5356 :             sal_uInt16 nItemWhich = 0;
    2949        5356 :             lcl_GetPropertyWhich( pEntry, nItemWhich );
    2950        5356 :             pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
    2951        5356 :             if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
    2952             :             {
    2953         466 :                 GetOnePropertyValue( pEntry, pReturns[j].Value );
    2954         466 :                 pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
    2955         466 :                 pReturns[j].Name = aPropertyNames[i];
    2956         466 :                 ++j;
    2957             :             }
    2958             :         }
    2959             :     }
    2960         164 :     if (j < nCount)
    2961          64 :         aReturns.realloc(j);
    2962         164 :     return aReturns;
    2963             : }
    2964             : 
    2965             : // XIndent
    2966             : 
    2967           3 : void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
    2968             : {
    2969           3 :     SolarMutexGuard aGuard;
    2970           3 :     if ( pDocShell && !aRanges.empty() )        // leer = nichts zu tun
    2971             :     {
    2972             :         //#97041#; put only MultiMarked ScMarkData in ChangeIndent
    2973           3 :         ScMarkData aMarkData(*GetMarkData());
    2974           3 :         aMarkData.MarkToMulti();
    2975           3 :         pDocShell->GetDocFunc().ChangeIndent( aMarkData, false, true );
    2976           3 :     }
    2977           3 : }
    2978             : 
    2979           3 : void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
    2980             : {
    2981           3 :     SolarMutexGuard aGuard;
    2982           3 :     if ( pDocShell && !aRanges.empty() )        // leer = nichts zu tun
    2983             :     {
    2984             :         //#97041#; put only MultiMarked ScMarkData in ChangeIndent
    2985           3 :         ScMarkData aMarkData(*GetMarkData());
    2986           3 :         aMarkData.MarkToMulti();
    2987           3 :         pDocShell->GetDocFunc().ChangeIndent( aMarkData, true, true );
    2988           3 :     }
    2989           3 : }
    2990             : 
    2991             : // XChartData
    2992             : 
    2993          18 : ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
    2994             : {
    2995          18 :     if ( pDocShell && !aRanges.empty() )
    2996             :     {
    2997          18 :         ScRangeListRef xChartRanges;
    2998          18 :         if ( aRanges.size() == 1 )
    2999             :         {
    3000             :             //  ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
    3001             :             //  (nur hier, Listener werden auf den ganzen Bereich angemeldet)
    3002             :             //! direkt testen, ob es ein ScTableSheetObj ist?
    3003             : 
    3004           8 :             const ScRange* pRange = aRanges[0];
    3005          24 :             if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
    3006           8 :                  pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
    3007             :             {
    3008           0 :                 SCTAB nTab = pRange->aStart.Tab();
    3009             : 
    3010             :                 SCCOL nStartX;
    3011             :                 SCROW nStartY; // Anfang holen
    3012           0 :                 if (!pDocShell->GetDocument()->GetDataStart( nTab, nStartX, nStartY ))
    3013             :                 {
    3014           0 :                     nStartX = 0;
    3015           0 :                     nStartY = 0;
    3016             :                 }
    3017             : 
    3018             :                 SCCOL nEndX;
    3019             :                 SCROW nEndY; // Ende holen
    3020           0 :                 if (!pDocShell->GetDocument()->GetTableArea( nTab, nEndX, nEndY ))
    3021             :                 {
    3022           0 :                     nEndX = 0;
    3023           0 :                     nEndY = 0;
    3024             :                 }
    3025             : 
    3026           0 :                 xChartRanges = new ScRangeList;
    3027           0 :                 xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
    3028             :             }
    3029             :         }
    3030          18 :         if (!xChartRanges.Is())         //  sonst Ranges direkt uebernehmen
    3031          18 :             xChartRanges = new ScRangeList(aRanges);
    3032          36 :         ScChartArray aArr( pDocShell->GetDocument(), xChartRanges, OUString() );
    3033             : 
    3034             :         // RowAsHdr = ColHeaders und umgekehrt
    3035          18 :         aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
    3036             : 
    3037          36 :         return aArr.CreateMemChart();
    3038             :     }
    3039           0 :     return NULL;
    3040             : }
    3041             : 
    3042           6 : uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
    3043             :     throw(uno::RuntimeException, std::exception)
    3044             : {
    3045           6 :     SolarMutexGuard aGuard;
    3046           6 :     ScMemChart* pMemChart = CreateMemChart_Impl();
    3047           6 :     if ( pMemChart )
    3048             :     {
    3049           6 :         sal_Int32 nColCount = pMemChart->GetColCount();
    3050           6 :         sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
    3051             : 
    3052           6 :         uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
    3053           6 :         uno::Sequence<double>* pRowAry = aRowSeq.getArray();
    3054          60 :         for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
    3055             :         {
    3056          54 :             uno::Sequence<double> aColSeq( nColCount );
    3057          54 :             double* pColAry = aColSeq.getArray();
    3058         148 :             for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
    3059          94 :                 pColAry[nCol] = pMemChart->GetData( static_cast<short>(nCol), static_cast<short>(nRow) );
    3060             : 
    3061          54 :             pRowAry[nRow] = aColSeq;
    3062          54 :         }
    3063             : 
    3064           6 :         delete pMemChart;
    3065           6 :         return aRowSeq;
    3066             :     }
    3067             : 
    3068           0 :     return uno::Sequence< uno::Sequence<double> >(0);
    3069             : }
    3070             : 
    3071           8 : ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
    3072             : {
    3073           8 :     if ( aRanges.size() == 1 )
    3074             :     {
    3075           3 :         const ScRange* pRange = aRanges[0];
    3076           9 :         if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
    3077           3 :              pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
    3078             :         {
    3079             :             //  if aRanges is a complete sheet, limit to given size
    3080             : 
    3081           0 :             SCTAB nTab = pRange->aStart.Tab();
    3082             : 
    3083           0 :             long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
    3084           0 :             if ( nEndColumn < 0 )
    3085           0 :                 nEndColumn = 0;
    3086           0 :             if ( nEndColumn > MAXCOL )
    3087           0 :                 nEndColumn = MAXCOL;
    3088             : 
    3089           0 :             long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
    3090           0 :             if ( nEndRow < 0 )
    3091           0 :                 nEndRow = 0;
    3092           0 :             if ( nEndRow > MAXROW )
    3093           0 :                 nEndRow = MAXROW;
    3094             : 
    3095           0 :             ScRangeListRef xChartRanges = new ScRangeList;
    3096           0 :             xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
    3097           0 :             return xChartRanges;
    3098             :         }
    3099             :     }
    3100             : 
    3101           8 :     return new ScRangeList(aRanges);        // as-is
    3102             : }
    3103             : 
    3104           4 : void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
    3105             :                                                 throw(uno::RuntimeException, std::exception)
    3106             : {
    3107           4 :     SolarMutexGuard aGuard;
    3108           4 :     sal_Bool bDone = false;
    3109           4 :     long nRowCount = aData.getLength();
    3110           4 :     long nColCount = nRowCount ? aData[0].getLength() : 0;
    3111           8 :     ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
    3112           4 :     if ( pDocShell && xChartRanges.Is() )
    3113             :     {
    3114           4 :         ScDocument* pDoc = pDocShell->GetDocument();
    3115           4 :         ScChartArray aArr( pDoc, xChartRanges, OUString() );
    3116           4 :         aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );      // RowAsHdr = ColHeaders
    3117           4 :         const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
    3118           4 :         if (pPosMap)
    3119             :         {
    3120           8 :             if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
    3121           4 :                  pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
    3122             :             {
    3123          43 :                 for (long nRow=0; nRow<nRowCount; nRow++)
    3124             :                 {
    3125          39 :                     const uno::Sequence<double>& rRowSeq = aData[nRow];
    3126          39 :                     const double* pArray = rRowSeq.getConstArray();
    3127          39 :                     nColCount = rRowSeq.getLength();
    3128         110 :                     for (long nCol=0; nCol<nColCount; nCol++)
    3129             :                     {
    3130             :                         const ScAddress* pPos = pPosMap->GetPosition(
    3131          71 :                                 sal::static_int_cast<SCCOL>(nCol),
    3132         142 :                                 sal::static_int_cast<SCROW>(nRow) );
    3133          71 :                         if (pPos)
    3134             :                         {
    3135          71 :                             double fVal = pArray[nCol];
    3136          71 :                             if ( fVal == DBL_MIN )
    3137          38 :                                 pDoc->SetEmptyCell(*pPos);
    3138             :                             else
    3139          33 :                                 pDoc->SetValue(*pPos, pArray[nCol]);
    3140             :                         }
    3141             :                     }
    3142             :                 }
    3143             : 
    3144             :                 //! undo
    3145           4 :                 PaintRanges_Impl( PAINT_GRID );
    3146           4 :                 pDocShell->SetDocumentModified();
    3147           4 :                 ForceChartListener_Impl();          // call listeners for this object synchronously
    3148           4 :                 bDone = sal_True;
    3149             :             }
    3150           4 :         }
    3151             :     }
    3152             : 
    3153           4 :     if (!bDone)
    3154           4 :         throw uno::RuntimeException();
    3155           4 : }
    3156             : 
    3157           6 : uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
    3158             :     throw(uno::RuntimeException, std::exception)
    3159             : {
    3160           6 :     SolarMutexGuard aGuard;
    3161           6 :     ScMemChart* pMemChart = CreateMemChart_Impl();
    3162           6 :     if ( pMemChart )
    3163             :     {
    3164           6 :         sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
    3165           6 :         uno::Sequence<OUString> aSeq( nRowCount );
    3166           6 :         OUString* pAry = aSeq.getArray();
    3167          51 :         for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
    3168          45 :             pAry[nRow] = pMemChart->GetRowText(static_cast<short>(nRow));
    3169             : 
    3170           6 :         delete pMemChart;
    3171           6 :         return aSeq;
    3172             :     }
    3173           0 :     return uno::Sequence<OUString>(0);
    3174             : }
    3175             : 
    3176           2 : void SAL_CALL ScCellRangesBase::setRowDescriptions(
    3177             :                         const uno::Sequence<OUString>& aRowDescriptions )
    3178             :                                                 throw(uno::RuntimeException, std::exception)
    3179             : {
    3180           2 :     SolarMutexGuard aGuard;
    3181           2 :     sal_Bool bDone = false;
    3182           2 :     if ( bChartColAsHdr )
    3183             :     {
    3184           2 :         long nRowCount = aRowDescriptions.getLength();
    3185           2 :         ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
    3186           2 :         if ( pDocShell && xChartRanges.Is() )
    3187             :         {
    3188           2 :             ScDocument* pDoc = pDocShell->GetDocument();
    3189           2 :             ScChartArray aArr( pDoc, xChartRanges, OUString() );
    3190           2 :             aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );      // RowAsHdr = ColHeaders
    3191           2 :             const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
    3192           2 :             if (pPosMap)
    3193             :             {
    3194           2 :                 if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
    3195             :                 {
    3196           2 :                     const OUString* pArray = aRowDescriptions.getConstArray();
    3197          17 :                     for (long nRow=0; nRow<nRowCount; nRow++)
    3198             :                     {
    3199             :                         const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
    3200          15 :                                 static_cast<SCSIZE>(nRow) );
    3201          15 :                         if (pPos)
    3202             :                         {
    3203          15 :                             const OUString& aStr = pArray[nRow];
    3204          15 :                             if (aStr.isEmpty())
    3205           0 :                                 pDoc->SetEmptyCell(*pPos);
    3206             :                             else
    3207             :                             {
    3208          15 :                                 ScSetStringParam aParam;
    3209          15 :                                 aParam.setTextInput();
    3210          15 :                                 pDoc->SetString(*pPos, aStr, &aParam);
    3211             :                             }
    3212             :                         }
    3213             :                     }
    3214             : 
    3215             :                     //! undo
    3216           2 :                     PaintRanges_Impl( PAINT_GRID );
    3217           2 :                     pDocShell->SetDocumentModified();
    3218           2 :                     ForceChartListener_Impl();          // call listeners for this object synchronously
    3219           2 :                     bDone = sal_True;
    3220             :                 }
    3221           2 :             }
    3222           2 :         }
    3223             :     }
    3224             : 
    3225           2 :     if (!bDone)
    3226           0 :         throw uno::RuntimeException();
    3227           2 : }
    3228             : 
    3229           6 : uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
    3230             :     throw(uno::RuntimeException, std::exception)
    3231             : {
    3232           6 :     SolarMutexGuard aGuard;
    3233           6 :     ScMemChart* pMemChart = CreateMemChart_Impl();
    3234           6 :     if ( pMemChart )
    3235             :     {
    3236           6 :         sal_Int32 nColCount = pMemChart->GetColCount();
    3237           6 :         uno::Sequence<OUString> aSeq( nColCount );
    3238           6 :         OUString* pAry = aSeq.getArray();
    3239          18 :         for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
    3240          12 :             pAry[nCol] = pMemChart->GetColText(static_cast<short>(nCol));
    3241             : 
    3242           6 :         delete pMemChart;
    3243           6 :         return aSeq;
    3244             :     }
    3245           0 :     return uno::Sequence<OUString>(0);
    3246             : }
    3247             : 
    3248           2 : void SAL_CALL ScCellRangesBase::setColumnDescriptions(
    3249             :     const uno::Sequence<OUString>& aColumnDescriptions )
    3250             :         throw(uno::RuntimeException, std::exception)
    3251             : {
    3252           2 :     SolarMutexGuard aGuard;
    3253           2 :     sal_Bool bDone = false;
    3254           2 :     if ( bChartRowAsHdr )
    3255             :     {
    3256           2 :         long nColCount = aColumnDescriptions.getLength();
    3257           2 :         ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
    3258           2 :         if ( pDocShell && xChartRanges.Is() )
    3259             :         {
    3260           2 :             ScDocument* pDoc = pDocShell->GetDocument();
    3261           2 :             ScChartArray aArr( pDoc, xChartRanges, OUString() );
    3262           2 :             aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );      // RowAsHdr = ColHeaders
    3263           2 :             const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
    3264           2 :             if (pPosMap)
    3265             :             {
    3266           2 :                 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
    3267             :                 {
    3268           2 :                     const OUString* pArray = aColumnDescriptions.getConstArray();
    3269           6 :                     for (long nCol=0; nCol<nColCount; nCol++)
    3270             :                     {
    3271             :                         const ScAddress* pPos = pPosMap->GetColHeaderPosition(
    3272           4 :                             sal::static_int_cast<SCCOL>(nCol) );
    3273           4 :                         if (pPos)
    3274             :                         {
    3275           4 :                             const OUString& aStr = pArray[nCol];
    3276           4 :                             if (aStr.isEmpty())
    3277           0 :                                 pDoc->SetEmptyCell(*pPos);
    3278             :                             else
    3279             :                             {
    3280           4 :                                 ScSetStringParam aParam;
    3281           4 :                                 aParam.setTextInput();
    3282           4 :                                 pDoc->SetString(*pPos, aStr, &aParam);
    3283             :                             }
    3284             :                         }
    3285             :                     }
    3286             : 
    3287             :                     //! undo
    3288           2 :                     PaintRanges_Impl( PAINT_GRID );
    3289           2 :                     pDocShell->SetDocumentModified();
    3290           2 :                     ForceChartListener_Impl();          // call listeners for this object synchronously
    3291           2 :                     bDone = sal_True;
    3292             :                 }
    3293           2 :             }
    3294           2 :         }
    3295             :     }
    3296             : 
    3297           2 :     if (!bDone)
    3298           0 :         throw uno::RuntimeException();
    3299           2 : }
    3300             : 
    3301           8 : void ScCellRangesBase::ForceChartListener_Impl()
    3302             : {
    3303             :     //  call Update immediately so the caller to setData etc. can
    3304             :     //  regognize the listener call
    3305             : 
    3306           8 :     if (!pDocShell)
    3307           0 :         return;
    3308             : 
    3309           8 :     ScChartListenerCollection* pColl = pDocShell->GetDocument()->GetChartListenerCollection();
    3310           8 :     if (!pColl)
    3311           0 :         return;
    3312             : 
    3313           8 :     ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
    3314           8 :     ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
    3315          11 :     for (; it != itEnd; ++it)
    3316             :     {
    3317           3 :         ScChartListener* p = it->second;
    3318             :         OSL_ASSERT(p);
    3319           3 :         if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty())
    3320           3 :             p->Update();
    3321             :     }
    3322             : }
    3323             : 
    3324           2 : void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
    3325             :                                     chart::XChartDataChangeEventListener >& aListener )
    3326             :                                 throw(uno::RuntimeException, std::exception)
    3327             : {
    3328           2 :     SolarMutexGuard aGuard;
    3329           2 :     if ( pDocShell && !aRanges.empty() )
    3330             :     {
    3331             :         //! auf doppelte testen?
    3332             : 
    3333           2 :         ScDocument* pDoc = pDocShell->GetDocument();
    3334           2 :         ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
    3335           2 :         ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
    3336           4 :         OUString aName = pColl->getUniqueName(OUString("__Uno"));
    3337           2 :         if (aName.isEmpty())
    3338             :             // failed to create unique name.
    3339           2 :             return;
    3340             : 
    3341           2 :         ScChartListener* pListener = new ScChartListener( aName, pDoc, aRangesRef );
    3342           2 :         pListener->SetUno( aListener, this );
    3343           2 :         pColl->insert( pListener );
    3344           4 :         pListener->StartListeningTo();
    3345           2 :     }
    3346             : }
    3347             : 
    3348           2 : void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
    3349             :                                     chart::XChartDataChangeEventListener >& aListener )
    3350             :     throw (uno::RuntimeException, std::exception)
    3351             : {
    3352           2 :     SolarMutexGuard aGuard;
    3353           2 :     if ( pDocShell && !aRanges.empty() )
    3354             :     {
    3355           2 :         ScDocument* pDoc = pDocShell->GetDocument();
    3356           2 :         ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
    3357           2 :         pColl->FreeUno( aListener, this );
    3358           2 :     }
    3359           2 : }
    3360             : 
    3361           1 : double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException, std::exception)
    3362             : {
    3363             :     //  im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
    3364           1 :     return DBL_MIN;
    3365             : }
    3366             : 
    3367           2 : sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException, std::exception)
    3368             : {
    3369             :     //  im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
    3370           2 :     return (nNumber == DBL_MIN);
    3371             : }
    3372             : 
    3373             : // XModifyBroadcaster
    3374             : 
    3375           6 : void SAL_CALL ScCellRangesBase::addModifyListener(const uno::Reference<util::XModifyListener>& aListener)
    3376             :     throw (uno::RuntimeException, std::exception)
    3377             : {
    3378           6 :     SolarMutexGuard aGuard;
    3379           6 :     if ( aRanges.empty() )
    3380           0 :         throw uno::RuntimeException();
    3381             : 
    3382             :     uno::Reference<util::XModifyListener> *pObj =
    3383           6 :             new uno::Reference<util::XModifyListener>( aListener );
    3384           6 :     aValueListeners.push_back( pObj );
    3385             : 
    3386           6 :     if ( aValueListeners.size() == 1 )
    3387             :     {
    3388           6 :         if (!pValueListener)
    3389           6 :             pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
    3390             : 
    3391           6 :         ScDocument* pDoc = pDocShell->GetDocument();
    3392          12 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; i++)
    3393           6 :             pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
    3394             : 
    3395           6 :         acquire();  // don't lose this object (one ref for all listeners)
    3396           6 :     }
    3397           6 : }
    3398             : 
    3399           2 : void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
    3400             :                                 throw(uno::RuntimeException, std::exception)
    3401             : {
    3402             : 
    3403           2 :     SolarMutexGuard aGuard;
    3404           2 :     if ( aRanges.empty() )
    3405           0 :         throw uno::RuntimeException();
    3406             : 
    3407           2 :     acquire();      // in case the listeners have the last ref - released below
    3408             : 
    3409           2 :     sal_uInt16 nCount = aValueListeners.size();
    3410           4 :     for ( sal_uInt16 n=nCount; n--; )
    3411             :     {
    3412           2 :         uno::Reference<util::XModifyListener>& rObj = aValueListeners[n];
    3413           2 :         if ( rObj == aListener )
    3414             :         {
    3415           2 :             aValueListeners.erase( aValueListeners.begin() + n );
    3416             : 
    3417           2 :             if ( aValueListeners.empty() )
    3418             :             {
    3419           2 :                 if (pValueListener)
    3420           2 :                     pValueListener->EndListeningAll();
    3421             : 
    3422           2 :                 release();      // release the ref for the listeners
    3423             :             }
    3424             : 
    3425           2 :             break;
    3426             :         }
    3427             :     }
    3428             : 
    3429           2 :     release();      // might delete this object
    3430           2 : }
    3431             : 
    3432             : // XCellRangesQuery
    3433             : 
    3434          25 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
    3435             :     throw(uno::RuntimeException, std::exception)
    3436             : {
    3437          25 :     SolarMutexGuard aGuard;
    3438          25 :     if (pDocShell)
    3439             :     {
    3440             :         //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
    3441          25 :         SCTAB nTab = lcl_FirstTab(aRanges);
    3442             : 
    3443          25 :         ScMarkData aMarkData(*GetMarkData());
    3444             : 
    3445          25 :         ScDocument* pDoc = pDocShell->GetDocument();
    3446          25 :         SCCOL nCol = 0, nLastCol;
    3447         107 :         while (nCol <= MAXCOL)
    3448             :         {
    3449          57 :             if (pDoc->ColHidden(nCol, nTab, NULL, &nLastCol))
    3450             :                 // hidden columns.  Unselect them.
    3451          18 :                 aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
    3452             : 
    3453          57 :             nCol = nLastCol + 1;
    3454             :         }
    3455             : 
    3456          25 :         SCROW nRow = 0, nLastRow;
    3457         104 :         while (nRow <= MAXROW)
    3458             :         {
    3459          54 :             if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
    3460             :                 // These rows are hidden.  Unselect them.
    3461          15 :                 aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
    3462             : 
    3463          54 :             nRow = nLastRow + 1;
    3464             :         }
    3465             : 
    3466          50 :         ScRangeList aNewRanges;
    3467          25 :         aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3468          50 :         return new ScCellRangesObj( pDocShell, aNewRanges );
    3469             :     }
    3470             : 
    3471           0 :     return NULL;
    3472             : }
    3473             : 
    3474           3 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
    3475             :     throw(uno::RuntimeException, std::exception)
    3476             : {
    3477           3 :     SolarMutexGuard aGuard;
    3478           3 :     if (pDocShell)
    3479             :     {
    3480           3 :         ScDocument* pDoc = pDocShell->GetDocument();
    3481             : 
    3482           3 :         ScMarkData aMarkData(*GetMarkData());
    3483             : 
    3484             :         //  belegte Zellen wegmarkieren
    3485           9 :         for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
    3486             :         {
    3487           6 :             ScRange aRange = *aRanges[ i ];
    3488             : 
    3489           6 :             ScCellIterator aIter( pDoc, aRange );
    3490          35 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3491             :             {
    3492             :                 //  Notizen zaehlen als nicht-leer
    3493          29 :                 if (!aIter.isEmpty())
    3494          29 :                     aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
    3495             :             }
    3496           6 :         }
    3497             : 
    3498           6 :         ScRangeList aNewRanges;
    3499             :         //  IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
    3500             :         //if (aMarkData.HasAnyMultiMarks()) // #i20044# should be set for all empty range
    3501           3 :         aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3502             : 
    3503           6 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3504             :     }
    3505             : 
    3506           0 :     return NULL;
    3507             : }
    3508             : 
    3509           2 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
    3510             :     sal_Int16 nContentFlags )
    3511             :         throw(uno::RuntimeException, std::exception)
    3512             : {
    3513           2 :     SolarMutexGuard aGuard;
    3514           2 :     if (pDocShell)
    3515             :     {
    3516           2 :         ScDocument* pDoc = pDocShell->GetDocument();
    3517             : 
    3518           2 :         ScMarkData aMarkData;
    3519             : 
    3520             :         //  passende Zellen selektieren
    3521           7 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    3522             :         {
    3523           5 :             ScRange aRange = *aRanges[ i ];
    3524             : 
    3525           5 :             ScCellIterator aIter( pDoc, aRange );
    3526          33 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3527             :             {
    3528          28 :                 bool bAdd = false;
    3529          28 :                 switch (aIter.getType())
    3530             :                 {
    3531             :                     case CELLTYPE_STRING:
    3532          20 :                         if ( nContentFlags & sheet::CellFlags::STRING )
    3533           0 :                             bAdd = true;
    3534          20 :                         break;
    3535             :                     case CELLTYPE_EDIT:
    3536           0 :                         if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
    3537           0 :                             bAdd = true;
    3538           0 :                         break;
    3539             :                     case CELLTYPE_FORMULA:
    3540           2 :                         if ( nContentFlags & sheet::CellFlags::FORMULA )
    3541           0 :                             bAdd = true;
    3542           2 :                         break;
    3543             :                     case CELLTYPE_VALUE:
    3544           6 :                         if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
    3545             :                                 == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
    3546           0 :                             bAdd = true;
    3547             :                         else
    3548             :                         {
    3549             :                             //  Date/Time Erkennung
    3550             : 
    3551             :                             sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)pDoc->GetAttr(
    3552           6 :                                         aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue();
    3553           6 :                             short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
    3554           6 :                             if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
    3555             :                                     (nTyp == NUMBERFORMAT_DATETIME))
    3556             :                             {
    3557           0 :                                 if ( nContentFlags & sheet::CellFlags::DATETIME )
    3558           0 :                                     bAdd = true;
    3559             :                             }
    3560             :                             else
    3561             :                             {
    3562           6 :                                 if ( nContentFlags & sheet::CellFlags::VALUE )
    3563           6 :                                     bAdd = true;
    3564             :                             }
    3565             :                         }
    3566           6 :                         break;
    3567             :                     default:
    3568             :                         {
    3569             :                             // added to avoid warnings
    3570             :                         }
    3571             :                 }
    3572             : 
    3573          28 :                 if (bAdd)
    3574           6 :                     aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
    3575             :             }
    3576             : 
    3577           5 :         }
    3578             : 
    3579           2 :         ScRangeList aNewRanges;
    3580           2 :         if (aMarkData.IsMultiMarked())
    3581           2 :             aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3582             : 
    3583           2 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3584             :     }
    3585             : 
    3586           0 :     return NULL;
    3587             : }
    3588             : 
    3589          25 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
    3590             :     sal_Int32 nResultFlags )
    3591             :         throw(uno::RuntimeException, std::exception)
    3592             : {
    3593          25 :     SolarMutexGuard aGuard;
    3594          25 :     if (pDocShell)
    3595             :     {
    3596          25 :         ScDocument* pDoc = pDocShell->GetDocument();
    3597             : 
    3598          25 :         ScMarkData aMarkData;
    3599             : 
    3600             :         //  passende Zellen selektieren
    3601          53 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    3602             :         {
    3603          28 :             ScRange aRange = *aRanges[ i ];
    3604             : 
    3605          28 :             ScCellIterator aIter( pDoc, aRange );
    3606         444 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3607             :             {
    3608         416 :                 if (aIter.getType() == CELLTYPE_FORMULA)
    3609             :                 {
    3610         180 :                     ScFormulaCell* pFCell = aIter.getFormulaCell();
    3611         180 :                     bool bAdd = false;
    3612         180 :                     if (pFCell->GetErrCode())
    3613             :                     {
    3614           0 :                         if ( nResultFlags & sheet::FormulaResult::ERROR )
    3615           0 :                             bAdd = true;
    3616             :                     }
    3617         180 :                     else if (pFCell->IsValue())
    3618             :                     {
    3619         180 :                         if ( nResultFlags & sheet::FormulaResult::VALUE )
    3620         180 :                             bAdd = true;
    3621             :                     }
    3622             :                     else    // String
    3623             :                     {
    3624           0 :                         if ( nResultFlags & sheet::FormulaResult::STRING )
    3625           0 :                             bAdd = true;
    3626             :                     }
    3627             : 
    3628         180 :                     if (bAdd)
    3629         180 :                         aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
    3630             :                 }
    3631             :             }
    3632          28 :         }
    3633             : 
    3634          50 :         ScRangeList aNewRanges;
    3635          25 :         if (aMarkData.IsMultiMarked())
    3636          10 :             aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3637             : 
    3638          50 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3639             :     }
    3640             : 
    3641           0 :     return NULL;
    3642             : }
    3643             : 
    3644           8 : uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
    3645             :                         const table::CellAddress& aCompare, sal_Bool bColumnDiff)
    3646             : {
    3647           8 :     if (pDocShell)
    3648             :     {
    3649           8 :         size_t nRangeCount = aRanges.size();
    3650             :         size_t i;
    3651           8 :         ScDocument* pDoc = pDocShell->GetDocument();
    3652           8 :         ScMarkData aMarkData;
    3653             : 
    3654           8 :         SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
    3655             : 
    3656             :         //  zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
    3657             :         //  (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
    3658             : 
    3659           8 :         SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
    3660           8 :         ScRange aCmpRange, aCellRange;
    3661           8 :         if (bColumnDiff)
    3662           4 :             aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
    3663             :         else
    3664           4 :             aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
    3665          16 :         ScCellIterator aCmpIter( pDoc, aCmpRange );
    3666          41 :         for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
    3667             :         {
    3668          33 :             SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
    3669          33 :             if (bColumnDiff)
    3670          32 :                 aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
    3671          16 :                         static_cast<SCCOL>(nCellPos),MAXROW,nTab );
    3672             :             else
    3673          17 :                 aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
    3674             : 
    3675         126 :             for (i=0; i<nRangeCount; i++)
    3676             :             {
    3677          93 :                 ScRange aRange( *aRanges[ i ] );
    3678          93 :                 if ( aRange.Intersects( aCellRange ) )
    3679             :                 {
    3680          29 :                     if (bColumnDiff)
    3681             :                     {
    3682          12 :                         aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
    3683          12 :                         aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
    3684             :                     }
    3685             :                     else
    3686             :                     {
    3687          17 :                         aRange.aStart.SetRow(nCellPos);
    3688          17 :                         aRange.aEnd.SetRow(nCellPos);
    3689             :                     }
    3690          29 :                     aMarkData.SetMultiMarkArea( aRange );
    3691             :                 }
    3692             :             }
    3693             :         }
    3694             : 
    3695             :         //  alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
    3696             :         //  selektieren oder aufheben
    3697             : 
    3698           8 :         ScAddress aCmpAddr;
    3699          22 :         for (i=0; i<nRangeCount; i++)
    3700             :         {
    3701          14 :             ScRange aRange( *aRanges[ i ] );
    3702             : 
    3703          14 :             ScCellIterator aIter( pDoc, aRange );
    3704          72 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3705             :             {
    3706          58 :                 if (bColumnDiff)
    3707          29 :                     aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
    3708             :                 else
    3709          29 :                     aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
    3710             : 
    3711          58 :                 ScRange aOneRange(aIter.GetPos());
    3712          58 :                 if (!aIter.equalsWithoutFormat(aCmpAddr))
    3713          13 :                     aMarkData.SetMultiMarkArea( aOneRange );
    3714             :                 else
    3715          45 :                     aMarkData.SetMultiMarkArea( aOneRange, false );     // deselect
    3716             :             }
    3717          14 :         }
    3718             : 
    3719          16 :         ScRangeList aNewRanges;
    3720           8 :         if (aMarkData.IsMultiMarked())
    3721           8 :             aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3722             : 
    3723          16 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3724             :     }
    3725           0 :     return NULL;
    3726             : }
    3727             : 
    3728           4 : uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
    3729             :     const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
    3730             : {
    3731           4 :     SolarMutexGuard aGuard;
    3732           4 :     return QueryDifferences_Impl( aCompare, true );
    3733             : }
    3734             : 
    3735           4 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
    3736             :     const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
    3737             : {
    3738           4 :     SolarMutexGuard aGuard;
    3739           4 :     return QueryDifferences_Impl( aCompare, false );
    3740             : }
    3741             : 
    3742           2 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
    3743             :                             const table::CellRangeAddress& aRange ) throw(uno::RuntimeException, std::exception)
    3744             : {
    3745           2 :     SolarMutexGuard aGuard;
    3746             :     ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
    3747           2 :                    (SCCOL)aRange.EndColumn,   (SCROW)aRange.EndRow,   aRange.Sheet );
    3748             : 
    3749           4 :     ScRangeList aNew;
    3750           7 :     for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    3751             :     {
    3752           5 :         ScRange aTemp( *aRanges[ i ] );
    3753           5 :         if ( aTemp.Intersects( aMask ) )
    3754           6 :             aNew.Join( ScRange( std::max( aTemp.aStart.Col(), aMask.aStart.Col() ),
    3755           6 :                                 std::max( aTemp.aStart.Row(), aMask.aStart.Row() ),
    3756           6 :                                 std::max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
    3757           6 :                                 std::min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
    3758           6 :                                 std::min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
    3759          21 :                                 std::min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
    3760             :     }
    3761             : 
    3762           4 :     return new ScCellRangesObj( pDocShell, aNew );  // kann leer sein
    3763             : }
    3764             : 
    3765             : // XFormulaQuery
    3766             : 
    3767           3 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
    3768             :     sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
    3769             : {
    3770           3 :     SolarMutexGuard aGuard;
    3771           3 :     if ( pDocShell )
    3772             :     {
    3773           3 :         ScDocument* pDoc = pDocShell->GetDocument();
    3774             : 
    3775           3 :         ScRangeList aNewRanges(aRanges);
    3776             :         sal_Bool bFound;
    3777           3 :         do
    3778             :         {
    3779           3 :             bFound = false;
    3780             : 
    3781             :             //  aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
    3782           3 :             ScMarkData aMarkData;
    3783           3 :             aMarkData.MarkFromRangeList( aNewRanges, false );
    3784           3 :             aMarkData.MarkToMulti();        // needed for IsAllMarked
    3785             : 
    3786           9 :             for (size_t nR = 0, nCount = aNewRanges.size(); nR<nCount; ++nR)
    3787             :             {
    3788           6 :                 ScRange aRange( *aNewRanges[ nR] );
    3789           6 :                 ScCellIterator aIter( pDoc, aRange );
    3790          36 :                 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3791             :                 {
    3792          30 :                     if (aIter.getType() != CELLTYPE_FORMULA)
    3793          28 :                         continue;
    3794             : 
    3795           2 :                     ScDetectiveRefIter aRefIter(aIter.getFormulaCell());
    3796           2 :                     ScRange aRefRange;
    3797           6 :                     while ( aRefIter.GetNextRef( aRefRange) )
    3798             :                     {
    3799           2 :                         if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
    3800           0 :                             bFound = true;
    3801           2 :                         aMarkData.SetMultiMarkArea(aRefRange, true);
    3802             :                     }
    3803             :                 }
    3804           6 :             }
    3805             : 
    3806           3 :             aMarkData.FillRangeListWithMarks( &aNewRanges, true );
    3807             :         }
    3808           0 :         while ( bRecursive && bFound );
    3809             : 
    3810           3 :         return new ScCellRangesObj( pDocShell, aNewRanges );
    3811             :     }
    3812             : 
    3813           0 :     return NULL;
    3814             : }
    3815             : 
    3816           3 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
    3817             :     sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
    3818             : {
    3819           3 :     SolarMutexGuard aGuard;
    3820           3 :     if ( pDocShell )
    3821             :     {
    3822           3 :         ScDocument* pDoc = pDocShell->GetDocument();
    3823             : 
    3824           3 :         ScRangeList aNewRanges(aRanges);
    3825             :         sal_Bool bFound;
    3826           3 :         do
    3827             :         {
    3828           3 :             bFound = false;
    3829             : 
    3830             :             //  aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
    3831           3 :             ScMarkData aMarkData;
    3832           3 :             aMarkData.MarkFromRangeList( aNewRanges, false );
    3833           3 :             aMarkData.MarkToMulti();        // needed for IsAllMarked
    3834             : 
    3835           3 :             SCTAB nTab = lcl_FirstTab(aNewRanges);              //! alle Tabellen
    3836             : 
    3837           6 :             ScCellIterator aCellIter( pDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab) );
    3838         114 :             for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
    3839             :             {
    3840         111 :                 if (aCellIter.getType() != CELLTYPE_FORMULA)
    3841         108 :                     continue;
    3842             : 
    3843           3 :                 bool bMark = false;
    3844           3 :                 ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
    3845           3 :                 ScRange aRefRange;
    3846           9 :                 while ( aIter.GetNextRef( aRefRange) )
    3847             :                 {
    3848           3 :                     size_t nRangesCount = aNewRanges.size();
    3849           9 :                     for (size_t nR = 0; nR < nRangesCount; ++nR)
    3850             :                     {
    3851           6 :                         ScRange aRange( *aNewRanges[ nR ] );
    3852           6 :                         if (aRange.Intersects(aRefRange))
    3853           2 :                             bMark = true;                   // von Teil des Ranges abhaengig
    3854             :                     }
    3855             :                 }
    3856           3 :                 if (bMark)
    3857             :                 {
    3858           2 :                     ScRange aCellRange(aCellIter.GetPos());
    3859           2 :                     if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
    3860           0 :                         bFound = true;
    3861           2 :                     aMarkData.SetMultiMarkArea(aCellRange, true);
    3862             :                 }
    3863             :             }
    3864             : 
    3865           6 :             aMarkData.FillRangeListWithMarks( &aNewRanges, true );
    3866             :         }
    3867           0 :         while ( bRecursive && bFound );
    3868             : 
    3869           3 :         return new ScCellRangesObj( pDocShell, aNewRanges );
    3870             :     }
    3871             : 
    3872           0 :     return NULL;
    3873             : }
    3874             : 
    3875             : // XSearchable
    3876             : 
    3877          12 : uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
    3878             :                                                             throw(uno::RuntimeException, std::exception)
    3879             : {
    3880          12 :     SolarMutexGuard aGuard;
    3881          12 :     return new ScCellSearchObj;
    3882             : }
    3883             : 
    3884          22 : uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
    3885             :                         const uno::Reference<util::XSearchDescriptor>& xDesc )
    3886             :                                                     throw(uno::RuntimeException,
    3887             :                                                           std::exception)
    3888             : {
    3889          22 :     SolarMutexGuard aGuard;
    3890             :     //  Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
    3891          22 :     uno::Reference<container::XIndexAccess> xRet;
    3892          22 :     if ( pDocShell && xDesc.is() )
    3893             :     {
    3894          22 :         ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
    3895          22 :         if (pSearch)
    3896             :         {
    3897          22 :             SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
    3898          22 :             if (pSearchItem)
    3899             :             {
    3900          22 :                 ScDocument* pDoc = pDocShell->GetDocument();
    3901          22 :                 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
    3902             :                 //  immer nur innerhalb dieses Objekts
    3903          22 :                 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
    3904             : 
    3905          22 :                 ScMarkData aMark(*GetMarkData());
    3906             : 
    3907          44 :                 OUString aDummyUndo;
    3908          44 :                 ScRangeList aMatchedRanges;
    3909          22 :                 SCCOL nCol = 0;
    3910          22 :                 SCROW nRow = 0;
    3911          22 :                 SCTAB nTab = 0;
    3912             :                 bool bFound = pDoc->SearchAndReplace(
    3913          22 :                     *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
    3914          22 :                 if (bFound)
    3915             :                 {
    3916             :                     //  bei findAll immer CellRanges, egal wieviel gefunden wurde
    3917          18 :                     xRet.set(new ScCellRangesObj( pDocShell, aMatchedRanges ));
    3918          22 :                 }
    3919             :             }
    3920             :         }
    3921             :     }
    3922          22 :     return xRet;
    3923             : }
    3924             : 
    3925          23 : uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
    3926             :                                     const uno::Reference<util::XSearchDescriptor>& xDesc,
    3927             :                                     const ScAddress* pLastPos )
    3928             : {
    3929          23 :     uno::Reference<uno::XInterface> xRet;
    3930          23 :     if ( pDocShell && xDesc.is() )
    3931             :     {
    3932          23 :         ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
    3933          23 :         if (pSearch)
    3934             :         {
    3935          23 :             SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
    3936          23 :             if (pSearchItem)
    3937             :             {
    3938          23 :                 ScDocument* pDoc = pDocShell->GetDocument();
    3939          23 :                 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
    3940             :                 //  immer nur innerhalb dieses Objekts
    3941          23 :                 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
    3942             : 
    3943          23 :                 ScMarkData aMark(*GetMarkData());
    3944             : 
    3945             :                 SCCOL nCol;
    3946             :                 SCROW nRow;
    3947             :                 SCTAB nTab;
    3948          23 :                 if (pLastPos)
    3949           2 :                     pLastPos->GetVars( nCol, nRow, nTab );
    3950             :                 else
    3951             :                 {
    3952          21 :                     nTab = lcl_FirstTab(aRanges);   //! mehrere Tabellen?
    3953          21 :                     ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
    3954             :                 }
    3955             : 
    3956          46 :                 OUString aDummyUndo;
    3957          46 :                 ScRangeList aMatchedRanges;
    3958             :                 bool bFound = pDoc->SearchAndReplace(
    3959          23 :                     *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
    3960          23 :                 if (bFound)
    3961             :                 {
    3962          15 :                     ScAddress aFoundPos( nCol, nRow, nTab );
    3963          15 :                     xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
    3964          23 :                 }
    3965             :             }
    3966             :         }
    3967             :     }
    3968          23 :     return xRet;
    3969             : }
    3970             : 
    3971          21 : uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
    3972             :                         const uno::Reference<util::XSearchDescriptor>& xDesc )
    3973             :                                                 throw(uno::RuntimeException, std::exception)
    3974             : {
    3975          21 :     SolarMutexGuard aGuard;
    3976          21 :     return Find_Impl( xDesc, NULL );
    3977             : }
    3978             : 
    3979           2 : uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
    3980             :                         const uno::Reference<uno::XInterface>& xStartAt,
    3981             :                         const uno::Reference<util::XSearchDescriptor >& xDesc )
    3982             :                                                 throw(uno::RuntimeException, std::exception)
    3983             : {
    3984           2 :     SolarMutexGuard aGuard;
    3985           2 :     if ( xStartAt.is() )
    3986             :     {
    3987           2 :         ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
    3988           2 :         if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
    3989             :         {
    3990           2 :             const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
    3991           2 :             if ( rStartRanges.size() == 1 )
    3992             :             {
    3993           2 :                 ScAddress aStartPos = rStartRanges[ 0 ]->aStart;
    3994           2 :                 return Find_Impl( xDesc, &aStartPos );
    3995             :             }
    3996             :         }
    3997             :     }
    3998           0 :     return NULL;
    3999             : }
    4000             : 
    4001             : // XReplaceable
    4002             : 
    4003          24 : uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
    4004             :                                                 throw(uno::RuntimeException, std::exception)
    4005             : {
    4006          24 :     SolarMutexGuard aGuard;
    4007          24 :     return new ScCellSearchObj;
    4008             : }
    4009             : 
    4010          26 : sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
    4011             :                                                 throw(uno::RuntimeException,
    4012             :                                                       std::exception)
    4013             : {
    4014          26 :     SolarMutexGuard aGuard;
    4015          26 :     sal_Int32 nReplaced = 0;
    4016          26 :     if ( pDocShell && xDesc.is() )
    4017             :     {
    4018          26 :         ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
    4019          26 :         if (pSearch)
    4020             :         {
    4021          26 :             SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
    4022          26 :             if (pSearchItem)
    4023             :             {
    4024          26 :                 ScDocument* pDoc = pDocShell->GetDocument();
    4025          26 :                 sal_Bool bUndo(pDoc->IsUndoEnabled());
    4026          26 :                 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
    4027             :                 //  immer nur innerhalb dieses Objekts
    4028          26 :                 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
    4029             : 
    4030          26 :                 ScMarkData aMark(*GetMarkData());
    4031             : 
    4032          26 :                 SCTAB nTabCount = pDoc->GetTableCount();
    4033          26 :                 bool bProtected = !pDocShell->IsEditable();
    4034          26 :                 ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
    4035          52 :                 for (; itr != itrEnd && *itr < nTabCount; ++itr)
    4036          26 :                     if ( pDoc->IsTabProtected(*itr) )
    4037           0 :                         bProtected = true;
    4038          26 :                 if (bProtected)
    4039             :                 {
    4040             :                     //! Exception, oder was?
    4041             :                 }
    4042             :                 else
    4043             :                 {
    4044          26 :                     SCTAB nTab = aMark.GetFirstSelected();      // bei SearchAndReplace nicht benutzt
    4045          26 :                     SCCOL nCol = 0;
    4046          26 :                     SCROW nRow = 0;
    4047             : 
    4048          26 :                     OUString aUndoStr;
    4049          26 :                     ScDocument* pUndoDoc = NULL;
    4050          26 :                     if (bUndo)
    4051             :                     {
    4052          26 :                         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    4053          26 :                         pUndoDoc->InitUndo( pDoc, nTab, nTab );
    4054             :                     }
    4055          26 :                     itr = aMark.begin();
    4056          52 :                     for (; itr != itrEnd && *itr < nTabCount; ++itr)
    4057          26 :                         if ( *itr != nTab && bUndo)
    4058           0 :                             pUndoDoc->AddUndoTab( *itr, *itr );
    4059          52 :                     boost::scoped_ptr<ScMarkData> pUndoMark;
    4060          26 :                     if (bUndo)
    4061          26 :                         pUndoMark.reset(new ScMarkData(aMark));
    4062             : 
    4063          26 :                     bool bFound = false;
    4064          26 :                     if (bUndo)
    4065             :                     {
    4066          26 :                         ScRangeList aMatchedRanges;
    4067             :                         bFound = pDoc->SearchAndReplace(
    4068          26 :                             *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc );
    4069             :                     }
    4070          26 :                     if (bFound)
    4071             :                     {
    4072          22 :                         nReplaced = pUndoDoc->GetCellCount();
    4073             : 
    4074          22 :                         pDocShell->GetUndoManager()->AddUndoAction(
    4075             :                             new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
    4076          22 :                                                         aUndoStr, pUndoDoc, pSearchItem ) );
    4077             : 
    4078          22 :                         pDocShell->PostPaintGridAll();
    4079          22 :                         pDocShell->SetDocumentModified();
    4080             :                     }
    4081             :                     else
    4082             :                     {
    4083           4 :                         delete pUndoDoc;
    4084             :                         // nReplaced bleibt 0
    4085          26 :                     }
    4086          26 :                 }
    4087             :             }
    4088             :         }
    4089             :     }
    4090          26 :     return nReplaced;
    4091             : }
    4092             : 
    4093             : // XUnoTunnel
    4094             : 
    4095       14669 : sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
    4096             :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
    4097             : {
    4098       29338 :     if ( rId.getLength() == 16 &&
    4099       14669 :           0 == memcmp( getUnoTunnelId().getConstArray(),
    4100       29338 :                                     rId.getConstArray(), 16 ) )
    4101             :     {
    4102       12134 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
    4103             :     }
    4104        2535 :     return 0;
    4105             : }
    4106             : 
    4107             : namespace
    4108             : {
    4109             :     class theScCellRangesBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellRangesBaseUnoTunnelId> {};
    4110             : }
    4111             : 
    4112       26805 : const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
    4113             : {
    4114       26805 :     return theScCellRangesBaseUnoTunnelId::get().getSeq();
    4115             : }
    4116             : 
    4117       12152 : ScCellRangesBase* ScCellRangesBase::getImplementation( const uno::Reference<uno::XInterface> xObj )
    4118             : {
    4119       12152 :     ScCellRangesBase* pRet = NULL;
    4120       12152 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
    4121       12152 :     if (xUT.is())
    4122       12136 :         pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
    4123       12152 :     return pRet;
    4124             : }
    4125             : 
    4126             : typedef boost::ptr_vector<ScNamedEntry> ScNamedEntryArr_Impl;
    4127             : 
    4128        2218 : struct ScCellRangesObj::Impl
    4129             : {
    4130             :     ScNamedEntryArr_Impl m_aNamedEntries;
    4131             : };
    4132             : 
    4133        1112 : ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR)
    4134             :     : ScCellRangesBase(pDocSh, rR)
    4135        1112 :     , m_pImpl(new Impl)
    4136             : {
    4137        1112 : }
    4138             : 
    4139        2212 : ScCellRangesObj::~ScCellRangesObj()
    4140             : {
    4141        2212 : }
    4142             : 
    4143        2361 : void ScCellRangesObj::RefChanged()
    4144             : {
    4145        2361 :     ScCellRangesBase::RefChanged();
    4146             : 
    4147             :     //  nix weiter...
    4148        2361 : }
    4149             : 
    4150        3077 : uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
    4151             :                                                 throw(uno::RuntimeException, std::exception)
    4152             : {
    4153        3077 :     SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
    4154        2194 :     SC_QUERYINTERFACE( sheet::XSheetCellRanges )
    4155        2069 :     SC_QUERYINTERFACE( container::XIndexAccess )
    4156        1969 :     SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
    4157        1969 :     SC_QUERYINTERFACE( container::XEnumerationAccess )
    4158        1917 :     SC_QUERYINTERFACE( container::XNameContainer )
    4159        1909 :     SC_QUERYINTERFACE( container::XNameReplace )
    4160        1909 :     SC_QUERYINTERFACE( container::XNameAccess )
    4161             : 
    4162        1829 :     return ScCellRangesBase::queryInterface( rType );
    4163             : }
    4164             : 
    4165       10379 : void SAL_CALL ScCellRangesObj::acquire() throw()
    4166             : {
    4167       10379 :     ScCellRangesBase::acquire();
    4168       10379 : }
    4169             : 
    4170       10357 : void SAL_CALL ScCellRangesObj::release() throw()
    4171             : {
    4172       10357 :     ScCellRangesBase::release();
    4173       10357 : }
    4174             : 
    4175           0 : uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException, std::exception)
    4176             : {
    4177           0 :     static uno::Sequence<uno::Type> aTypes;
    4178           0 :     if ( aTypes.getLength() == 0 )
    4179             :     {
    4180           0 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
    4181           0 :         long nParentLen = aParentTypes.getLength();
    4182           0 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    4183             : 
    4184           0 :         aTypes.realloc( nParentLen + 3 );
    4185           0 :         uno::Type* pPtr = aTypes.getArray();
    4186           0 :         pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSheetCellRangeContainer>*)0);
    4187           0 :         pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNameContainer>*)0);
    4188           0 :         pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
    4189             : 
    4190           0 :         for (long i=0; i<nParentLen; i++)
    4191           0 :             pPtr[i] = pParentPtr[i];                // parent types first
    4192             :     }
    4193           0 :     return aTypes;
    4194             : }
    4195             : 
    4196           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
    4197             :                                                     throw(uno::RuntimeException, std::exception)
    4198             : {
    4199           0 :     return css::uno::Sequence<sal_Int8>();
    4200             : }
    4201             : 
    4202             : // XCellRanges
    4203             : 
    4204         479 : ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
    4205             : {
    4206         479 :     ScDocShell* pDocSh = GetDocShell();
    4207         479 :     const ScRangeList& rRanges = GetRangeList();
    4208         479 :     if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.size()) )
    4209             :     {
    4210         477 :         ScRange aRange( *rRanges[ nIndex ] );
    4211         477 :         if ( aRange.aStart == aRange.aEnd )
    4212          10 :             return new ScCellObj( pDocSh, aRange.aStart );
    4213             :         else
    4214         467 :             return new ScCellRangeObj( pDocSh, aRange );
    4215             :     }
    4216             : 
    4217           2 :     return NULL;        // keine DocShell oder falscher Index
    4218             : }
    4219             : 
    4220         545 : uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
    4221             :                                                     throw(uno::RuntimeException, std::exception)
    4222             : {
    4223         545 :     SolarMutexGuard aGuard;
    4224         545 :     ScDocShell* pDocSh = GetDocShell();
    4225         545 :     const ScRangeList& rRanges = GetRangeList();
    4226         545 :     size_t nCount = rRanges.size();
    4227         545 :     if ( pDocSh && nCount )
    4228             :     {
    4229         542 :         table::CellRangeAddress aRangeAddress;
    4230         542 :         uno::Sequence<table::CellRangeAddress> aSeq(nCount);
    4231         542 :         table::CellRangeAddress* pAry = aSeq.getArray();
    4232        1613 :         for ( size_t i=0; i < nCount; i++)
    4233             :         {
    4234        1071 :             ScUnoConversion::FillApiRange( aRangeAddress, *rRanges[ i ] );
    4235        1071 :             pAry[i] = aRangeAddress;
    4236             :         }
    4237         542 :         return aSeq;
    4238             :     }
    4239             : 
    4240           3 :     return uno::Sequence<table::CellRangeAddress>(0);   // leer ist moeglich
    4241             : }
    4242             : 
    4243           4 : uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
    4244             :                                                     throw(uno::RuntimeException, std::exception)
    4245             : {
    4246           4 :     SolarMutexGuard aGuard;
    4247             : 
    4248             :     //  getCells with empty range list is possible (no exception),
    4249             :     //  the resulting enumeration just has no elements
    4250             :     //  (same behaviour as a valid range with no cells)
    4251             :     //  This is handled in ScCellsEnumeration ctor.
    4252             : 
    4253           4 :     const ScRangeList& rRanges = GetRangeList();
    4254           4 :     ScDocShell* pDocSh = GetDocShell();
    4255           4 :     if (pDocSh)
    4256           4 :         return new ScCellsObj( pDocSh, rRanges );
    4257           0 :     return NULL;
    4258             : }
    4259             : 
    4260          33 : OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
    4261             :                                                 throw(uno::RuntimeException, std::exception)
    4262             : {
    4263          33 :     SolarMutexGuard aGuard;
    4264          33 :     OUString aString;
    4265          33 :     ScDocShell* pDocSh = GetDocShell();
    4266          33 :     const ScRangeList& rRanges = GetRangeList();
    4267          33 :     if (pDocSh)
    4268          33 :         rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, pDocSh->GetDocument() );
    4269          33 :     return aString;
    4270             : }
    4271             : 
    4272             : // XSheetCellRangeContainer
    4273             : 
    4274        2304 : void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
    4275             :                                     sal_Bool bMergeRanges )
    4276             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception)
    4277             : {
    4278        2304 :     SolarMutexGuard aGuard;
    4279             :     ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
    4280             :             static_cast<SCROW>(rRange.StartRow),
    4281             :             static_cast<SCTAB>(rRange.Sheet),
    4282             :             static_cast<SCCOL>(rRange.EndColumn),
    4283             :             static_cast<SCROW>(rRange.EndRow),
    4284        2304 :             static_cast<SCTAB>(rRange.Sheet));
    4285        2304 :     AddRange(aRange, bMergeRanges);
    4286        2304 : }
    4287             : 
    4288           8 : static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
    4289             : {
    4290           8 :     sal_uInt16 nCount = rNamedEntries.size();
    4291          26 :     for ( sal_uInt16 n=nCount; n--; )
    4292          10 :         if ( rNamedEntries[n].GetRange() == rRange )
    4293           4 :             rNamedEntries.erase( rNamedEntries.begin() + n );
    4294           8 : }
    4295             : 
    4296           8 : void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
    4297             :                                 throw(::com::sun::star::container::NoSuchElementException,
    4298             :                                     ::com::sun::star::uno::RuntimeException, std::exception)
    4299             : {
    4300           8 :     SolarMutexGuard aGuard;
    4301           8 :     const ScRangeList& rRanges = GetRangeList();
    4302             : 
    4303          16 :     ScRangeList aSheetRanges;
    4304          16 :     ScRangeList aNotSheetRanges;
    4305          25 :     for (size_t i = 0; i < rRanges.size(); ++i)
    4306             :     {
    4307          17 :         if (rRanges[ i]->aStart.Tab() == rRange.Sheet)
    4308             :         {
    4309          14 :             aSheetRanges.Append( *rRanges[ i ] );
    4310             :         }
    4311             :         else
    4312             :         {
    4313           3 :             aNotSheetRanges.Append( *rRanges[ i ] );
    4314             :         }
    4315             :     }
    4316          16 :     ScMarkData aMarkData;
    4317           8 :     aMarkData.MarkFromRangeList( aSheetRanges, false );
    4318             :     ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
    4319             :                 static_cast<SCROW>(rRange.StartRow),
    4320             :                 static_cast<SCTAB>(rRange.Sheet),
    4321             :                 static_cast<SCCOL>(rRange.EndColumn),
    4322             :                 static_cast<SCROW>(rRange.EndRow),
    4323           8 :                 static_cast<SCTAB>(rRange.Sheet));
    4324           8 :     if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
    4325             :     {
    4326           8 :         aMarkData.MarkToMulti();
    4327           8 :         if (aMarkData.IsAllMarked( aRange ) )
    4328             :         {
    4329           8 :             aMarkData.SetMultiMarkArea( aRange, false );
    4330           8 :             lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aRange);
    4331             :         }
    4332             :         else
    4333           0 :             throw container::NoSuchElementException();
    4334             :     }
    4335           8 :     SetNewRanges(aNotSheetRanges);
    4336          16 :     ScRangeList aNew;
    4337           8 :     aMarkData.FillRangeListWithMarks( &aNew, false );
    4338          14 :     for ( size_t j = 0; j < aNew.size(); ++j)
    4339             :     {
    4340           6 :         AddRange(*aNew[ j ], false);
    4341           8 :     }
    4342           8 : }
    4343             : 
    4344           1 : void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
    4345             :                                     sal_Bool bMergeRanges )
    4346             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception)
    4347             : {
    4348           1 :     SolarMutexGuard aGuard;
    4349           1 :     sal_Int32 nCount(rRanges.getLength());
    4350           1 :     if (nCount)
    4351             :     {
    4352           1 :         const table::CellRangeAddress* pRanges = rRanges.getConstArray();
    4353           4 :         for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
    4354             :         {
    4355             :             ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
    4356             :                     static_cast<SCROW>(pRanges->StartRow),
    4357             :                     static_cast<SCTAB>(pRanges->Sheet),
    4358             :                     static_cast<SCCOL>(pRanges->EndColumn),
    4359             :                     static_cast<SCROW>(pRanges->EndRow),
    4360           3 :                     static_cast<SCTAB>(pRanges->Sheet));
    4361           3 :             AddRange(aRange, bMergeRanges);
    4362             :         }
    4363           1 :     }
    4364           1 : }
    4365             : 
    4366           4 : void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
    4367             :                                 throw(::com::sun::star::container::NoSuchElementException,
    4368             :                                     ::com::sun::star::uno::RuntimeException, std::exception)
    4369             : {
    4370             :     // use sometimes a better/faster implementation
    4371           4 :     sal_uInt32 nCount(rRangeSeq.getLength());
    4372           4 :     if (nCount)
    4373             :     {
    4374           2 :         const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
    4375           9 :         for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
    4376             :         {
    4377           7 :             removeRangeAddress(*pRanges);
    4378             :         }
    4379             :     }
    4380           4 : }
    4381             : 
    4382             : // XNameContainer
    4383             : 
    4384           4 : static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const OUString& rName )
    4385             : {
    4386           4 :     sal_uInt16 nCount = rNamedEntries.size();
    4387          25 :     for ( sal_uInt16 n=nCount; n--; )
    4388          17 :         if ( rNamedEntries[n].GetName() == rName )
    4389           3 :             rNamedEntries.erase( rNamedEntries.begin() + n );
    4390           4 : }
    4391             : 
    4392          37 : void SAL_CALL ScCellRangesObj::insertByName( const OUString& aName, const uno::Any& aElement )
    4393             :                             throw (lang::IllegalArgumentException, container::ElementExistException,
    4394             :                                    lang::WrappedTargetException, uno::RuntimeException,
    4395             :                                    std::exception)
    4396             : {
    4397          37 :     SolarMutexGuard aGuard;
    4398          37 :     ScDocShell* pDocSh = GetDocShell();
    4399          37 :     sal_Bool bDone = false;
    4400             : 
    4401             :     //! Type of aElement can be some specific interface instead of XInterface
    4402             : 
    4403          74 :     uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
    4404          37 :     if ( pDocSh && xInterface.is() )
    4405             :     {
    4406          36 :         ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
    4407          36 :         if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
    4408             :         {
    4409             :             //  if explicit name is given and already existing, throw exception
    4410             : 
    4411          36 :             OUString aNamStr(aName);
    4412          36 :             if ( !aNamStr.isEmpty() )
    4413             :             {
    4414          36 :                 size_t nNamedCount = m_pImpl->m_aNamedEntries.size();
    4415          98 :                 for (size_t n = 0; n < nNamedCount; n++)
    4416             :                 {
    4417          63 :                     if (m_pImpl->m_aNamedEntries[n].GetName() == aNamStr)
    4418           1 :                         throw container::ElementExistException();
    4419             :                 }
    4420             :             }
    4421             : 
    4422          70 :             ScRangeList aNew(GetRangeList());
    4423          35 :             const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
    4424          35 :             size_t nAddCount = rAddRanges.size();
    4425          70 :             for ( size_t i = 0; i < nAddCount; i++ )
    4426          35 :                 aNew.Join( *rAddRanges[ i ] );
    4427          35 :             SetNewRanges(aNew);
    4428          35 :             bDone = sal_True;
    4429             : 
    4430          35 :             if ( !aName.isEmpty() && nAddCount == 1 )
    4431             :             {
    4432             :                 //  if a name is given, also insert into list of named entries
    4433             :                 //  (only possible for a single range)
    4434             :                 //  name is not in m_pImpl->m_aNamedEntries (tested above)
    4435             : 
    4436          35 :                 ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges[ 0 ] );
    4437          35 :                 m_pImpl->m_aNamedEntries.push_back(pEntry);
    4438          36 :             }
    4439             :         }
    4440             :     }
    4441             : 
    4442          36 :     if (!bDone)
    4443             :     {
    4444             :         //  invalid element - double names are handled above
    4445           1 :         throw lang::IllegalArgumentException();
    4446          37 :     }
    4447          35 : }
    4448             : 
    4449          13 : static sal_Bool lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
    4450             :                             const OUString& rName, size_t& rIndex )
    4451             : {
    4452          13 :     if (pDocSh)
    4453             :     {
    4454          13 :         OUString aRangeStr;
    4455          13 :         ScDocument* pDoc = pDocSh->GetDocument();
    4456          67 :         for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
    4457             :         {
    4458          54 :             aRangeStr = rRanges[ i ]->Format(SCA_VALID | SCA_TAB_3D, pDoc);
    4459          54 :             if ( aRangeStr == rName )
    4460             :             {
    4461           0 :                 rIndex = i;
    4462           0 :                 return sal_True;
    4463             :             }
    4464          13 :         }
    4465             :     }
    4466          13 :     return false;   // nicht gefunden
    4467             : }
    4468             : 
    4469           9 : static sal_Bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
    4470             :                             const ScRangeList& rRanges, ScDocShell* pDocSh,
    4471             :                             const OUString& rName, ScRange& rFound )
    4472             : {
    4473             :     //  exact range in list?
    4474             : 
    4475           9 :     size_t nIndex = 0;
    4476           9 :     if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
    4477             :     {
    4478           0 :         rFound = *rRanges[ nIndex ];
    4479           0 :         return true;
    4480             :     }
    4481             : 
    4482             :     //  range contained in selection? (sheet must be specified)
    4483             : 
    4484           9 :     ScRange aCellRange;
    4485           9 :     sal_uInt16 nParse = aCellRange.ParseAny( rName, pDocSh->GetDocument() );
    4486           9 :     if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
    4487             :     {
    4488           0 :         ScMarkData aMarkData;
    4489           0 :         aMarkData.MarkFromRangeList( rRanges, false );
    4490           0 :         aMarkData.MarkToMulti();        // needed for IsAllMarked
    4491           0 :         if ( aMarkData.IsAllMarked( aCellRange ) )
    4492             :         {
    4493           0 :             rFound = aCellRange;
    4494           0 :             return sal_True;
    4495           0 :         }
    4496             :     }
    4497             : 
    4498             :     //  named entry in this object?
    4499             : 
    4500           9 :     if ( !rNamedEntries.empty() )
    4501             :     {
    4502          31 :         for ( sal_uInt16 n=0; n<rNamedEntries.size(); n++ )
    4503          28 :             if ( rNamedEntries[n].GetName() == rName )
    4504             :             {
    4505             :                 //  test if named entry is contained in rRanges
    4506             : 
    4507           6 :                 const ScRange& rComp = rNamedEntries[n].GetRange();
    4508           6 :                 ScMarkData aMarkData;
    4509           6 :                 aMarkData.MarkFromRangeList( rRanges, false );
    4510           6 :                 aMarkData.MarkToMulti();        // needed for IsAllMarked
    4511           6 :                 if ( aMarkData.IsAllMarked( rComp ) )
    4512             :                 {
    4513           6 :                     rFound = rComp;
    4514           6 :                     return sal_True;
    4515           0 :                 }
    4516             :             }
    4517             :     }
    4518             : 
    4519           3 :     return false;       // not found
    4520             : }
    4521             : 
    4522           4 : void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
    4523             :                                 throw(container::NoSuchElementException,
    4524             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4525             : {
    4526           4 :     SolarMutexGuard aGuard;
    4527           4 :     sal_Bool bDone = false;
    4528           8 :     OUString aNameStr(aName);
    4529           4 :     ScDocShell* pDocSh = GetDocShell();
    4530           4 :     const ScRangeList& rRanges = GetRangeList();
    4531           4 :     size_t nIndex = 0;
    4532           4 :     if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
    4533             :     {
    4534             :         //  einzelnen Range weglassen
    4535           0 :         ScRangeList aNew;
    4536           0 :         for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
    4537           0 :             if (i != nIndex)
    4538           0 :                 aNew.Append( *rRanges[ i ] );
    4539           0 :         SetNewRanges(aNew);
    4540           0 :         bDone = sal_True;
    4541             :     }
    4542           4 :     else if (pDocSh)
    4543             :     {
    4544             :         //  deselect any ranges (parsed or named entry)
    4545           4 :         ScRangeList aDiff;
    4546           4 :         sal_Bool bValid = ( aDiff.Parse( aNameStr, pDocSh->GetDocument() ) & SCA_VALID ) != 0;
    4547           4 :         if (!bValid && !m_pImpl->m_aNamedEntries.empty())
    4548             :         {
    4549           4 :             sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size();
    4550          18 :             for (sal_uInt16 n=0; n<nCount && !bValid; n++)
    4551          14 :                 if (m_pImpl->m_aNamedEntries[n].GetName() == aNameStr)
    4552             :                 {
    4553           3 :                     aDiff.RemoveAll();
    4554           3 :                     aDiff.Append(m_pImpl->m_aNamedEntries[n].GetRange());
    4555           3 :                     bValid = sal_True;
    4556             :                 }
    4557             :         }
    4558           4 :         if ( bValid )
    4559             :         {
    4560           3 :             ScMarkData aMarkData;
    4561           3 :             aMarkData.MarkFromRangeList( rRanges, false );
    4562             : 
    4563           6 :             for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ )
    4564             :             {
    4565           3 :                 ScRange* pDiffRange = aDiff[ i ];
    4566           3 :                 if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
    4567           3 :                     aMarkData.SetMultiMarkArea( *pDiffRange, false );
    4568             :             }
    4569             : 
    4570           6 :             ScRangeList aNew;
    4571           3 :             aMarkData.FillRangeListWithMarks( &aNew, false );
    4572           3 :             SetNewRanges(aNew);
    4573             : 
    4574           6 :             bDone = sal_True;       //! error if range was not selected before?
    4575           4 :         }
    4576             :     }
    4577             : 
    4578           4 :     if (!m_pImpl->m_aNamedEntries.empty())
    4579           4 :         lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aNameStr);
    4580             : 
    4581           4 :     if (!bDone)
    4582           5 :         throw container::NoSuchElementException();      // not found
    4583           3 : }
    4584             : 
    4585             : // XNameReplace
    4586             : 
    4587           2 : void SAL_CALL ScCellRangesObj::replaceByName( const OUString& aName, const uno::Any& aElement )
    4588             :                             throw(lang::IllegalArgumentException, container::NoSuchElementException,
    4589             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4590             : {
    4591           2 :     SolarMutexGuard aGuard;
    4592             :     //! zusammenfassen?
    4593           2 :     removeByName( aName );
    4594           2 :     insertByName( aName, aElement );
    4595           2 : }
    4596             : 
    4597             : // XNameAccess
    4598             : 
    4599           5 : uno::Any SAL_CALL ScCellRangesObj::getByName( const OUString& aName )
    4600             :             throw(container::NoSuchElementException,
    4601             :                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4602             : {
    4603           5 :     SolarMutexGuard aGuard;
    4604           5 :     uno::Any aRet;
    4605             : 
    4606          10 :     OUString aNameStr(aName);
    4607           5 :     ScDocShell* pDocSh = GetDocShell();
    4608           5 :     const ScRangeList& rRanges = GetRangeList();
    4609           5 :     ScRange aRange;
    4610          10 :     if (lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges,
    4611           5 :                 pDocSh, aNameStr, aRange))
    4612             :     {
    4613           4 :         uno::Reference<table::XCellRange> xRange;
    4614           4 :         if ( aRange.aStart == aRange.aEnd )
    4615           0 :             xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
    4616             :         else
    4617           4 :             xRange.set(new ScCellRangeObj( pDocSh, aRange ));
    4618           4 :         aRet <<= xRange;
    4619             :     }
    4620             :     else
    4621           1 :         throw container::NoSuchElementException();
    4622           9 :     return aRet;
    4623             : }
    4624             : 
    4625          22 : static sal_Bool lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
    4626             :                         const ScRange& rRange, OUString& rName )
    4627             : {
    4628          22 :     sal_uInt16 nCount = rNamedEntries.size();
    4629          60 :     for (sal_uInt16 i=0; i<nCount; i++)
    4630          60 :         if (rNamedEntries[i].GetRange() == rRange)
    4631             :         {
    4632          22 :             rName = rNamedEntries[i].GetName();
    4633          22 :             return sal_True;
    4634             :         }
    4635           0 :     return false;
    4636             : }
    4637             : 
    4638           5 : uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getElementNames()
    4639             :                                                 throw(uno::RuntimeException, std::exception)
    4640             : {
    4641           5 :     SolarMutexGuard aGuard;
    4642             : 
    4643           5 :     ScDocShell* pDocSh = GetDocShell();
    4644           5 :     const ScRangeList& rRanges = GetRangeList();
    4645           5 :     if (pDocSh)
    4646             :     {
    4647           5 :         OUString aRangeStr;
    4648           5 :         ScDocument* pDoc = pDocSh->GetDocument();
    4649           5 :         size_t nCount = rRanges.size();
    4650             : 
    4651          10 :         uno::Sequence<OUString> aSeq(nCount);
    4652           5 :         OUString* pAry = aSeq.getArray();
    4653          27 :         for (size_t i=0; i < nCount; i++)
    4654             :         {
    4655             :             //  use given name if for exactly this range, otherwise just format
    4656          22 :             ScRange aRange = *rRanges[ i ];
    4657          44 :             if (m_pImpl->m_aNamedEntries.empty() ||
    4658          22 :                 !lcl_FindEntryName(m_pImpl->m_aNamedEntries, aRange, aRangeStr))
    4659             :             {
    4660           0 :                 aRangeStr = aRange.Format(SCA_VALID | SCA_TAB_3D, pDoc);
    4661             :             }
    4662          22 :             pAry[i] = aRangeStr;
    4663             :         }
    4664          10 :         return aSeq;
    4665             :     }
    4666           0 :     return uno::Sequence<OUString>(0);
    4667             : }
    4668             : 
    4669           4 : sal_Bool SAL_CALL ScCellRangesObj::hasByName( const OUString& aName )
    4670             :                                         throw(uno::RuntimeException, std::exception)
    4671             : {
    4672           4 :     SolarMutexGuard aGuard;
    4673           8 :     OUString aNameStr(aName);
    4674           4 :     ScDocShell* pDocSh = GetDocShell();
    4675           4 :     const ScRangeList& rRanges = GetRangeList();
    4676           4 :     ScRange aRange;
    4677           4 :     return lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, pDocSh,
    4678           8 :                 aNameStr, aRange);
    4679             : }
    4680             : 
    4681             : // XEnumerationAccess
    4682             : 
    4683          52 : uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
    4684             :                                                     throw(uno::RuntimeException, std::exception)
    4685             : {
    4686          52 :     SolarMutexGuard aGuard;
    4687          52 :     return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.SheetCellRangesEnumeration"));
    4688             : }
    4689             : 
    4690             : // XIndexAccess
    4691             : 
    4692         517 : sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException, std::exception)
    4693             : {
    4694         517 :     SolarMutexGuard aGuard;
    4695         517 :     const ScRangeList& rRanges = GetRangeList();
    4696         517 :     return rRanges.size();
    4697             : }
    4698             : 
    4699         479 : uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
    4700             :                             throw(lang::IndexOutOfBoundsException,
    4701             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4702             : {
    4703         479 :     SolarMutexGuard aGuard;
    4704         958 :     uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
    4705         479 :     if (xRange.is())
    4706         954 :         return uno::makeAny(xRange);
    4707             :     else
    4708         481 :         throw lang::IndexOutOfBoundsException();
    4709             : }
    4710             : 
    4711           1 : uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException, std::exception)
    4712             : {
    4713           1 :     SolarMutexGuard aGuard;
    4714           1 :     return getCppuType((uno::Reference<table::XCellRange>*)0);
    4715             : }
    4716             : 
    4717           1 : sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException, std::exception)
    4718             : {
    4719           1 :     SolarMutexGuard aGuard;
    4720           1 :     const ScRangeList& rRanges = GetRangeList();
    4721           1 :     return !rRanges.empty();
    4722             : }
    4723             : 
    4724             : // XServiceInfo
    4725           4 : OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    4726             : {
    4727           4 :     return OUString( "ScCellRangesObj" );
    4728             : }
    4729             : 
    4730          12 : sal_Bool SAL_CALL ScCellRangesObj::supportsService( const OUString& rServiceName )
    4731             :                                                     throw(uno::RuntimeException, std::exception)
    4732             : {
    4733          12 :     return cppu::supportsService(this, rServiceName);
    4734             : }
    4735             : 
    4736          12 : uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
    4737             :                                                     throw(uno::RuntimeException, std::exception)
    4738             : {
    4739          12 :     uno::Sequence<OUString> aRet(4);
    4740          12 :     OUString* pArray = aRet.getArray();
    4741          12 :     pArray[0] = OUString( SCSHEETCELLRANGES_SERVICE );
    4742          12 :     pArray[1] = OUString( SCCELLPROPERTIES_SERVICE );
    4743          12 :     pArray[2] = OUString( SCCHARPROPERTIES_SERVICE );
    4744          12 :     pArray[3] = OUString( SCPARAPROPERTIES_SERVICE );
    4745          12 :     return aRet;
    4746             : }
    4747             : 
    4748           0 : uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
    4749             : {
    4750           0 :     SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
    4751           0 :     if ( pObjSh && pObjSh->ISA(ScDocShell) )
    4752           0 :         return new ScCellRangeObj( (ScDocShell*) pObjSh, rR );
    4753           0 :     return NULL;
    4754             : }
    4755             : 
    4756       22638 : ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
    4757             :     ScCellRangesBase( pDocSh, rR ),
    4758       22638 :     pRangePropSet( lcl_GetRangePropertySet() ),
    4759       45276 :     aRange( rR )
    4760             : {
    4761       22638 :     aRange.Justify();       // Anfang / Ende richtig
    4762       22638 : }
    4763             : 
    4764       28223 : ScCellRangeObj::~ScCellRangeObj()
    4765             : {
    4766       28223 : }
    4767             : 
    4768        3147 : void ScCellRangeObj::RefChanged()
    4769             : {
    4770        3147 :     ScCellRangesBase::RefChanged();
    4771             : 
    4772        3147 :     const ScRangeList& rRanges = GetRangeList();
    4773             :     OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
    4774        3147 :     if ( !rRanges.empty() )
    4775             :     {
    4776        3121 :         const ScRange* pFirst = rRanges[0];
    4777        3121 :         aRange = ScRange(*pFirst);
    4778        3121 :         aRange.Justify();
    4779             :     }
    4780        3147 : }
    4781             : 
    4782       53766 : uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
    4783             :                                                 throw(uno::RuntimeException, std::exception)
    4784             : {
    4785       53766 :     SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
    4786       48825 :     SC_QUERYINTERFACE( table::XCellRange )
    4787       40713 :     SC_QUERYINTERFACE( sheet::XSheetCellRange )
    4788       38158 :     SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
    4789       38156 :     SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
    4790       38156 :     SC_QUERYINTERFACE( sheet::XCellRangeData )
    4791       38132 :     SC_QUERYINTERFACE( sheet::XCellRangeFormula )
    4792       38130 :     SC_QUERYINTERFACE( sheet::XMultipleOperation )
    4793       38129 :     SC_QUERYINTERFACE( util::XMergeable )
    4794       38121 :     SC_QUERYINTERFACE( sheet::XCellSeries )
    4795       38111 :     SC_QUERYINTERFACE( table::XAutoFormattable )
    4796       38111 :     SC_QUERYINTERFACE( util::XSortable )
    4797       38110 :     SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
    4798       38109 :     SC_QUERYINTERFACE( sheet::XSheetFilterable )
    4799       38107 :     SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
    4800       38101 :     SC_QUERYINTERFACE( table::XColumnRowRange )
    4801       34298 :     SC_QUERYINTERFACE( util::XImportable )
    4802       34295 :     SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
    4803       34292 :     SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
    4804             : 
    4805       34267 :     return ScCellRangesBase::queryInterface( rType );
    4806             : }
    4807             : 
    4808      203207 : void SAL_CALL ScCellRangeObj::acquire() throw()
    4809             : {
    4810      203207 :     ScCellRangesBase::acquire();
    4811      203207 : }
    4812             : 
    4813      203088 : void SAL_CALL ScCellRangeObj::release() throw()
    4814             : {
    4815      203088 :     ScCellRangesBase::release();
    4816      203088 : }
    4817             : 
    4818           5 : uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException, std::exception)
    4819             : {
    4820           5 :     static uno::Sequence<uno::Type> aTypes;
    4821           5 :     if ( aTypes.getLength() == 0 )
    4822             :     {
    4823           2 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
    4824           2 :         long nParentLen = aParentTypes.getLength();
    4825           2 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    4826             : 
    4827           2 :         aTypes.realloc( nParentLen + 17 );
    4828           2 :         uno::Type* pPtr = aTypes.getArray();
    4829           2 :         pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XCellRangeAddressable>*)0);
    4830           2 :         pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XSheetCellRange>*)0);
    4831           2 :         pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XArrayFormulaRange>*)0);
    4832           2 :         pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XArrayFormulaTokens>*)0);
    4833           2 :         pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XCellRangeData>*)0);
    4834           2 :         pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XCellRangeFormula>*)0);
    4835           2 :         pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XMultipleOperation>*)0);
    4836           2 :         pPtr[nParentLen + 7] = getCppuType((const uno::Reference<util::XMergeable>*)0);
    4837           2 :         pPtr[nParentLen + 8] = getCppuType((const uno::Reference<sheet::XCellSeries>*)0);
    4838           2 :         pPtr[nParentLen + 9] = getCppuType((const uno::Reference<table::XAutoFormattable>*)0);
    4839           2 :         pPtr[nParentLen +10] = getCppuType((const uno::Reference<util::XSortable>*)0);
    4840           2 :         pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetFilterableEx>*)0);
    4841           2 :         pPtr[nParentLen +12] = getCppuType((const uno::Reference<sheet::XSubTotalCalculatable>*)0);
    4842           2 :         pPtr[nParentLen +13] = getCppuType((const uno::Reference<table::XColumnRowRange>*)0);
    4843           2 :         pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XImportable>*)0);
    4844           2 :         pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XCellFormatRangesSupplier>*)0);
    4845           2 :         pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XUniqueCellFormatRangesSupplier>*)0);
    4846             : 
    4847          28 :         for (long i=0; i<nParentLen; i++)
    4848          28 :             pPtr[i] = pParentPtr[i];                // parent types first
    4849             :     }
    4850           5 :     return aTypes;
    4851             : }
    4852             : 
    4853           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
    4854             :                                                     throw(uno::RuntimeException, std::exception)
    4855             : {
    4856           0 :     return css::uno::Sequence<sal_Int8>();
    4857             : }
    4858             : 
    4859             : // XCellRange
    4860             : 
    4861             : //  ColumnCount / RowCount sind weggefallen
    4862             : //! werden im Writer fuer Tabellen noch gebraucht ???
    4863             : 
    4864       12023 : uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
    4865             :                                         sal_Int32 nColumn, sal_Int32 nRow )
    4866             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
    4867             : {
    4868       12023 :     ScDocShell* pDocSh = GetDocShell();
    4869       12023 :     if (!pDocSh)
    4870           0 :         throw uno::RuntimeException();
    4871             : 
    4872       12023 :     if ( nColumn >= 0 && nRow >= 0 )
    4873             :     {
    4874       12022 :         sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
    4875       12022 :         sal_Int32 nPosY = aRange.aStart.Row() + nRow;
    4876             : 
    4877       12022 :         if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
    4878             :         {
    4879       12022 :             ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
    4880       24044 :             return new ScCellObj( pDocSh, aNew );
    4881             :         }
    4882             :     }
    4883             : 
    4884           1 :     throw lang::IndexOutOfBoundsException();
    4885             : }
    4886             : 
    4887        8204 : uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
    4888             :                                         sal_Int32 nColumn, sal_Int32 nRow )
    4889             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    4890             : {
    4891        8204 :     SolarMutexGuard aGuard;
    4892             : 
    4893        8204 :     return GetCellByPosition_Impl(nColumn, nRow);
    4894             : }
    4895             : 
    4896        4259 : uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
    4897             :                 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
    4898             :                                     throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    4899             : {
    4900        4259 :     SolarMutexGuard aGuard;
    4901             : 
    4902        4259 :     ScDocShell* pDocSh = GetDocShell();
    4903        4259 :     if (!pDocSh)
    4904           0 :         throw uno::RuntimeException();
    4905             : 
    4906        4259 :     if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
    4907             :     {
    4908        4258 :         sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
    4909        4258 :         sal_Int32 nStartY = aRange.aStart.Row() + nTop;
    4910        4258 :         sal_Int32 nEndX = aRange.aStart.Col() + nRight;
    4911        4258 :         sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
    4912             : 
    4913        8516 :         if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
    4914        8516 :              nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
    4915             :         {
    4916        4258 :             ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
    4917        8516 :                           (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
    4918        8516 :             return new ScCellRangeObj( pDocSh, aNew );
    4919             :         }
    4920             :     }
    4921             : 
    4922        4258 :     throw lang::IndexOutOfBoundsException();
    4923             : }
    4924             : 
    4925          94 : uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
    4926             :                         const OUString& aName ) throw(uno::RuntimeException, std::exception)
    4927             : {
    4928          94 :     return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
    4929             : }
    4930             : 
    4931          94 : uno::Reference<table::XCellRange>  ScCellRangeObj::getCellRangeByName(
    4932             :                         const OUString& aName, const ScAddress::Details& rDetails  ) throw(uno::RuntimeException)
    4933             : {
    4934             :     //  name refers to the whole document (with the range's table as default),
    4935             :     //  valid only if the range is within this range
    4936             : 
    4937          94 :     SolarMutexGuard aGuard;
    4938          94 :     ScDocShell* pDocSh = GetDocShell();
    4939          94 :     if ( pDocSh )
    4940             :     {
    4941          94 :         ScDocument* pDoc = pDocSh->GetDocument();
    4942          94 :         SCTAB nTab = aRange.aStart.Tab();
    4943             : 
    4944          94 :         ScRange aCellRange;
    4945          94 :         sal_Bool bFound = false;
    4946          94 :         OUString aString(aName);
    4947          94 :         sal_uInt16 nParse = aCellRange.ParseAny( aString, pDoc, rDetails );
    4948          94 :         if ( nParse & SCA_VALID )
    4949             :         {
    4950          94 :             if ( !(nParse & SCA_TAB_3D) )   // keine Tabelle angegeben -> auf dieser Tabelle
    4951             :             {
    4952          61 :                 aCellRange.aStart.SetTab(nTab);
    4953          61 :                 aCellRange.aEnd.SetTab(nTab);
    4954             :             }
    4955          94 :             bFound = sal_True;
    4956             :         }
    4957             :         else
    4958             :         {
    4959           0 :             ScRangeUtil aRangeUtil;
    4960           0 :             if ( aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_NAMES ) ||
    4961           0 :                  aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_DBASE ) )
    4962           0 :                 bFound = sal_True;
    4963             :         }
    4964             : 
    4965          94 :         if (bFound)         // valid only if within this object's range
    4966             :         {
    4967          94 :             if (!aRange.In(aCellRange))
    4968           0 :                 bFound = false;
    4969             :         }
    4970             : 
    4971          94 :         if (bFound)
    4972             :         {
    4973          94 :             if ( aCellRange.aStart == aCellRange.aEnd )
    4974           4 :                 return new ScCellObj( pDocSh, aCellRange.aStart );
    4975             :             else
    4976          90 :                 return new ScCellRangeObj( pDocSh, aCellRange );
    4977           0 :         }
    4978             :     }
    4979             : 
    4980          94 :     throw uno::RuntimeException();
    4981             : }
    4982             : 
    4983             : // XColumnRowRange
    4984             : 
    4985         563 : uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException, std::exception)
    4986             : {
    4987         563 :     SolarMutexGuard aGuard;
    4988         563 :     ScDocShell* pDocSh = GetDocShell();
    4989         563 :     if (pDocSh)
    4990         563 :         return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
    4991         563 :                                         aRange.aStart.Col(), aRange.aEnd.Col() );
    4992             : 
    4993             :     OSL_FAIL("Dokument ungueltig");
    4994           0 :     return NULL;
    4995             : }
    4996             : 
    4997        2918 : uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException, std::exception)
    4998             : {
    4999        2918 :     SolarMutexGuard aGuard;
    5000        2918 :     ScDocShell* pDocSh = GetDocShell();
    5001        2918 :     if (pDocSh)
    5002        2918 :         return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
    5003        2918 :                                     aRange.aStart.Row(), aRange.aEnd.Row() );
    5004             : 
    5005             :     OSL_FAIL("Dokument ungueltig");
    5006           0 :     return NULL;
    5007             : }
    5008             : 
    5009             : // XAddressableCellRange
    5010             : 
    5011        5689 : table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException, std::exception)
    5012             : {
    5013        5689 :     SolarMutexGuard aGuard;
    5014        5689 :     table::CellRangeAddress aRet;
    5015        5689 :     ScUnoConversion::FillApiRange( aRet, aRange );
    5016        5689 :     return aRet;
    5017             : }
    5018             : 
    5019             : // XSheetCellRange
    5020             : 
    5021        1064 : uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
    5022             :                                                 throw(uno::RuntimeException, std::exception)
    5023             : {
    5024        1064 :     SolarMutexGuard aGuard;
    5025        1064 :     ScDocShell* pDocSh = GetDocShell();
    5026        1064 :     if (pDocSh)
    5027        1064 :         return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
    5028             : 
    5029             :     OSL_FAIL("Dokument ungueltig");
    5030           0 :     return NULL;
    5031             : }
    5032             : 
    5033             : // XArrayFormulaRange
    5034             : 
    5035           2 : OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException, std::exception)
    5036             : {
    5037           2 :     SolarMutexGuard aGuard;
    5038             : 
    5039             :     //  Matrix-Formel, wenn eindeutig Teil einer Matrix,
    5040             :     //  also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
    5041             :     //  Sonst Leerstring.
    5042             : 
    5043           2 :     ScDocShell* pDocSh = GetDocShell();
    5044           2 :     if (!pDocSh)
    5045           0 :         return EMPTY_OUSTRING;
    5046             : 
    5047           4 :     OUString aFormula;
    5048             : 
    5049           2 :     ScDocument* pDoc = pDocSh->GetDocument();
    5050           4 :     ScRefCellValue aCell1;
    5051           4 :     ScRefCellValue aCell2;
    5052           2 :     aCell1.assign(*pDoc, aRange.aStart);
    5053           2 :     aCell2.assign(*pDoc, aRange.aEnd);
    5054           2 :     if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
    5055             :     {
    5056           1 :         const ScFormulaCell* pFCell1 = aCell1.mpFormula;
    5057           1 :         const ScFormulaCell* pFCell2 = aCell2.mpFormula;
    5058           1 :         ScAddress aStart1;
    5059           1 :         ScAddress aStart2;
    5060           1 :         if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
    5061             :         {
    5062           1 :             if (aStart1 == aStart2)               // beides dieselbe Matrix
    5063           1 :                 pFCell1->GetFormula(aFormula);    // egal, von welcher Zelle
    5064             :         }
    5065             :     }
    5066           4 :     return aFormula;
    5067             : }
    5068             : 
    5069           1 : void ScCellRangeObj::SetArrayFormula_Impl( const OUString& rFormula,
    5070             :         const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
    5071             : {
    5072           1 :     ScDocShell* pDocSh = GetDocShell();
    5073           1 :     if (pDocSh)
    5074             :     {
    5075           1 :         if ( !rFormula.isEmpty() )
    5076             :         {
    5077           1 :             if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5078             :             {
    5079             :                 //  don't set array formula for sheet object
    5080           0 :                 throw uno::RuntimeException();
    5081             :             }
    5082             : 
    5083           1 :             pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, NULL, rFormula, true, true, rFormulaNmsp, eGrammar );
    5084             :         }
    5085             :         else
    5086             :         {
    5087             :             //  empty string -> erase array formula
    5088           0 :             ScMarkData aMark;
    5089           0 :             aMark.SetMarkArea( aRange );
    5090           0 :             aMark.SelectTable( aRange.aStart.Tab(), true );
    5091           0 :             pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
    5092             :         }
    5093             :     }
    5094           1 : }
    5095             : 
    5096           1 : void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula )
    5097             :                                                 throw(uno::RuntimeException, std::exception)
    5098             : {
    5099           1 :     SolarMutexGuard aGuard;
    5100             :     // GRAM_PODF_A1 for API compatibility.
    5101           1 :     SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
    5102           1 : }
    5103             : 
    5104           0 : void ScCellRangeObj::SetArrayFormulaWithGrammar( const OUString& rFormula,
    5105             :         const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
    5106             : {
    5107           0 :     SolarMutexGuard aGuard;
    5108           0 :     SetArrayFormula_Impl( rFormula, rFormulaNmsp, eGrammar);
    5109           0 : }
    5110             : 
    5111             : // XArrayFormulaTokens
    5112             : 
    5113           0 : uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens()
    5114             :     throw (uno::RuntimeException, std::exception)
    5115             : {
    5116           0 :     SolarMutexGuard aGuard;
    5117             : 
    5118             :     // same cell logic as in getArrayFormula
    5119             : 
    5120           0 :     uno::Sequence<sheet::FormulaToken> aSequence;
    5121           0 :     ScDocShell* pDocSh = GetDocShell();
    5122           0 :     if (!pDocSh)
    5123           0 :         return aSequence;
    5124             : 
    5125           0 :     ScDocument* pDoc = pDocSh->GetDocument();
    5126           0 :     ScRefCellValue aCell1;
    5127           0 :     ScRefCellValue aCell2;
    5128           0 :     aCell1.assign(*pDoc, aRange.aStart);
    5129           0 :     aCell2.assign(*pDoc, aRange.aEnd);
    5130           0 :     if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
    5131             :     {
    5132           0 :         const ScFormulaCell* pFCell1 = aCell1.mpFormula;
    5133           0 :         const ScFormulaCell* pFCell2 = aCell2.mpFormula;
    5134           0 :         ScAddress aStart1;
    5135           0 :         ScAddress aStart2;
    5136           0 :         if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
    5137             :         {
    5138           0 :             if (aStart1 == aStart2)
    5139             :             {
    5140           0 :                 const ScTokenArray* pTokenArray = pFCell1->GetCode();
    5141           0 :                 if (pTokenArray)
    5142           0 :                     (void)ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
    5143             :             }
    5144             :         }
    5145             :     }
    5146             : 
    5147           0 :     return aSequence;
    5148             : }
    5149             : 
    5150           0 : void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
    5151             : {
    5152           0 :     SolarMutexGuard aGuard;
    5153           0 :     ScDocShell* pDocSh = GetDocShell();
    5154           0 :     if ( pDocSh )
    5155             :     {
    5156           0 :         if ( rTokens.getLength() )
    5157             :         {
    5158           0 :             if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5159             :             {
    5160           0 :                 throw uno::RuntimeException();
    5161             :             }
    5162             : 
    5163           0 :             ScDocument* pDoc = pDocSh->GetDocument();
    5164           0 :             ScTokenArray aTokenArray;
    5165           0 :             (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
    5166             : 
    5167             :             // Actually GRAM_PODF_A1 is a don't-care here because of the token
    5168             :             // array being set, it fits with other API compatibility grammars
    5169             :             // though.
    5170           0 :             pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_OUSTRING, true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 );
    5171             :         }
    5172             :         else
    5173             :         {
    5174             :             //  empty sequence -> erase array formula
    5175           0 :             ScMarkData aMark;
    5176           0 :             aMark.SetMarkArea( aRange );
    5177           0 :             aMark.SelectTable( aRange.aStart.Tab(), true );
    5178           0 :             pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
    5179             :         }
    5180           0 :     }
    5181           0 : }
    5182             : 
    5183             : // XCellRangeData
    5184             : 
    5185          17 : uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
    5186             :                                     throw(uno::RuntimeException, std::exception)
    5187             : {
    5188          17 :     SolarMutexGuard aGuard;
    5189             : 
    5190          17 :     if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5191             :     {
    5192             :         //  don't create a data array for the sheet
    5193           0 :         throw uno::RuntimeException();
    5194             :     }
    5195             : 
    5196          17 :     ScDocShell* pDocSh = GetDocShell();
    5197          17 :     if (pDocSh)
    5198             :     {
    5199          17 :         uno::Any aAny;
    5200             :         // bAllowNV = TRUE: errors as void
    5201          17 :         if ( ScRangeToSequence::FillMixedArray( aAny, pDocSh->GetDocument(), aRange, true ) )
    5202             :         {
    5203          17 :             uno::Sequence< uno::Sequence<uno::Any> > aSeq;
    5204          17 :             if ( aAny >>= aSeq )
    5205          34 :                 return aSeq;            // success
    5206           0 :         }
    5207             :     }
    5208             : 
    5209          17 :     throw uno::RuntimeException();      // no other exceptions specified
    5210             : }
    5211             : 
    5212           8 : void SAL_CALL ScCellRangeObj::setDataArray(
    5213             :                         const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
    5214             :                                     throw(uno::RuntimeException, std::exception)
    5215             : {
    5216           8 :     SolarMutexGuard aGuard;
    5217             : 
    5218           8 :     sal_Bool bDone = false;
    5219           8 :     ScDocShell* pDocSh = GetDocShell();
    5220           8 :     if (pDocSh)
    5221             :     {
    5222             :         //! move lcl_PutDataArray to docfunc?
    5223           8 :         bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
    5224             :     }
    5225             : 
    5226           8 :     if (!bDone)
    5227           0 :         throw uno::RuntimeException();      // no other exceptions specified
    5228           8 : }
    5229             : 
    5230             : // XCellRangeFormula
    5231             : 
    5232           5 : uno::Sequence< uno::Sequence<OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
    5233             :                                     throw(uno::RuntimeException, std::exception)
    5234             : {
    5235           5 :     SolarMutexGuard aGuard;
    5236             : 
    5237           5 :     if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5238             :     {
    5239             :         //  don't create a data array for the sheet
    5240           0 :         throw uno::RuntimeException();
    5241             :     }
    5242             : 
    5243           5 :     ScDocShell* pDocSh = GetDocShell();
    5244           5 :     if (pDocSh)
    5245             :     {
    5246           5 :         SCCOL nStartCol = aRange.aStart.Col();
    5247           5 :         SCROW nStartRow = aRange.aStart.Row();
    5248           5 :         SCCOL nEndCol = aRange.aEnd.Col();
    5249           5 :         SCROW nEndRow = aRange.aEnd.Row();
    5250           5 :         SCCOL nColCount = nEndCol + 1 - nStartCol;
    5251           5 :         SCROW nRowCount = nEndRow + 1 - nStartRow;
    5252           5 :         SCTAB nTab = aRange.aStart.Tab();
    5253             : 
    5254           5 :         uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount );
    5255           5 :         uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
    5256          30 :         for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
    5257             :         {
    5258          25 :             uno::Sequence<OUString> aColSeq( nColCount );
    5259          25 :             OUString* pColAry = aColSeq.getArray();
    5260         120 :             for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
    5261         190 :                 pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
    5262          95 :                                     ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), sal_True );
    5263             : 
    5264          25 :             pRowAry[nRowIndex] = aColSeq;
    5265          25 :         }
    5266             : 
    5267          10 :         return aRowSeq;
    5268             :     }
    5269             : 
    5270           5 :     throw uno::RuntimeException();      // no other exceptions specified
    5271             : }
    5272             : 
    5273           2 : void SAL_CALL ScCellRangeObj::setFormulaArray(
    5274             :                         const uno::Sequence< uno::Sequence<OUString> >& aArray )
    5275             :                                     throw(uno::RuntimeException, std::exception)
    5276             : {
    5277           2 :     SolarMutexGuard aGuard;
    5278             : 
    5279           2 :     sal_Bool bDone = false;
    5280           2 :     ScDocShell* pDocSh = GetDocShell();
    5281           2 :     if (pDocSh)
    5282             :     {
    5283           2 :         ScExternalRefManager::ApiGuard aExtRefGuard(pDocSh->GetDocument());
    5284             : 
    5285             :         // GRAM_PODF_A1 for API compatibility.
    5286           2 :         bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_PODF_A1 );
    5287             :     }
    5288             : 
    5289           2 :     if (!bDone)
    5290           0 :         throw uno::RuntimeException();      // no other exceptions specified
    5291           2 : }
    5292             : 
    5293             : // XMultipleOperation
    5294             : 
    5295           3 : void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
    5296             :                                         sheet::TableOperationMode nMode,
    5297             :                                         const table::CellAddress& aColumnCell,
    5298             :                                         const table::CellAddress& aRowCell )
    5299             :                                     throw(uno::RuntimeException, std::exception)
    5300             : {
    5301           3 :     SolarMutexGuard aGuard;
    5302           3 :     ScDocShell* pDocSh = GetDocShell();
    5303           3 :     if (pDocSh)
    5304             :     {
    5305           3 :         bool bError = false;
    5306           3 :         ScTabOpParam aParam;
    5307           6 :         aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
    5308             :                                               (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
    5309           3 :                                               false, false, false );
    5310           6 :         aParam.aRefFormulaEnd  = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
    5311             :                                               (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
    5312           3 :                                               false, false, false );
    5313           6 :         aParam.aRefRowCell     = ScRefAddress( (SCCOL)aRowCell.Column,
    5314             :                                               (SCROW)aRowCell.Row, aRowCell.Sheet,
    5315           3 :                                               false, false, false );
    5316           6 :         aParam.aRefColCell     = ScRefAddress( (SCCOL)aColumnCell.Column,
    5317             :                                               (SCROW)aColumnCell.Row, aColumnCell.Sheet,
    5318           3 :                                               false, false, false );
    5319             : 
    5320           3 :         switch (nMode)
    5321             :         {
    5322             :             case sheet::TableOperationMode_COLUMN:
    5323           1 :                 aParam.meMode = ScTabOpParam::Column;
    5324           1 :                 break;
    5325             :             case sheet::TableOperationMode_ROW:
    5326           1 :                 aParam.meMode = ScTabOpParam::Row;
    5327           1 :                 break;
    5328             :             case sheet::TableOperationMode_BOTH:
    5329           1 :                 aParam.meMode = ScTabOpParam::Both;
    5330           1 :                 break;
    5331             :             default:
    5332           0 :                 bError = true;
    5333             :         }
    5334             : 
    5335           3 :         if (!bError)
    5336           3 :             pDocSh->GetDocFunc().TabOp( aRange, NULL, aParam, true, true );
    5337           3 :     }
    5338           3 : }
    5339             : 
    5340             : // XMergeable
    5341             : 
    5342          10 : void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException, std::exception)
    5343             : {
    5344          10 :     SolarMutexGuard aGuard;
    5345          10 :     ScDocShell* pDocSh = GetDocShell();
    5346          10 :     if ( pDocSh )
    5347             :     {
    5348             :         ScCellMergeOption aMergeOption(
    5349          10 :             aRange.aStart.Col(), aRange.aStart.Row(),
    5350          20 :             aRange.aEnd.Col(), aRange.aEnd.Row(), false);
    5351          10 :         aMergeOption.maTabs.insert(aRange.aStart.Tab());
    5352          10 :         if ( bMerge )
    5353           5 :             pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
    5354             :         else
    5355           5 :             pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true );
    5356             : 
    5357             :         //! Fehler abfangen?
    5358          10 :     }
    5359          10 : }
    5360             : 
    5361           4 : sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException, std::exception)
    5362             : {
    5363           4 :     SolarMutexGuard aGuard;
    5364           4 :     ScDocShell* pDocSh = GetDocShell();
    5365           4 :     return pDocSh && pDocSh->GetDocument()->HasAttrib( aRange, HASATTR_MERGED );
    5366             : }
    5367             : 
    5368             : // XCellSeries
    5369             : 
    5370          13 : void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
    5371             :                         sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
    5372             :                         double fStep, double fEndValue ) throw(uno::RuntimeException, std::exception)
    5373             : {
    5374          13 :     SolarMutexGuard aGuard;
    5375          13 :     ScDocShell* pDocSh = GetDocShell();
    5376          13 :     if ( pDocSh )
    5377             :     {
    5378          13 :         sal_Bool bError = false;
    5379             : 
    5380          13 :         FillDir eDir = FILL_TO_BOTTOM;
    5381          13 :         switch (nFillDirection)
    5382             :         {
    5383             :             case sheet::FillDirection_TO_BOTTOM:
    5384           4 :                 eDir = FILL_TO_BOTTOM;
    5385           4 :                 break;
    5386             :             case sheet::FillDirection_TO_RIGHT:
    5387           5 :                 eDir = FILL_TO_RIGHT;
    5388           5 :                 break;
    5389             :             case sheet::FillDirection_TO_TOP:
    5390           2 :                 eDir = FILL_TO_TOP;
    5391           2 :                 break;
    5392             :             case sheet::FillDirection_TO_LEFT:
    5393           2 :                 eDir = FILL_TO_LEFT;
    5394           2 :                 break;
    5395             :             default:
    5396           0 :                 bError = sal_True;
    5397             :         }
    5398             : 
    5399          13 :         FillCmd eCmd = FILL_SIMPLE;
    5400          13 :         switch ( nFillMode )
    5401             :         {
    5402             :             case sheet::FillMode_SIMPLE:
    5403           9 :                 eCmd = FILL_SIMPLE;
    5404           9 :                 break;
    5405             :             case sheet::FillMode_LINEAR:
    5406           2 :                 eCmd = FILL_LINEAR;
    5407           2 :                 break;
    5408             :             case sheet::FillMode_GROWTH:
    5409           2 :                 eCmd = FILL_GROWTH;
    5410           2 :                 break;
    5411             :             case sheet::FillMode_DATE:
    5412           0 :                 eCmd = FILL_DATE;
    5413           0 :                 break;
    5414             :             case sheet::FillMode_AUTO:
    5415           0 :                 eCmd = FILL_AUTO;
    5416           0 :                 break;
    5417             :             default:
    5418           0 :                 bError = sal_True;
    5419             :         }
    5420             : 
    5421          13 :         FillDateCmd eDateCmd = FILL_DAY;
    5422          13 :         switch ( nFillDateMode )
    5423             :         {
    5424             :             case sheet::FillDateMode_FILL_DATE_DAY:
    5425          13 :                 eDateCmd = FILL_DAY;
    5426          13 :                 break;
    5427             :             case sheet::FillDateMode_FILL_DATE_WEEKDAY:
    5428           0 :                 eDateCmd = FILL_WEEKDAY;
    5429           0 :                 break;
    5430             :             case sheet::FillDateMode_FILL_DATE_MONTH:
    5431           0 :                 eDateCmd = FILL_MONTH;
    5432           0 :                 break;
    5433             :             case sheet::FillDateMode_FILL_DATE_YEAR:
    5434           0 :                 eDateCmd = FILL_YEAR;
    5435           0 :                 break;
    5436             :             default:
    5437           0 :                 bError = sal_True;
    5438             :         }
    5439             : 
    5440          13 :         if (!bError)
    5441          13 :             pDocSh->GetDocFunc().FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
    5442          26 :                                                 MAXDOUBLE, fStep, fEndValue, true, true );
    5443          13 :     }
    5444          13 : }
    5445             : 
    5446           2 : void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
    5447             :                                 sal_Int32 nSourceCount ) throw(uno::RuntimeException, std::exception)
    5448             : {
    5449           2 :     SolarMutexGuard aGuard;
    5450           2 :     ScDocShell* pDocSh = GetDocShell();
    5451           2 :     if ( pDocSh && nSourceCount )
    5452             :     {
    5453           2 :         ScRange aSourceRange(aRange);
    5454           2 :         SCsCOLROW nCount = 0;                   // "Dest-Count"
    5455           2 :         FillDir eDir = FILL_TO_BOTTOM;
    5456           2 :         sal_Bool bError = false;
    5457           2 :         switch (nFillDirection)
    5458             :         {
    5459             :             case sheet::FillDirection_TO_BOTTOM:
    5460           1 :                 aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
    5461           1 :                 nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
    5462           1 :                 eDir = FILL_TO_BOTTOM;
    5463           1 :                 break;
    5464             :             case sheet::FillDirection_TO_RIGHT:
    5465           1 :                 aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
    5466           1 :                 nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
    5467           1 :                 eDir = FILL_TO_RIGHT;
    5468           1 :                 break;
    5469             :             case sheet::FillDirection_TO_TOP:
    5470           0 :                 aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
    5471           0 :                 nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
    5472           0 :                 eDir = FILL_TO_TOP;
    5473           0 :                 break;
    5474             :             case sheet::FillDirection_TO_LEFT:
    5475           0 :                 aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
    5476           0 :                 nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
    5477           0 :                 eDir = FILL_TO_LEFT;
    5478           0 :                 break;
    5479             :             default:
    5480           0 :                 bError = sal_True;
    5481             :         }
    5482           2 :         if (nCount < 0 || nCount > MAXROW)      // overflow
    5483           0 :             bError = sal_True;
    5484             : 
    5485           2 :         if (!bError)
    5486           2 :             pDocSh->GetDocFunc().FillAuto( aSourceRange, NULL, eDir, nCount, true, true );
    5487           2 :     }
    5488           2 : }
    5489             : 
    5490             : // XAutoFormattable
    5491             : 
    5492           0 : void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName )
    5493             :                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    5494             : {
    5495           0 :     SolarMutexGuard aGuard;
    5496           0 :     ScDocShell* pDocSh = GetDocShell();
    5497           0 :     if ( pDocSh )
    5498             :     {
    5499           0 :         ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
    5500           0 :         ScAutoFormat::const_iterator it = pAutoFormat->find(aName);
    5501           0 :         if (it != pAutoFormat->end())
    5502             :         {
    5503           0 :             ScAutoFormat::const_iterator itBeg = pAutoFormat->begin();
    5504           0 :             size_t nIndex = std::distance(itBeg, it);
    5505           0 :             pDocSh->GetDocFunc().AutoFormat(aRange, NULL, nIndex, true, true);
    5506             :         }
    5507             :         else
    5508           0 :             throw lang::IllegalArgumentException();
    5509           0 :     }
    5510           0 : }
    5511             : 
    5512             : // XSortable
    5513             : 
    5514           1 : uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
    5515             :                                                 throw(uno::RuntimeException, std::exception)
    5516             : {
    5517           1 :     SolarMutexGuard aGuard;
    5518           2 :     ScSortParam aParam;
    5519           1 :     ScDocShell* pDocSh = GetDocShell();
    5520           1 :     if ( pDocSh )
    5521             :     {
    5522             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5523           1 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5524           1 :         if (pData)
    5525             :         {
    5526           0 :             pData->GetSortParam(aParam);
    5527             : 
    5528             :             //  im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5529           0 :             ScRange aDBRange;
    5530           0 :             pData->GetArea(aDBRange);
    5531             :             SCCOLROW nFieldStart = aParam.bByRow ?
    5532           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
    5533           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Row());
    5534           0 :             for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
    5535           0 :                 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
    5536           0 :                     aParam.maKeyState[i].nField -= nFieldStart;
    5537             :         }
    5538             :     }
    5539             : 
    5540           1 :     uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
    5541           1 :     ScSortDescriptor::FillProperties( aSeq, aParam );
    5542           2 :     return aSeq;
    5543             : }
    5544             : 
    5545           4 : void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
    5546             :                                                 throw(uno::RuntimeException, std::exception)
    5547             : {
    5548           4 :     SolarMutexGuard aGuard;
    5549           4 :     ScDocShell* pDocSh = GetDocShell();
    5550           4 :     if (pDocSh)
    5551             :     {
    5552             :         sal_uInt16 i;
    5553           4 :         ScSortParam aParam;
    5554           4 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
    5555           4 :         if (pData)
    5556             :         {
    5557             :             //  alten Einstellungen holen, falls nicht alles neu gesetzt wird
    5558           4 :             pData->GetSortParam(aParam);
    5559             :             SCCOLROW nOldStart = aParam.bByRow ?
    5560           4 :                 static_cast<SCCOLROW>(aRange.aStart.Col()) :
    5561           8 :                 static_cast<SCCOLROW>(aRange.aStart.Row());
    5562          16 :             for (i=0; i<aParam.GetSortKeyCount(); i++)
    5563          12 :                 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nOldStart )
    5564           3 :                     aParam.maKeyState[i].nField -= nOldStart;
    5565             :         }
    5566             : 
    5567           4 :         ScSortDescriptor::FillSortParam( aParam, aDescriptor );
    5568             : 
    5569             :         //  im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5570             :         //  ByRow kann bei FillSortParam umgesetzt worden sein
    5571             :         SCCOLROW nFieldStart = aParam.bByRow ?
    5572           4 :             static_cast<SCCOLROW>(aRange.aStart.Col()) :
    5573           8 :             static_cast<SCCOLROW>(aRange.aStart.Row());
    5574          16 :         for (i=0; i<aParam.GetSortKeyCount(); i++)
    5575          12 :             aParam.maKeyState[i].nField += nFieldStart;
    5576             : 
    5577           4 :         SCTAB nTab = aRange.aStart.Tab();
    5578           4 :         aParam.nCol1 = aRange.aStart.Col();
    5579           4 :         aParam.nRow1 = aRange.aStart.Row();
    5580           4 :         aParam.nCol2 = aRange.aEnd.Col();
    5581           4 :         aParam.nRow2 = aRange.aEnd.Row();
    5582             : 
    5583           4 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );       // ggf. Bereich anlegen
    5584             : 
    5585           8 :         ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
    5586           8 :         aFunc.Sort( nTab, aParam, true, true, true );
    5587           4 :     }
    5588           4 : }
    5589             : 
    5590             : // XFilterable
    5591             : 
    5592           2 : uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
    5593             :                                 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
    5594             : {
    5595           2 :     SolarMutexGuard aGuard;
    5596           2 :     ScDocShell* pDocSh = GetDocShell();
    5597           2 :     ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
    5598           2 :     if ( !bEmpty && pDocSh )
    5599             :     {
    5600             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5601           0 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5602           0 :         if (pData)
    5603             :         {
    5604           0 :             ScQueryParam aParam;
    5605           0 :             pData->GetQueryParam(aParam);
    5606             :             //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5607           0 :             ScRange aDBRange;
    5608           0 :             pData->GetArea(aDBRange);
    5609             :             SCCOLROW nFieldStart = aParam.bByRow ?
    5610           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
    5611           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Row());
    5612           0 :             SCSIZE nCount = aParam.GetEntryCount();
    5613           0 :             for (SCSIZE i=0; i<nCount; i++)
    5614             :             {
    5615           0 :                 ScQueryEntry& rEntry = aParam.GetEntry(i);
    5616           0 :                 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
    5617           0 :                     rEntry.nField -= nFieldStart;
    5618             :             }
    5619           0 :             pNew->SetParam(aParam);
    5620             :         }
    5621             :     }
    5622           2 :     return pNew;
    5623             : }
    5624             : 
    5625           1 : void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
    5626             :                                                 throw(uno::RuntimeException, std::exception)
    5627             : {
    5628           1 :     SolarMutexGuard aGuard;
    5629             : 
    5630             :     //  das koennte theoretisch ein fremdes Objekt sein, also nur das
    5631             :     //  oeffentliche XSheetFilterDescriptor Interface benutzen, um
    5632             :     //  die Daten in ein ScFilterDescriptor Objekt zu kopieren:
    5633             :     //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
    5634             : 
    5635           1 :     ScDocShell* pDocSh = GetDocShell();
    5636           2 :     ScFilterDescriptor aImpl(pDocSh);
    5637           2 :     uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
    5638           1 :     if ( xDescriptor2.is() )
    5639             :     {
    5640           1 :         aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
    5641             :     }
    5642             :     else
    5643             :     {
    5644           0 :         aImpl.setFilterFields( xDescriptor->getFilterFields() );
    5645             :     }
    5646             :     //  Rest sind jetzt Properties...
    5647             : 
    5648           2 :     uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
    5649           1 :     if (xPropSet.is())
    5650           1 :         lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
    5651             : 
    5652             : 
    5653             :     //  ausfuehren...
    5654             : 
    5655             : 
    5656           1 :     if (pDocSh)
    5657             :     {
    5658           1 :         ScQueryParam aParam = aImpl.GetParam();
    5659             :         //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5660             :         SCCOLROW nFieldStart = aParam.bByRow ?
    5661           1 :             static_cast<SCCOLROW>(aRange.aStart.Col()) :
    5662           2 :             static_cast<SCCOLROW>(aRange.aStart.Row());
    5663           1 :         SCSIZE nCount = aParam.GetEntryCount();
    5664           1 :         svl::SharedStringPool& rPool = pDocSh->GetDocument()->GetSharedStringPool();
    5665           9 :         for (SCSIZE i=0; i<nCount; i++)
    5666             :         {
    5667           8 :             ScQueryEntry& rEntry = aParam.GetEntry(i);
    5668           8 :             if (rEntry.bDoQuery)
    5669             :             {
    5670           2 :                 rEntry.nField += nFieldStart;
    5671             :                 //  Im Dialog wird immer der String angezeigt -> muss zum Wert passen
    5672           2 :                 ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
    5673           2 :                 rItems.resize(1);
    5674           2 :                 ScQueryEntry::Item& rItem = rItems.front();
    5675           2 :                 if (rItem.meType != ScQueryEntry::ByString)
    5676             :                 {
    5677           1 :                     OUString aStr;
    5678           1 :                     pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
    5679           1 :                     rItem.maString = rPool.intern(aStr);
    5680             :                 }
    5681             :             }
    5682             :         }
    5683             : 
    5684           1 :         SCTAB nTab = aRange.aStart.Tab();
    5685           1 :         aParam.nCol1 = aRange.aStart.Col();
    5686           1 :         aParam.nRow1 = aRange.aStart.Row();
    5687           1 :         aParam.nCol2 = aRange.aEnd.Col();
    5688           1 :         aParam.nRow2 = aRange.aEnd.Row();
    5689             : 
    5690           1 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );   // ggf. Bereich anlegen
    5691             : 
    5692             :         //! keep source range in filter descriptor
    5693             :         //! if created by createFilterDescriptorByObject ???
    5694             : 
    5695           2 :         ScDBDocFunc aFunc(*pDocSh);
    5696           2 :         aFunc.Query( nTab, aParam, NULL, true, true );  // Bereich muss angelegt sein
    5697           1 :     }
    5698           1 : }
    5699             : 
    5700             : //! get/setAutoFilter als Properties!!!
    5701             : 
    5702             : // XAdvancedFilterSource
    5703             : 
    5704           1 : uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
    5705             :                         const uno::Reference<sheet::XSheetFilterable>& xObject )
    5706             :                                                 throw(uno::RuntimeException, std::exception)
    5707             : {
    5708           1 :     SolarMutexGuard aGuard;
    5709             : 
    5710             :     //  this ist hier nicht der Bereich, der gefiltert wird, sondern der
    5711             :     //  Bereich mit der Abfrage...
    5712             : 
    5713           2 :     uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
    5714             : 
    5715           1 :     ScDocShell* pDocSh = GetDocShell();
    5716           1 :     if ( pDocSh && xAddr.is() )
    5717             :     {
    5718             :         //! Test, ob xObject im selben Dokument ist
    5719             : 
    5720           1 :         ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);  //! stattdessen vom Objekt?
    5721             : 
    5722           1 :         ScQueryParam aParam = pNew->GetParam();
    5723           1 :         aParam.bHasHeader = true;
    5724             : 
    5725           1 :         table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
    5726           1 :         aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
    5727           1 :         aParam.nRow1 = (SCROW)aDataAddress.StartRow;
    5728           1 :         aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
    5729           1 :         aParam.nRow2 = (SCROW)aDataAddress.EndRow;
    5730           1 :         aParam.nTab  = aDataAddress.Sheet;
    5731             : 
    5732           1 :         ScDocument* pDoc = pDocSh->GetDocument();
    5733             :         sal_Bool bOk = pDoc->CreateQueryParam(
    5734           1 :                             aRange.aStart.Col(), aRange.aStart.Row(),
    5735           1 :                             aRange.aEnd.Col(), aRange.aEnd.Row(),
    5736           3 :                             aRange.aStart.Tab(), aParam );
    5737           1 :         if ( bOk )
    5738             :         {
    5739             :             //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5740             :             SCCOLROW nFieldStart = aParam.bByRow ?
    5741             :                 static_cast<SCCOLROW>(aDataAddress.StartColumn) :
    5742           1 :                 static_cast<SCCOLROW>(aDataAddress.StartRow);
    5743           1 :             SCSIZE nCount = aParam.GetEntryCount();
    5744           9 :             for (SCSIZE i=0; i<nCount; i++)
    5745             :             {
    5746           8 :                 ScQueryEntry& rEntry = aParam.GetEntry(i);
    5747           8 :                 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
    5748           1 :                     rEntry.nField -= nFieldStart;
    5749             :             }
    5750             : 
    5751           1 :             pNew->SetParam( aParam );
    5752           1 :             return pNew;
    5753             :         }
    5754             :         else
    5755             :         {
    5756           0 :             delete pNew;
    5757           0 :             return NULL;        // ungueltig -> null
    5758           1 :         }
    5759             :     }
    5760             : 
    5761             :     OSL_FAIL("kein Dokument oder kein Bereich");
    5762           1 :     return NULL;
    5763             : }
    5764             : 
    5765             : // XSubTotalSource
    5766             : 
    5767           6 : uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
    5768             :                                 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
    5769             : {
    5770           6 :     SolarMutexGuard aGuard;
    5771           6 :     ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
    5772           6 :     ScDocShell* pDocSh = GetDocShell();
    5773           6 :     if ( !bEmpty && pDocSh )
    5774             :     {
    5775             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5776           0 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5777           0 :         if (pData)
    5778             :         {
    5779           0 :             ScSubTotalParam aParam;
    5780           0 :             pData->GetSubTotalParam(aParam);
    5781             :             //  im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5782           0 :             ScRange aDBRange;
    5783           0 :             pData->GetArea(aDBRange);
    5784           0 :             SCCOL nFieldStart = aDBRange.aStart.Col();
    5785           0 :             for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
    5786             :             {
    5787           0 :                 if ( aParam.bGroupActive[i] )
    5788             :                 {
    5789           0 :                     if ( aParam.nField[i] >= nFieldStart )
    5790           0 :                         aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
    5791           0 :                     for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
    5792           0 :                         if ( aParam.pSubTotals[i][j] >= nFieldStart )
    5793           0 :                             aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
    5794             :                 }
    5795             :             }
    5796           0 :             pNew->SetParam(aParam);
    5797             :         }
    5798             :     }
    5799           6 :     return pNew;
    5800             : }
    5801             : 
    5802           1 : void SAL_CALL ScCellRangeObj::applySubTotals(
    5803             :     const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
    5804             :     sal_Bool bReplace)
    5805             :     throw (uno::RuntimeException, std::exception)
    5806             : {
    5807           1 :     SolarMutexGuard aGuard;
    5808             : 
    5809           2 :     if (!xDescriptor.is()) return;
    5810             : 
    5811           1 :     ScDocShell* pDocSh = GetDocShell();
    5812             :     ScSubTotalDescriptorBase* pImp =
    5813           1 :         ScSubTotalDescriptorBase::getImplementation( xDescriptor );
    5814             : 
    5815           1 :     if (pDocSh && pImp)
    5816             :     {
    5817           1 :         ScSubTotalParam aParam;
    5818           1 :         pImp->GetData(aParam);      // virtuelle Methode der Basisklasse
    5819             : 
    5820             :         //  im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5821           1 :         SCCOL nFieldStart = aRange.aStart.Col();
    5822           4 :         for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
    5823             :         {
    5824           3 :             if ( aParam.bGroupActive[i] )
    5825             :             {
    5826           1 :                 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
    5827           2 :                 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
    5828           1 :                     aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
    5829             :             }
    5830             :         }
    5831             : 
    5832           1 :         aParam.bReplace = bReplace;
    5833             : 
    5834           1 :         SCTAB nTab = aRange.aStart.Tab();
    5835           1 :         aParam.nCol1 = aRange.aStart.Col();
    5836           1 :         aParam.nRow1 = aRange.aStart.Row();
    5837           1 :         aParam.nCol2 = aRange.aEnd.Col();
    5838           1 :         aParam.nRow2 = aRange.aEnd.Row();
    5839             : 
    5840           1 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );   // ggf. Bereich anlegen
    5841             : 
    5842           1 :         ScDBDocFunc aFunc(*pDocSh);
    5843           1 :         aFunc.DoSubTotals( nTab, aParam, NULL, true, true );    // Bereich muss angelegt sein
    5844           1 :     }
    5845             : }
    5846             : 
    5847           1 : void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException, std::exception)
    5848             : {
    5849           1 :     SolarMutexGuard aGuard;
    5850             : 
    5851           1 :     ScDocShell* pDocSh = GetDocShell();
    5852           1 :     if (pDocSh)
    5853             :     {
    5854           1 :         ScSubTotalParam aParam;
    5855           1 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5856           1 :         if (pData)
    5857           0 :             pData->GetSubTotalParam(aParam);    // auch bei Remove die Feld-Eintraege behalten
    5858             : 
    5859           1 :         aParam.bRemoveOnly = true;
    5860             : 
    5861           1 :         SCTAB nTab = aRange.aStart.Tab();
    5862           1 :         aParam.nCol1 = aRange.aStart.Col();
    5863           1 :         aParam.nRow1 = aRange.aStart.Row();
    5864           1 :         aParam.nCol2 = aRange.aEnd.Col();
    5865           1 :         aParam.nRow2 = aRange.aEnd.Row();
    5866             : 
    5867           1 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );   // ggf. Bereich anlegen
    5868             : 
    5869           1 :         ScDBDocFunc aFunc(*pDocSh);
    5870           1 :         aFunc.DoSubTotals( nTab, aParam, NULL, true, true );    // Bereich muss angelegt sein
    5871           1 :     }
    5872           1 : }
    5873             : 
    5874           4 : uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
    5875             :                                                 throw(uno::RuntimeException, std::exception)
    5876             : {
    5877           4 :     SolarMutexGuard aGuard;
    5878           8 :     ScImportParam aParam;
    5879           4 :     ScDocShell* pDocSh = GetDocShell();
    5880           4 :     if ( !bEmpty && pDocSh )
    5881             :     {
    5882             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5883           3 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5884           3 :         if (pData)
    5885           0 :             pData->GetImportParam(aParam);
    5886             :     }
    5887             : 
    5888           4 :     uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
    5889           4 :     ScImportDescriptor::FillProperties( aSeq, aParam );
    5890           8 :     return aSeq;
    5891             : }
    5892             : 
    5893           4 : void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
    5894             :                                             throw(uno::RuntimeException, std::exception)
    5895             : {
    5896           4 :     SolarMutexGuard aGuard;
    5897           4 :     ScDocShell* pDocSh = GetDocShell();
    5898           4 :     if (pDocSh)
    5899             :     {
    5900           4 :         ScImportParam aParam;
    5901           4 :         ScImportDescriptor::FillImportParam( aParam, aDescriptor );
    5902             : 
    5903           4 :         SCTAB nTab = aRange.aStart.Tab();
    5904           4 :         aParam.nCol1 = aRange.aStart.Col();
    5905           4 :         aParam.nRow1 = aRange.aStart.Row();
    5906           4 :         aParam.nCol2 = aRange.aEnd.Col();
    5907           4 :         aParam.nRow2 = aRange.aEnd.Row();
    5908             : 
    5909             :         //! TODO: could we get passed a valid result set by any means?
    5910             : 
    5911           4 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );       // ggf. Bereich anlegen
    5912             : 
    5913           8 :         ScDBDocFunc aFunc(*pDocSh);                         // Bereich muss angelegt sein
    5914           8 :         aFunc.DoImport( nTab, aParam, NULL, true );         //! Api-Flag as parameter
    5915           4 :     }
    5916           4 : }
    5917             : 
    5918             : // XCellFormatRangesSupplier
    5919             : 
    5920           3 : uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
    5921             :                                                 throw(uno::RuntimeException, std::exception)
    5922             : {
    5923           3 :     SolarMutexGuard aGuard;
    5924           3 :     ScDocShell* pDocSh = GetDocShell();
    5925           3 :     if ( pDocSh )
    5926           3 :         return new ScCellFormatsObj( pDocSh, aRange );
    5927           0 :     return NULL;
    5928             : }
    5929             : 
    5930             : // XUniqueCellFormatRangesSupplier
    5931             : 
    5932          25 : uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
    5933             :                                                 throw(uno::RuntimeException, std::exception)
    5934             : {
    5935          25 :     SolarMutexGuard aGuard;
    5936          25 :     ScDocShell* pDocSh = GetDocShell();
    5937          25 :     if ( pDocSh )
    5938          25 :         return new ScUniqueCellFormatsObj( pDocSh, aRange );
    5939           0 :     return NULL;
    5940             : }
    5941             : 
    5942             : // XPropertySet erweitert fuer Range-Properties
    5943             : 
    5944         344 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
    5945             :                                                         throw(uno::RuntimeException, std::exception)
    5946             : {
    5947         344 :     SolarMutexGuard aGuard;
    5948             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    5949         344 :         new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
    5950         344 :     return aRef;
    5951             : }
    5952             : 
    5953         409 : void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    5954             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    5955             : {
    5956             :     //  Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
    5957             :     //  -> nothing to do here
    5958             : 
    5959         409 :     ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
    5960         408 : }
    5961             : 
    5962        9512 : void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    5963             :     throw(uno::RuntimeException, std::exception)
    5964             : {
    5965        9512 :     if ( pEntry )
    5966             :     {
    5967        9512 :         if ( pEntry->nWID == SC_WID_UNO_POS )
    5968             :         {
    5969         235 :             ScDocShell* pDocSh = GetDocShell();
    5970         235 :             if (pDocSh)
    5971             :             {
    5972             :                 //  GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
    5973             :                 Rectangle aMMRect(pDocSh->GetDocument()->GetMMRect(
    5974         235 :                                         aRange.aStart.Col(), aRange.aStart.Row(),
    5975         470 :                                         aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
    5976         235 :                 awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
    5977         235 :                 rAny <<= aPos;
    5978             :             }
    5979             :         }
    5980        9277 :         else if ( pEntry->nWID == SC_WID_UNO_SIZE )
    5981             :         {
    5982         148 :             ScDocShell* pDocSh = GetDocShell();
    5983         148 :             if (pDocSh)
    5984             :             {
    5985             :                 //  GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
    5986             :                 Rectangle aMMRect = pDocSh->GetDocument()->GetMMRect(
    5987         148 :                                         aRange.aStart.Col(), aRange.aStart.Row(),
    5988         296 :                                         aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
    5989         148 :                 Size aSize(aMMRect.GetSize());
    5990         148 :                 awt::Size aAwtSize( aSize.Width(), aSize.Height() );
    5991         148 :                 rAny <<= aAwtSize;
    5992             :             }
    5993             :         }
    5994             :         else
    5995        9129 :             ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
    5996             :     }
    5997        9512 : }
    5998             : 
    5999        1616 : const SfxItemPropertyMap& ScCellRangeObj::GetItemPropertyMap()
    6000             : {
    6001        1616 :     return pRangePropSet->getPropertyMap();
    6002             : }
    6003             : 
    6004             : // XServiceInfo
    6005             : 
    6006           6 : OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    6007             : {
    6008           6 :     return OUString( "ScCellRangeObj" );
    6009             : }
    6010             : 
    6011          10 : sal_Bool SAL_CALL ScCellRangeObj::supportsService( const OUString& rServiceName )
    6012             :                                                     throw(uno::RuntimeException, std::exception)
    6013             : {
    6014          10 :     return cppu::supportsService(this, rServiceName);
    6015             : }
    6016             : 
    6017          10 : uno::Sequence<OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
    6018             :                                                     throw(uno::RuntimeException, std::exception)
    6019             : {
    6020          10 :     uno::Sequence<OUString> aRet(5);
    6021          10 :     OUString* pArray = aRet.getArray();
    6022          10 :     pArray[0] = OUString( SCSHEETCELLRANGE_SERVICE );
    6023          10 :     pArray[1] = OUString( SCCELLRANGE_SERVICE );
    6024          10 :     pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
    6025          10 :     pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
    6026          10 :     pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
    6027          10 :     return aRet;
    6028             : }
    6029             : 
    6030          10 : const SvxItemPropertySet* ScCellObj::GetEditPropertySet()
    6031             : {
    6032          10 :     return lcl_GetEditPropertySet();
    6033             : }
    6034             : 
    6035           0 : const SfxItemPropertyMap& ScCellObj::GetCellPropertyMap()
    6036             : {
    6037           0 :     return lcl_GetCellPropertySet()->getPropertyMap();
    6038             : }
    6039             : 
    6040       12584 : ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
    6041             :     ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
    6042       12584 :     pCellPropSet( lcl_GetCellPropertySet() ),
    6043             :     aCellPos( rP ),
    6044       25168 :     nActionLockCount( 0 )
    6045             : {
    6046             :     //  pUnoText is allocated on demand (GetUnoText)
    6047             :     //  can't be aggregated because getString/setString is handled here
    6048       12584 : }
    6049             : 
    6050          23 : SvxUnoText& ScCellObj::GetUnoText()
    6051             : {
    6052          23 :     if (!mxUnoText.is())
    6053             :     {
    6054          10 :         mxUnoText.set(new ScCellTextObj(GetDocShell(), aCellPos));
    6055          10 :         if (nActionLockCount)
    6056             :         {
    6057             :             ScCellEditSource* pEditSource =
    6058           0 :                 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6059           0 :             if (pEditSource)
    6060           0 :                 pEditSource->SetDoUpdateData(false);
    6061             :         }
    6062             :     }
    6063          23 :     return *mxUnoText;
    6064             : }
    6065             : 
    6066       25120 : ScCellObj::~ScCellObj()
    6067             : {
    6068       25120 : }
    6069             : 
    6070        1732 : void ScCellObj::RefChanged()
    6071             : {
    6072        1732 :     ScCellRangeObj::RefChanged();
    6073             : 
    6074        1732 :     const ScRangeList& rRanges = GetRangeList();
    6075             :     OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
    6076        1732 :     if ( !rRanges.empty() )
    6077             :     {
    6078        1710 :         const ScRange* pFirst = rRanges[ 0 ];
    6079        1710 :         aCellPos = pFirst->aStart;
    6080             :     }
    6081        1732 : }
    6082             : 
    6083       33182 : uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    6084             : {
    6085       33182 :     SC_QUERYINTERFACE( table::XCell )
    6086       25430 :     SC_QUERYINTERFACE( table::XCell2 )
    6087       25430 :     SC_QUERYINTERFACE( sheet::XFormulaTokens )
    6088       25430 :     SC_QUERYINTERFACE( sheet::XCellAddressable )
    6089       23974 :     SC_QUERYINTERFACE( text::XText )
    6090       23965 :     SC_QUERYINTERFACE( text::XSimpleText )
    6091       23874 :     SC_QUERYINTERFACE( text::XTextRange )
    6092       23706 :     SC_QUERYINTERFACE( container::XEnumerationAccess )
    6093       23704 :     SC_QUERYINTERFACE( container::XElementAccess )
    6094       23702 :     SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
    6095       23695 :     SC_QUERYINTERFACE( text::XTextFieldsSupplier )
    6096       23692 :     SC_QUERYINTERFACE( document::XActionLockable )
    6097             : 
    6098       23691 :     return ScCellRangeObj::queryInterface( rType );
    6099             : }
    6100             : 
    6101       94701 : void SAL_CALL ScCellObj::acquire() throw()
    6102             : {
    6103       94701 :     ScCellRangeObj::acquire();
    6104       94701 : }
    6105             : 
    6106       94677 : void SAL_CALL ScCellObj::release() throw()
    6107             : {
    6108       94677 :     ScCellRangeObj::release();
    6109       94677 : }
    6110             : 
    6111           2 : uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException, std::exception)
    6112             : {
    6113           2 :     static uno::Sequence<uno::Type> aTypes;
    6114           2 :     if ( aTypes.getLength() == 0 )
    6115             :     {
    6116           1 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
    6117           1 :         long nParentLen = aParentTypes.getLength();
    6118           1 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    6119             : 
    6120           1 :         aTypes.realloc( nParentLen + 9 );
    6121           1 :         uno::Type* pPtr = aTypes.getArray();
    6122           1 :         pPtr[nParentLen + 0] = getCppuType((const uno::Reference<table::XCell>*)0);
    6123           1 :         pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XCellAddressable>*)0);
    6124           1 :         pPtr[nParentLen + 2] = getCppuType((const uno::Reference<text::XText>*)0);
    6125           1 :         pPtr[nParentLen + 3] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
    6126           1 :         pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XSheetAnnotationAnchor>*)0);
    6127           1 :         pPtr[nParentLen + 5] = getCppuType((const uno::Reference<text::XTextFieldsSupplier>*)0);
    6128           1 :         pPtr[nParentLen + 6] = getCppuType((const uno::Reference<document::XActionLockable>*)0);
    6129           1 :         pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XFormulaTokens>*)0);
    6130           1 :         pPtr[nParentLen + 8] = getCppuType((const uno::Reference<table::XCell2>*)0);
    6131             : 
    6132          31 :         for (long i=0; i<nParentLen; i++)
    6133          31 :             pPtr[i] = pParentPtr[i];                // parent types first
    6134             :     }
    6135           2 :     return aTypes;
    6136             : }
    6137             : 
    6138           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException, std::exception)
    6139             : {
    6140           0 :     return css::uno::Sequence<sal_Int8>();
    6141             : }
    6142             : 
    6143             : //  Hilfsfunktionen
    6144             : 
    6145         131 : OUString ScCellObj::GetInputString_Impl(bool bEnglish) const      // fuer getFormula / FormulaLocal
    6146             : {
    6147         131 :     if (GetDocShell())
    6148         131 :         return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
    6149           0 :     return OUString();
    6150             : }
    6151             : 
    6152         243 : OUString ScCellObj::GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aCellPos)
    6153             : {
    6154         243 :     if (!pDoc)
    6155           0 :         return EMPTY_OUSTRING;
    6156             : 
    6157         243 :     ScRefCellValue aCell;
    6158         243 :     aCell.assign(*pDoc, aCellPos);
    6159             : 
    6160         243 :     if (aCell.isEmpty())
    6161          39 :         return EMPTY_OUSTRING;
    6162             : 
    6163         408 :     OUString aVal;
    6164             : 
    6165         204 :     if (aCell.meType == CELLTYPE_EDIT)
    6166             :     {
    6167             :         //  GetString an der EditCell macht Leerzeichen aus Umbruechen,
    6168             :         //  hier werden die Umbrueche aber gebraucht
    6169           1 :         const EditTextObject* pData = aCell.mpEditText;
    6170           1 :         if (pData)
    6171             :         {
    6172           1 :             EditEngine& rEngine = pDoc->GetEditEngine();
    6173           1 :             rEngine.SetText(*pData);
    6174           1 :             aVal = rEngine.GetText(LINEEND_LF);
    6175             :         }
    6176             :         //  Edit-Zellen auch nicht per NumberFormatter formatieren
    6177             :         //  (passend zur Ausgabe)
    6178             :     }
    6179             :     else
    6180             :     {
    6181             :         //  wie in GetString am Dokument (column)
    6182             :         Color* pColor;
    6183         203 :         sal_uLong nNumFmt = pDoc->GetNumberFormat( aCellPos );
    6184         203 :         aVal = ScCellFormat::GetString(*pDoc, aCellPos, nNumFmt, &pColor, *pDoc->GetFormatTable());
    6185             :     }
    6186         447 :     return aVal;
    6187             : }
    6188             : 
    6189         243 : OUString ScCellObj::GetOutputString_Impl() const
    6190             : {
    6191         243 :     ScDocShell* pDocSh = GetDocShell();
    6192         243 :     OUString aVal;
    6193         243 :     if ( pDocSh )
    6194         243 :         aVal = GetOutputString_Impl(pDocSh->GetDocument(), aCellPos);
    6195         243 :     return aVal;
    6196             : }
    6197             : 
    6198        2046 : void ScCellObj::SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish)
    6199             : {
    6200        2046 :     ScDocShell* pDocSh = GetDocShell();
    6201        2046 :     if ( pDocSh )
    6202             :     {
    6203             :         // GRAM_PODF_A1 for API compatibility.
    6204        2046 :         (void)pDocSh->GetDocFunc().SetCellText(
    6205        4092 :             aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_PODF_A1 );
    6206             :     }
    6207        2046 : }
    6208             : 
    6209        2471 : double ScCellObj::GetValue_Impl() const
    6210             : {
    6211        2471 :     ScDocShell* pDocSh = GetDocShell();
    6212        2471 :     if ( pDocSh )
    6213        2471 :         return pDocSh->GetDocument()->GetValue( aCellPos );
    6214             : 
    6215           0 :     return 0.0;
    6216             : }
    6217             : 
    6218        3555 : void ScCellObj::SetValue_Impl(double fValue)
    6219             : {
    6220        3555 :     ScDocShell* pDocSh = GetDocShell();
    6221        3555 :     if ( pDocSh )
    6222        3555 :         pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false);
    6223        3555 : }
    6224             : 
    6225             : // only for XML import
    6226             : 
    6227        1529 : void ScCellObj::InputEnglishString( const OUString& rText )
    6228             : {
    6229             :     // This is like a mixture of setFormula and property FormulaLocal:
    6230             :     // The cell's number format is checked for "text", a new cell format may be set,
    6231             :     // but all parsing is in English.
    6232             : 
    6233        1529 :     ScDocShell* pDocSh = GetDocShell();
    6234        1529 :     if (!pDocSh)
    6235           0 :         return;
    6236             : 
    6237        1529 :     OUString aString(rText);
    6238        1529 :     ScDocument* pDoc = pDocSh->GetDocument();
    6239        1529 :     SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
    6240        1529 :     sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos );
    6241        1529 :     if (pFormatter->GetType(nOldFormat) == NUMBERFORMAT_TEXT)
    6242             :     {
    6243           0 :         SetString_Impl(aString, false, false);      // text cell
    6244           0 :         return;
    6245             :     }
    6246             : 
    6247        1529 :     ScDocFunc &rFunc = pDocSh->GetDocFunc();
    6248             : 
    6249             :     ScInputStringType aRes =
    6250        3058 :         ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US);
    6251             : 
    6252        1529 :     if (aRes.meType != ScInputStringType::Unknown)
    6253             :     {
    6254         385 :         if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType)
    6255             :         {
    6256             :             // apply a format for the recognized type and the old format's language
    6257           1 :             sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType);
    6258           1 :             if (nNewFormat != nOldFormat)
    6259             :             {
    6260           0 :                 ScPatternAttr aPattern( pDoc->GetPool() );
    6261           0 :                 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
    6262             :                 // ATTR_LANGUAGE_FORMAT remains unchanged
    6263           0 :                 rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true );
    6264             :             }
    6265             :         }
    6266             :     }
    6267        1529 :     switch (aRes.meType)
    6268             :     {
    6269             :         case ScInputStringType::Formula:
    6270             :             rFunc.SetFormulaCell(
    6271             :                 aCellPos,
    6272           1 :                 new ScFormulaCell(pDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1),
    6273           2 :                 false);
    6274           1 :         break;
    6275             :         case ScInputStringType::Number:
    6276           1 :             rFunc.SetValueCell(aCellPos, aRes.mfValue, false);
    6277           1 :         break;
    6278             :         case ScInputStringType::Text:
    6279         383 :             rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false);
    6280         383 :         break;
    6281             :         default:
    6282        1144 :             SetString_Impl(aString, false, false); // probably empty string
    6283        1529 :     }
    6284             : }
    6285             : 
    6286             : //  XText
    6287             : 
    6288          12 : uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
    6289             :                                                     throw(uno::RuntimeException, std::exception)
    6290             : {
    6291          12 :     SolarMutexGuard aGuard;
    6292          12 :     return new ScCellTextCursor( *this );
    6293             : }
    6294             : 
    6295           1 : uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
    6296             :                                     const uno::Reference<text::XTextRange>& aTextPosition )
    6297             :                                                     throw(uno::RuntimeException, std::exception)
    6298             : {
    6299           1 :     SolarMutexGuard aGuard;
    6300           1 :     SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
    6301           1 :     uno::Reference<text::XTextCursor> xCursor(pCursor);
    6302             : 
    6303           1 :     SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
    6304           1 :     if(pRange)
    6305           1 :         pCursor->SetSelection( pRange->GetSelection() );
    6306             :     else
    6307             :     {
    6308           0 :         ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
    6309           0 :         if(pOther)
    6310           0 :             pCursor->SetSelection( pOther->GetSelection() );
    6311             :         else
    6312           0 :             throw uno::RuntimeException();
    6313             :     }
    6314             : 
    6315           1 :     return xCursor;
    6316             : }
    6317             : 
    6318         243 : OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException, std::exception)
    6319             : {
    6320         243 :     SolarMutexGuard aGuard;
    6321         243 :     return GetOutputString_Impl();
    6322             : }
    6323             : 
    6324          34 : void SAL_CALL ScCellObj::setString( const OUString& aText ) throw(uno::RuntimeException, std::exception)
    6325             : {
    6326          34 :     SolarMutexGuard aGuard;
    6327          68 :     OUString aString(aText);
    6328          34 :     SetString_Impl(aString, false, false);  // immer Text
    6329             : 
    6330             :     // don't create pUnoText here if not there
    6331          34 :     if (mxUnoText.is())
    6332          40 :         mxUnoText->SetSelection(ESelection( 0,0, 0,aString.getLength() ));
    6333          34 : }
    6334             : 
    6335           2 : void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
    6336             :                                         const OUString& aString, sal_Bool bAbsorb )
    6337             :                                     throw(uno::RuntimeException, std::exception)
    6338             : {
    6339             :     // special handling for ScCellTextCursor is no longer needed,
    6340             :     // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
    6341             : 
    6342           2 :     SolarMutexGuard aGuard;
    6343           2 :     GetUnoText().insertString(xRange, aString, bAbsorb);
    6344           2 : }
    6345             : 
    6346           2 : void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
    6347             :                                                 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
    6348             :                                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    6349             : {
    6350           2 :     SolarMutexGuard aGuard;
    6351           2 :     GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
    6352           2 : }
    6353             : 
    6354           7 : void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
    6355             :                                                 const uno::Reference<text::XTextContent >& xContent,
    6356             :                                                 sal_Bool bAbsorb )
    6357             :                                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    6358             : {
    6359           7 :     SolarMutexGuard aGuard;
    6360           7 :     ScDocShell* pDocSh = GetDocShell();
    6361           7 :     if ( pDocSh && xContent.is() )
    6362             :     {
    6363           6 :         ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
    6364           6 :         SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
    6365             : 
    6366           6 :         if ( pCellField && !pCellField->IsInserted() && pTextRange )
    6367             :         {
    6368           6 :             SvxEditSource* pEditSource = pTextRange->GetEditSource();
    6369           6 :             ESelection aSelection(pTextRange->GetSelection());
    6370             : 
    6371           6 :             if (!bAbsorb)
    6372             :             {
    6373             :                 //  nicht ersetzen -> hinten anhaengen
    6374           2 :                 aSelection.Adjust();
    6375           2 :                 aSelection.nStartPara = aSelection.nEndPara;
    6376           2 :                 aSelection.nStartPos  = aSelection.nEndPos;
    6377             :             }
    6378             : 
    6379           6 :             if (pCellField->GetFieldType() == text::textfield::Type::TABLE)
    6380           0 :                 pCellField->setPropertyValue(SC_UNONAME_TABLEPOS, uno::makeAny<sal_Int32>(aCellPos.Tab()));
    6381             : 
    6382           6 :             SvxFieldItem aItem = pCellField->CreateFieldItem();
    6383           6 :             SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
    6384           6 :             pForwarder->QuickInsertField( aItem, aSelection );
    6385           6 :             pEditSource->UpdateData();
    6386             : 
    6387             :             //  neue Selektion: ein Zeichen
    6388           6 :             aSelection.Adjust();
    6389           6 :             aSelection.nEndPara = aSelection.nStartPara;
    6390           6 :             aSelection.nEndPos = aSelection.nStartPos + 1;
    6391          12 :             uno::Reference<text::XTextRange> xParent(this);
    6392             :             pCellField->InitDoc(
    6393           6 :                 xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
    6394             : 
    6395             :             //  for bAbsorb=FALSE, the new selection must be behind the inserted content
    6396             :             //  (the xml filter relies on this)
    6397           6 :             if (!bAbsorb)
    6398           2 :                 aSelection.nStartPos = aSelection.nEndPos;
    6399             : 
    6400           6 :             pTextRange->SetSelection( aSelection );
    6401             : 
    6402          18 :             return;
    6403             :         }
    6404             :     }
    6405           2 :     GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
    6406             : }
    6407             : 
    6408           1 : void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
    6409             :                                 throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
    6410             : {
    6411           1 :     SolarMutexGuard aGuard;
    6412           1 :     if ( xContent.is() )
    6413             :     {
    6414           1 :         ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
    6415           1 :         if ( pCellField && pCellField->IsInserted() )
    6416             :         {
    6417             :             //! Testen, ob das Feld in dieser Zelle ist
    6418           1 :             pCellField->DeleteField();
    6419           2 :             return;
    6420             :         }
    6421             :     }
    6422           0 :     GetUnoText().removeTextContent(xContent);
    6423             : }
    6424             : 
    6425           4 : uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException, std::exception)
    6426             : {
    6427           4 :     SolarMutexGuard aGuard;
    6428           4 :     return this;
    6429             : }
    6430             : 
    6431           1 : uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException, std::exception)
    6432             : {
    6433           1 :     SolarMutexGuard aGuard;
    6434           1 :     return GetUnoText().getStart();
    6435             : }
    6436             : 
    6437           1 : uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException, std::exception)
    6438             : {
    6439           1 :     SolarMutexGuard aGuard;
    6440           1 :     return GetUnoText().getEnd();
    6441             : }
    6442             : 
    6443           1 : uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
    6444             :                                                     throw(uno::RuntimeException, std::exception)
    6445             : {
    6446           1 :     SolarMutexGuard aGuard;
    6447           1 :     return GetUnoText().createEnumeration();
    6448             : }
    6449             : 
    6450           1 : uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException, std::exception)
    6451             : {
    6452           1 :     SolarMutexGuard aGuard;
    6453           1 :     return GetUnoText().getElementType();
    6454             : }
    6455             : 
    6456           1 : sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException, std::exception)
    6457             : {
    6458           1 :     SolarMutexGuard aGuard;
    6459           1 :     return GetUnoText().hasElements();
    6460             : }
    6461             : 
    6462             : //  XCell
    6463             : 
    6464         121 : OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException, std::exception)
    6465             : {
    6466         121 :     SolarMutexGuard aGuard;
    6467         121 :     return GetInputString_Impl( true /* English */ );
    6468             : }
    6469             : 
    6470         866 : void SAL_CALL ScCellObj::setFormula( const OUString& aFormula ) throw(uno::RuntimeException, std::exception)
    6471             : {
    6472         866 :     SolarMutexGuard aGuard;
    6473        1732 :     OUString aString(aFormula);
    6474        1732 :     SetString_Impl(aString, true, true); // Interpret as English
    6475         866 : }
    6476             : 
    6477        2471 : double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException, std::exception)
    6478             : {
    6479        2471 :     SolarMutexGuard aGuard;
    6480        2471 :     return GetValue_Impl();
    6481             : }
    6482             : 
    6483        3555 : void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException, std::exception)
    6484             : {
    6485        3555 :     SolarMutexGuard aGuard;
    6486        3555 :     SetValue_Impl(nValue);
    6487        3555 : }
    6488             : 
    6489           0 : void SAL_CALL ScCellObj::setFormulaString( const OUString& aFormula) throw(uno::RuntimeException, std::exception)
    6490             : {
    6491           0 :     SolarMutexGuard aGuard;
    6492           0 :     ScDocShell *pDocSh = GetDocShell();
    6493           0 :     if( pDocSh )
    6494             :     {
    6495           0 :         ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), aCellPos );
    6496           0 :         pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE );
    6497           0 :         pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false);
    6498           0 :     }
    6499           0 : }
    6500           0 : void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException, std::exception)
    6501             : {
    6502           0 :     SolarMutexGuard aGuard;
    6503           0 :     ScDocShell* pDocSh = GetDocShell();
    6504           0 :     if ( pDocSh && pDocSh->GetDocument()->GetCellType( aCellPos ) == CELLTYPE_FORMULA )
    6505             :     {
    6506           0 :         ScFormulaCell* pCell = pDocSh->GetDocument()->GetFormulaCell(aCellPos);
    6507           0 :         if (!pCell)
    6508           0 :             return;
    6509           0 :         pCell->SetHybridDouble( nValue );
    6510           0 :         pCell->ResetDirty();
    6511           0 :         pCell->SetChanged(false);
    6512           0 :     }
    6513             : }
    6514             : 
    6515        3866 : table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException, std::exception)
    6516             : {
    6517        3866 :     SolarMutexGuard aGuard;
    6518        3866 :     table::CellContentType eRet = table::CellContentType_EMPTY;
    6519        3866 :     ScDocShell* pDocSh = GetDocShell();
    6520        3866 :     if (pDocSh)
    6521             :     {
    6522        3866 :         CellType eCalcType = pDocSh->GetDocument()->GetCellType( aCellPos );
    6523        3866 :         switch (eCalcType)
    6524             :         {
    6525             :             case CELLTYPE_VALUE:
    6526        2399 :                 eRet = table::CellContentType_VALUE;
    6527        2399 :                 break;
    6528             :             case CELLTYPE_STRING:
    6529             :             case CELLTYPE_EDIT:
    6530         116 :                 eRet = table::CellContentType_TEXT;
    6531         116 :                 break;
    6532             :             case CELLTYPE_FORMULA:
    6533          54 :                 eRet = table::CellContentType_FORMULA;
    6534          54 :                 break;
    6535             :             default:
    6536        1297 :                 eRet = table::CellContentType_EMPTY;
    6537             :         }
    6538             :     }
    6539             :     else
    6540             :     {
    6541             :         OSL_FAIL("keine DocShell");     //! Exception oder so?
    6542             :     }
    6543             : 
    6544        3866 :     return eRet;
    6545             : }
    6546             : 
    6547          39 : table::CellContentType ScCellObj::GetResultType_Impl()
    6548             : {
    6549          39 :     ScDocShell* pDocSh = GetDocShell();
    6550          39 :     if ( pDocSh )
    6551             :     {
    6552          39 :         ScRefCellValue aCell;
    6553          39 :         aCell.assign(*pDocSh->GetDocument(), aCellPos);
    6554          39 :         if (aCell.meType == CELLTYPE_FORMULA)
    6555             :         {
    6556          29 :             bool bValue = aCell.mpFormula->IsValue();
    6557          29 :             return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
    6558          10 :         }
    6559             :     }
    6560          10 :     return getType();   // wenn keine Formel
    6561             : }
    6562             : 
    6563           2 : sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException, std::exception)
    6564             : {
    6565           2 :     SolarMutexGuard aGuard;
    6566           2 :     ScDocShell* pDocSh = GetDocShell();
    6567           2 :     if (!pDocSh)
    6568             :     {
    6569             :         OSL_FAIL("keine DocShell");     //! Exception oder so?
    6570           0 :         return 0;
    6571             :     }
    6572             : 
    6573           2 :     sal_uInt16 nError = 0;
    6574           4 :     ScRefCellValue aCell;
    6575           2 :     aCell.assign(*pDocSh->GetDocument(), aCellPos);
    6576           2 :     if (aCell.meType == CELLTYPE_FORMULA)
    6577           1 :         nError = aCell.mpFormula->GetErrCode();
    6578             : 
    6579           4 :     return nError;
    6580             : }
    6581             : 
    6582             : // XFormulaTokens
    6583             : 
    6584           0 : uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens()
    6585             :     throw (uno::RuntimeException, std::exception)
    6586             : {
    6587           0 :     SolarMutexGuard aGuard;
    6588           0 :     uno::Sequence<sheet::FormulaToken> aSequence;
    6589           0 :     ScDocShell* pDocSh = GetDocShell();
    6590           0 :     if (!pDocSh)
    6591           0 :         return aSequence;
    6592             : 
    6593           0 :     ScDocument* pDoc = pDocSh->GetDocument();
    6594           0 :     ScRefCellValue aCell;
    6595           0 :     aCell.assign(*pDoc, aCellPos);
    6596           0 :     if (aCell.meType == CELLTYPE_FORMULA)
    6597             :     {
    6598           0 :         ScTokenArray* pTokenArray = aCell.mpFormula->GetCode();
    6599           0 :         if (pTokenArray)
    6600           0 :             ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
    6601             :     }
    6602           0 :     return aSequence;
    6603             : }
    6604             : 
    6605           0 : void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
    6606             : {
    6607           0 :     SolarMutexGuard aGuard;
    6608           0 :     ScDocShell* pDocSh = GetDocShell();
    6609           0 :     if ( pDocSh )
    6610             :     {
    6611           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    6612           0 :         ScTokenArray aTokenArray;
    6613           0 :         (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
    6614             : 
    6615           0 :         ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, aCellPos, aTokenArray);
    6616           0 :         (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false);
    6617           0 :     }
    6618           0 : }
    6619             : 
    6620             : // XCellAddressable
    6621             : 
    6622        1459 : table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException, std::exception)
    6623             : {
    6624        1459 :     SolarMutexGuard aGuard;
    6625        1459 :     table::CellAddress aAdr;
    6626        1459 :     aAdr.Sheet  = aCellPos.Tab();
    6627        1459 :     aAdr.Column = aCellPos.Col();
    6628        1459 :     aAdr.Row    = aCellPos.Row();
    6629        1459 :     return aAdr;
    6630             : }
    6631             : 
    6632             : // XSheetAnnotationAnchor
    6633             : 
    6634           7 : uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
    6635             :                                                 throw(uno::RuntimeException, std::exception)
    6636             : {
    6637           7 :     SolarMutexGuard aGuard;
    6638           7 :     ScDocShell* pDocSh = GetDocShell();
    6639           7 :     if ( pDocSh )
    6640           7 :         return new ScAnnotationObj( pDocSh, aCellPos );
    6641             : 
    6642             :     OSL_FAIL("getAnnotation ohne DocShell");
    6643           0 :     return NULL;
    6644             : }
    6645             : 
    6646             : // XFieldTypesSupplier
    6647             : 
    6648           4 : uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
    6649             :                                                 throw(uno::RuntimeException, std::exception)
    6650             : {
    6651           4 :     SolarMutexGuard aGuard;
    6652           4 :     ScDocShell* pDocSh = GetDocShell();
    6653           4 :     if ( pDocSh )
    6654             :     {
    6655           4 :         uno::Reference<text::XTextRange> xContent(this);
    6656           4 :         return new ScCellFieldsObj(xContent, pDocSh, aCellPos);
    6657             :     }
    6658             : 
    6659           0 :     return NULL;
    6660             : }
    6661             : 
    6662           0 : uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
    6663             :                                                 throw(uno::RuntimeException, std::exception)
    6664             : {
    6665             :     //  sowas gibts nicht im Calc (?)
    6666           0 :     return NULL;
    6667             : }
    6668             : 
    6669             : // XPropertySet erweitert fuer Zell-Properties
    6670             : 
    6671         228 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
    6672             :                                                         throw(uno::RuntimeException, std::exception)
    6673             : {
    6674         228 :     SolarMutexGuard aGuard;
    6675             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    6676         228 :         new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
    6677         228 :     return aRef;
    6678             : }
    6679             : 
    6680          48 : void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    6681             :                                 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    6682             : {
    6683          48 :     if ( pEntry )
    6684             :     {
    6685          48 :         if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
    6686             :         {
    6687           2 :             OUString aStrVal;
    6688           2 :             aValue >>= aStrVal;
    6689           4 :             OUString aString(aStrVal);
    6690           4 :             SetString_Impl(aString, true, false);   // lokal interpretieren
    6691             :         }
    6692          46 :         else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
    6693             :         {
    6694             :             //  Read-Only
    6695             :             //! Exception oder so...
    6696             :         }
    6697             :         else
    6698          45 :             ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
    6699             :     }
    6700          48 : }
    6701             : 
    6702        8032 : void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    6703             :     throw(uno::RuntimeException, std::exception)
    6704             : {
    6705        8032 :     if ( pEntry )
    6706             :     {
    6707        8032 :         if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
    6708             :         {
    6709             :             // sal_False = lokal
    6710          10 :             rAny <<= OUString( GetInputString_Impl(false) );
    6711             :         }
    6712        8022 :         else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
    6713             :         {
    6714          39 :             table::CellContentType eType = GetResultType_Impl();
    6715          39 :             rAny <<= eType;
    6716             :         }
    6717             :         else
    6718        7983 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    6719             :     }
    6720        8032 : }
    6721             : 
    6722        7555 : const SfxItemPropertyMap& ScCellObj::GetItemPropertyMap()
    6723             : {
    6724        7555 :     return pCellPropSet->getPropertyMap();
    6725             : }
    6726             : 
    6727             : // XServiceInfo
    6728             : 
    6729          13 : OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    6730             : {
    6731          13 :     return OUString( "ScCellObj" );
    6732             : }
    6733             : 
    6734          17 : sal_Bool SAL_CALL ScCellObj::supportsService( const OUString& rServiceName )
    6735             :                                                     throw(uno::RuntimeException, std::exception)
    6736             : {
    6737          17 :     return cppu::supportsService(this, rServiceName);
    6738             : }
    6739             : 
    6740          17 : uno::Sequence<OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
    6741             :                                                     throw(uno::RuntimeException, std::exception)
    6742             : {
    6743          17 :     uno::Sequence<OUString> aRet(7);
    6744          17 :     OUString* pArray = aRet.getArray();
    6745          17 :     pArray[0] = OUString( SCSHEETCELL_SERVICE );
    6746          17 :     pArray[1] = OUString( SCCELL_SERVICE );
    6747          17 :     pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
    6748          17 :     pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
    6749          17 :     pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
    6750          17 :     pArray[5] = OUString( SCSHEETCELLRANGE_SERVICE );
    6751          17 :     pArray[6] = OUString( SCCELLRANGE_SERVICE );
    6752          17 :     return aRet;
    6753             : }
    6754             : 
    6755             : // XActionLockable
    6756             : 
    6757           3 : sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException, std::exception)
    6758             : {
    6759           3 :     SolarMutexGuard aGuard;
    6760           3 :     return nActionLockCount != 0;
    6761             : }
    6762             : 
    6763           2 : void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException, std::exception)
    6764             : {
    6765           2 :     SolarMutexGuard aGuard;
    6766           2 :     if (!nActionLockCount)
    6767             :     {
    6768           2 :         if (mxUnoText.is())
    6769             :         {
    6770             :             ScCellEditSource* pEditSource =
    6771           0 :                 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6772           0 :             if (pEditSource)
    6773           0 :                 pEditSource->SetDoUpdateData(false);
    6774             :         }
    6775             :     }
    6776           2 :     nActionLockCount++;
    6777           2 : }
    6778             : 
    6779           1 : void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException, std::exception)
    6780             : {
    6781           1 :     SolarMutexGuard aGuard;
    6782           1 :     if (nActionLockCount > 0)
    6783             :     {
    6784           1 :         nActionLockCount--;
    6785           1 :         if (!nActionLockCount)
    6786             :         {
    6787           1 :             if (mxUnoText.is())
    6788             :             {
    6789             :                 ScCellEditSource* pEditSource =
    6790           0 :                     static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6791           0 :                 if (pEditSource)
    6792             :                 {
    6793           0 :                     pEditSource->SetDoUpdateData(true);
    6794           0 :                     if (pEditSource->IsDirty())
    6795           0 :                         pEditSource->UpdateData();
    6796             :                 }
    6797             :             }
    6798             :         }
    6799           1 :     }
    6800           1 : }
    6801             : 
    6802           1 : void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException, std::exception)
    6803             : {
    6804           1 :     SolarMutexGuard aGuard;
    6805           1 :     if (mxUnoText.is())
    6806             :     {
    6807             :         ScCellEditSource* pEditSource =
    6808           0 :             static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6809           0 :         if (pEditSource)
    6810             :         {
    6811           0 :             pEditSource->SetDoUpdateData(nLock == 0);
    6812           0 :             if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
    6813           0 :                 pEditSource->UpdateData();
    6814             :         }
    6815             :     }
    6816           1 :     nActionLockCount = nLock;
    6817           1 : }
    6818             : 
    6819           1 : sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException, std::exception)
    6820             : {
    6821           1 :     SolarMutexGuard aGuard;
    6822           1 :     sal_uInt16 nRet(nActionLockCount);
    6823           1 :     if (mxUnoText.is())
    6824             :     {
    6825             :         ScCellEditSource* pEditSource =
    6826           0 :             static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6827           0 :         if (pEditSource)
    6828             :         {
    6829           0 :             pEditSource->SetDoUpdateData(true);
    6830           0 :             if (pEditSource->IsDirty())
    6831           0 :                 pEditSource->UpdateData();
    6832             :         }
    6833             :     }
    6834           1 :     nActionLockCount = 0;
    6835           1 :     return nRet;
    6836             : }
    6837             : 
    6838        2891 : ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
    6839             :     ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
    6840        2891 :     pSheetPropSet(lcl_GetSheetPropertySet())
    6841             : {
    6842        2891 : }
    6843             : 
    6844        5626 : ScTableSheetObj::~ScTableSheetObj()
    6845             : {
    6846        5626 : }
    6847             : 
    6848           0 : void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
    6849             : {
    6850           0 :     InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
    6851           0 : }
    6852             : 
    6853       13556 : uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    6854             : {
    6855       13556 :     SC_QUERYINTERFACE( sheet::XSpreadsheet )
    6856       12702 :     SC_QUERYINTERFACE( container::XNamed )
    6857       12496 :     SC_QUERYINTERFACE( sheet::XSheetPageBreak )
    6858       12493 :     SC_QUERYINTERFACE( sheet::XCellRangeMovement )
    6859       12487 :     SC_QUERYINTERFACE( table::XTableChartsSupplier )
    6860       12446 :     SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
    6861       12409 :     SC_QUERYINTERFACE( sheet::XScenariosSupplier )
    6862       12408 :     SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
    6863       12401 :     SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
    6864       12098 :     SC_QUERYINTERFACE( sheet::XPrintAreas )
    6865       12072 :     SC_QUERYINTERFACE( sheet::XSheetAuditing )
    6866       12071 :     SC_QUERYINTERFACE( sheet::XSheetOutline )
    6867       12050 :     SC_QUERYINTERFACE( util::XProtectable )
    6868       12028 :     SC_QUERYINTERFACE( sheet::XScenario )
    6869       12028 :     SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
    6870       12028 :     SC_QUERYINTERFACE( sheet::XSheetLinkable )
    6871       12004 :     SC_QUERYINTERFACE( sheet::XExternalSheetName )
    6872       12004 :     SC_QUERYINTERFACE( document::XEventsSupplier )
    6873             : 
    6874       12004 :     return ScCellRangeObj::queryInterface( rType );
    6875             : }
    6876             : 
    6877       47408 : void SAL_CALL ScTableSheetObj::acquire() throw()
    6878             : {
    6879       47408 :     ScCellRangeObj::acquire();
    6880       47408 : }
    6881             : 
    6882       47330 : void SAL_CALL ScTableSheetObj::release() throw()
    6883             : {
    6884       47330 :     ScCellRangeObj::release();
    6885       47330 : }
    6886             : 
    6887           4 : uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException, std::exception)
    6888             : {
    6889           4 :     static uno::Sequence<uno::Type> aTypes;
    6890           4 :     if ( aTypes.getLength() == 0 )
    6891             :     {
    6892           2 :         uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
    6893           2 :         long nParentLen = aParentTypes.getLength();
    6894           2 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    6895             : 
    6896           2 :         aTypes.realloc( nParentLen + 18 );
    6897           2 :         uno::Type* pPtr = aTypes.getArray();
    6898           2 :         pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheet>*)0);
    6899           2 :         pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNamed>*)0);
    6900           2 :         pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XSheetPageBreak>*)0);
    6901           2 :         pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XCellRangeMovement>*)0);
    6902           2 :         pPtr[nParentLen + 4] = getCppuType((const uno::Reference<table::XTableChartsSupplier>*)0);
    6903           2 :         pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XDataPilotTablesSupplier>*)0);
    6904           2 :         pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XScenariosSupplier>*)0);
    6905           2 :         pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XSheetAnnotationsSupplier>*)0);
    6906           2 :         pPtr[nParentLen + 8] = getCppuType((const uno::Reference<drawing::XDrawPageSupplier>*)0);
    6907           2 :         pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XPrintAreas>*)0);
    6908           2 :         pPtr[nParentLen +10] = getCppuType((const uno::Reference<sheet::XSheetAuditing>*)0);
    6909           2 :         pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetOutline>*)0);
    6910           2 :         pPtr[nParentLen +12] = getCppuType((const uno::Reference<util::XProtectable>*)0);
    6911           2 :         pPtr[nParentLen +13] = getCppuType((const uno::Reference<sheet::XScenario>*)0);
    6912           2 :         pPtr[nParentLen +14] = getCppuType((const uno::Reference<sheet::XScenarioEnhanced>*)0);
    6913           2 :         pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XSheetLinkable>*)0);
    6914           2 :         pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XExternalSheetName>*)0);
    6915           2 :         pPtr[nParentLen +17] = getCppuType((const uno::Reference<document::XEventsSupplier>*)0);
    6916             : 
    6917          62 :         for (long i=0; i<nParentLen; i++)
    6918          62 :             pPtr[i] = pParentPtr[i];                // parent types first
    6919             :     }
    6920           4 :     return aTypes;
    6921             : }
    6922             : 
    6923           0 : uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException, std::exception)
    6924             : {
    6925           0 :     return css::uno::Sequence<sal_Int8>();
    6926             : }
    6927             : 
    6928             : //  Hilfsfunktionen
    6929             : 
    6930        5410 : SCTAB ScTableSheetObj::GetTab_Impl() const
    6931             : {
    6932        5410 :     const ScRangeList& rRanges = GetRangeList();
    6933             :     OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
    6934        5410 :     if ( !rRanges.empty() )
    6935             :     {
    6936        5410 :         const ScRange* pFirst = rRanges[ 0 ];
    6937        5410 :         return pFirst->aStart.Tab();
    6938             :     }
    6939           0 :     return 0;   // soll nicht sein
    6940             : }
    6941             : 
    6942             : // former XSheet
    6943             : 
    6944          41 : uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException, std::exception)
    6945             : {
    6946          41 :     SolarMutexGuard aGuard;
    6947          41 :     ScDocShell* pDocSh = GetDocShell();
    6948          41 :     if ( pDocSh )
    6949          41 :         return new ScChartsObj( pDocSh, GetTab_Impl() );
    6950             : 
    6951             :     OSL_FAIL("kein Dokument");
    6952           0 :     return NULL;
    6953             : }
    6954             : 
    6955          44 : uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
    6956             :                                                 throw(uno::RuntimeException, std::exception)
    6957             : {
    6958          44 :     SolarMutexGuard aGuard;
    6959          44 :     ScDocShell* pDocSh = GetDocShell();
    6960          44 :     if ( pDocSh )
    6961          44 :         return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
    6962             : 
    6963             :     OSL_FAIL("kein Dokument");
    6964           0 :     return NULL;
    6965             : }
    6966             : 
    6967           2 : uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException, std::exception)
    6968             : {
    6969           2 :     SolarMutexGuard aGuard;
    6970           2 :     ScDocShell* pDocSh = GetDocShell();
    6971             : 
    6972           2 :     if ( pDocSh )
    6973           2 :         return new ScScenariosObj( pDocSh, GetTab_Impl() );
    6974             : 
    6975             :     OSL_FAIL("kein Dokument");
    6976           0 :     return NULL;
    6977             : }
    6978             : 
    6979           7 : uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
    6980             :                                                 throw(uno::RuntimeException, std::exception)
    6981             : {
    6982           7 :     SolarMutexGuard aGuard;
    6983           7 :     ScDocShell* pDocSh = GetDocShell();
    6984             : 
    6985           7 :     if ( pDocSh )
    6986           7 :         return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
    6987             : 
    6988             :     OSL_FAIL("kein Dokument");
    6989           0 :     return NULL;
    6990             : }
    6991             : 
    6992          93 : uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
    6993             :                         const OUString& rRange ) throw(uno::RuntimeException, std::exception)
    6994             : {
    6995          93 :     SolarMutexGuard aGuard;
    6996          93 :     return ScCellRangeObj::getCellRangeByName( rRange );
    6997             : }
    6998             : 
    6999          44 : uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
    7000             :                                                 throw(uno::RuntimeException, std::exception)
    7001             : {
    7002          44 :     SolarMutexGuard aGuard;
    7003          44 :     ScDocShell* pDocSh = GetDocShell();
    7004          44 :     if ( pDocSh )
    7005             :     {
    7006             :         //! einzelne Zelle oder ganze Tabelle???????
    7007          44 :         SCTAB nTab = GetTab_Impl();
    7008          44 :         return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
    7009             :     }
    7010           0 :     return NULL;
    7011             : }
    7012             : 
    7013         223 : uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
    7014             :                         const uno::Reference<sheet::XSheetCellRange>& xCellRange )
    7015             :                                                 throw(uno::RuntimeException, std::exception)
    7016             : {
    7017         223 :     SolarMutexGuard aGuard;
    7018         223 :     ScDocShell* pDocSh = GetDocShell();
    7019         223 :     if ( pDocSh && xCellRange.is() )
    7020             :     {
    7021         223 :         ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
    7022         223 :         if (pRangesImp)
    7023             :         {
    7024         223 :             const ScRangeList& rRanges = pRangesImp->GetRangeList();
    7025             :             OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
    7026         223 :             return new ScCellCursorObj( pDocSh, *rRanges[ 0 ] );
    7027             :         }
    7028             :     }
    7029           0 :     return NULL;
    7030             : }
    7031             : 
    7032             : // XSheetCellRange
    7033             : 
    7034        1272 : uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
    7035             :                                                 throw(uno::RuntimeException, std::exception)
    7036             : {
    7037        1272 :     SolarMutexGuard aGuard;
    7038        1272 :     return this;        //!???
    7039             : }
    7040             : 
    7041             : // XCellRange
    7042             : 
    7043        3819 : uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
    7044             :                                         sal_Int32 nColumn, sal_Int32 nRow )
    7045             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    7046             : {
    7047        3819 :     SolarMutexGuard aGuard;
    7048        3819 :     return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
    7049             : }
    7050             : 
    7051        4209 : uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
    7052             :                 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
    7053             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    7054             : {
    7055        4209 :     SolarMutexGuard aGuard;
    7056        4209 :     return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
    7057             : }
    7058             : 
    7059           6 : uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
    7060             :                                                 throw(uno::RuntimeException, std::exception)
    7061             : {
    7062           6 :     SolarMutexGuard aGuard;
    7063           6 :     ScDocShell* pDocSh = GetDocShell();
    7064           6 :     if ( pDocSh )
    7065             :     {
    7066           6 :         ScDocument* pDoc = pDocSh->GetDocument();
    7067           6 :         SCTAB nTab = GetTab_Impl();
    7068             : 
    7069           6 :         Size aSize(pDoc->GetPageSize( nTab ));
    7070           6 :         if (aSize.Width() && aSize.Height())        // effektive Groesse schon gesetzt?
    7071           6 :             pDoc->UpdatePageBreaks( nTab );
    7072             :         else
    7073             :         {
    7074             :             //  Umbrueche updaten wie in ScDocShell::PageStyleModified:
    7075           0 :             ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
    7076           0 :             aPrintFunc.UpdatePages();
    7077             :         }
    7078             : 
    7079           6 :         SCCOL nCount = 0;
    7080             :         SCCOL nCol;
    7081        6150 :         for (nCol=0; nCol<=MAXCOL; nCol++)
    7082        6144 :             if (pDoc->HasColBreak(nCol, nTab))
    7083          16 :                 ++nCount;
    7084             : 
    7085           6 :         sheet::TablePageBreakData aData;
    7086           6 :         uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
    7087           6 :         sheet::TablePageBreakData* pAry = aSeq.getArray();
    7088           6 :         sal_uInt16 nPos = 0;
    7089        6150 :         for (nCol=0; nCol<=MAXCOL; nCol++)
    7090             :         {
    7091        6144 :             ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
    7092        6144 :             if (nBreak)
    7093             :             {
    7094          16 :                 aData.Position    = nCol;
    7095          16 :                 aData.ManualBreak = (nBreak & BREAK_MANUAL);
    7096          16 :                 pAry[nPos] = aData;
    7097          16 :                 ++nPos;
    7098             :             }
    7099             :         }
    7100           6 :         return aSeq;
    7101             :     }
    7102           0 :     return uno::Sequence<sheet::TablePageBreakData>(0);
    7103             : }
    7104             : 
    7105           6 : uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
    7106             :                                                 throw(uno::RuntimeException, std::exception)
    7107             : {
    7108           6 :     SolarMutexGuard aGuard;
    7109           6 :     ScDocShell* pDocSh = GetDocShell();
    7110           6 :     if ( pDocSh )
    7111             :     {
    7112           6 :         ScDocument* pDoc = pDocSh->GetDocument();
    7113           6 :         SCTAB nTab = GetTab_Impl();
    7114             : 
    7115           6 :         Size aSize(pDoc->GetPageSize( nTab ));
    7116           6 :         if (aSize.Width() && aSize.Height())        // effektive Groesse schon gesetzt?
    7117           5 :             pDoc->UpdatePageBreaks( nTab );
    7118             :         else
    7119             :         {
    7120             :             //  Umbrueche updaten wie in ScDocShell::PageStyleModified:
    7121           1 :             ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
    7122           1 :             aPrintFunc.UpdatePages();
    7123             :         }
    7124           6 :         return pDoc->GetRowBreakData(nTab);
    7125             :     }
    7126           0 :     return uno::Sequence<sheet::TablePageBreakData>(0);
    7127             : }
    7128             : 
    7129           0 : void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException, std::exception)
    7130             : {
    7131           0 :     SolarMutexGuard aGuard;
    7132           0 :     ScDocShell* pDocSh = GetDocShell();
    7133           0 :     if ( pDocSh )
    7134             :     {
    7135             :         //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
    7136             : 
    7137           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    7138           0 :         sal_Bool bUndo (pDoc->IsUndoEnabled());
    7139           0 :         SCTAB nTab = GetTab_Impl();
    7140             : 
    7141           0 :         if (bUndo)
    7142             :         {
    7143           0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    7144           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true );
    7145           0 :             pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, false, pUndoDoc );
    7146           0 :             pDocSh->GetUndoManager()->AddUndoAction(
    7147           0 :                                     new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
    7148             :         }
    7149             : 
    7150           0 :         pDoc->RemoveManualBreaks(nTab);
    7151           0 :         pDoc->UpdatePageBreaks(nTab);
    7152             : 
    7153             :         //? UpdatePageBreakData( sal_True );
    7154           0 :         pDocSh->SetDocumentModified();
    7155           0 :         pDocSh->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PAINT_GRID);
    7156           0 :     }
    7157           0 : }
    7158             : 
    7159             : // XNamed
    7160             : 
    7161         204 : OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException, std::exception)
    7162             : {
    7163         204 :     SolarMutexGuard aGuard;
    7164         204 :     OUString aName;
    7165         204 :     ScDocShell* pDocSh = GetDocShell();
    7166         204 :     if ( pDocSh )
    7167         204 :         pDocSh->GetDocument()->GetName( GetTab_Impl(), aName );
    7168         204 :     return aName;
    7169             : }
    7170             : 
    7171           9 : void SAL_CALL ScTableSheetObj::setName( const OUString& aNewName )
    7172             :                                                 throw(uno::RuntimeException, std::exception)
    7173             : {
    7174           9 :     SolarMutexGuard aGuard;
    7175           9 :     ScDocShell* pDocSh = GetDocShell();
    7176           9 :     if ( pDocSh )
    7177             :     {
    7178           9 :         OUString aString(aNewName);
    7179           9 :         pDocSh->GetDocFunc().RenameTable( GetTab_Impl(), aString, true, true );
    7180           9 :     }
    7181           9 : }
    7182             : 
    7183             : // XDrawPageSupplier
    7184             : 
    7185         303 : uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
    7186             :                                                 throw(uno::RuntimeException, std::exception)
    7187             : {
    7188         303 :     SolarMutexGuard aGuard;
    7189         303 :     ScDocShell* pDocSh = GetDocShell();
    7190         303 :     if ( pDocSh )
    7191             :     {
    7192         303 :         ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
    7193             :         OSL_ENSURE(pDrawLayer,"kann Draw-Layer nicht anlegen");
    7194             : 
    7195         303 :         SCTAB nTab = GetTab_Impl();
    7196         303 :         SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
    7197             :         OSL_ENSURE(pPage,"Draw-Page nicht gefunden");
    7198         303 :         if (pPage)
    7199         303 :             return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
    7200             : 
    7201             :         //  Das DrawPage-Objekt meldet sich als Listener am SdrModel an
    7202             :         //  und sollte von dort alle Aktionen mitbekommen
    7203             :     }
    7204           0 :     return NULL;
    7205             : }
    7206             : 
    7207             : // XCellMovement
    7208             : 
    7209           1 : void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
    7210             :                                 sheet::CellInsertMode nMode ) throw(uno::RuntimeException, std::exception)
    7211             : {
    7212           1 :     SolarMutexGuard aGuard;
    7213           1 :     ScDocShell* pDocSh = GetDocShell();
    7214           1 :     if ( pDocSh )
    7215             :     {
    7216           1 :         sal_Bool bDo = sal_True;
    7217           1 :         InsCellCmd eCmd = INS_NONE;
    7218           1 :         switch (nMode)
    7219             :         {
    7220           0 :             case sheet::CellInsertMode_NONE:    bDo = false;            break;
    7221           0 :             case sheet::CellInsertMode_DOWN:    eCmd = INS_CELLSDOWN;   break;
    7222           1 :             case sheet::CellInsertMode_RIGHT:   eCmd = INS_CELLSRIGHT;  break;
    7223           0 :             case sheet::CellInsertMode_ROWS:    eCmd = INS_INSROWS;     break;
    7224           0 :             case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS;     break;
    7225             :             default:
    7226             :                 OSL_FAIL("insertCells: falscher Mode");
    7227           0 :                 bDo = false;
    7228             :         }
    7229             : 
    7230           1 :         if (bDo)
    7231             :         {
    7232             :             OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7233           1 :             ScRange aScRange;
    7234           1 :             ScUnoConversion::FillScRange( aScRange, rRangeAddress );
    7235           1 :             pDocSh->GetDocFunc().InsertCells( aScRange, NULL, eCmd, true, true );
    7236             :         }
    7237           1 :     }
    7238           1 : }
    7239             : 
    7240           3 : void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
    7241             :                                 sheet::CellDeleteMode nMode ) throw(uno::RuntimeException, std::exception)
    7242             : {
    7243           3 :     SolarMutexGuard aGuard;
    7244           3 :     ScDocShell* pDocSh = GetDocShell();
    7245           3 :     if ( pDocSh )
    7246             :     {
    7247           3 :         sal_Bool bDo = sal_True;
    7248           3 :         DelCellCmd eCmd = DEL_NONE;
    7249           3 :         switch (nMode)
    7250             :         {
    7251           0 :             case sheet::CellDeleteMode_NONE:     bDo = false;           break;
    7252           1 :             case sheet::CellDeleteMode_UP:       eCmd = DEL_CELLSUP;    break;
    7253           2 :             case sheet::CellDeleteMode_LEFT:     eCmd = DEL_CELLSLEFT;  break;
    7254           0 :             case sheet::CellDeleteMode_ROWS:     eCmd = DEL_DELROWS;    break;
    7255           0 :             case sheet::CellDeleteMode_COLUMNS:  eCmd = DEL_DELCOLS;    break;
    7256             :             default:
    7257             :                 OSL_FAIL("deleteCells: falscher Mode");
    7258           0 :                 bDo = false;
    7259             :         }
    7260             : 
    7261           3 :         if (bDo)
    7262             :         {
    7263             :             OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7264           3 :             ScRange aScRange;
    7265           3 :             ScUnoConversion::FillScRange( aScRange, rRangeAddress );
    7266           3 :             pDocSh->GetDocFunc().DeleteCells( aScRange, NULL, eCmd, true, true );
    7267             :         }
    7268           3 :     }
    7269           3 : }
    7270             : 
    7271           1 : void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
    7272             :                                         const table::CellRangeAddress& aSource )
    7273             :                                         throw(uno::RuntimeException, std::exception)
    7274             : {
    7275           1 :     SolarMutexGuard aGuard;
    7276           1 :     ScDocShell* pDocSh = GetDocShell();
    7277           1 :     if ( pDocSh )
    7278             :     {
    7279             :         OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7280           1 :         ScRange aSourceRange;
    7281           1 :         ScUnoConversion::FillScRange( aSourceRange, aSource );
    7282           1 :         ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
    7283           1 :         pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, true, true, true, true );
    7284           1 :     }
    7285           1 : }
    7286             : 
    7287           1 : void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
    7288             :                                         const table::CellRangeAddress& aSource )
    7289             :                                         throw(uno::RuntimeException, std::exception)
    7290             : {
    7291           1 :     SolarMutexGuard aGuard;
    7292           1 :     ScDocShell* pDocSh = GetDocShell();
    7293           1 :     if ( pDocSh )
    7294             :     {
    7295             :         OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7296           1 :         ScRange aSourceRange;
    7297           1 :         ScUnoConversion::FillScRange( aSourceRange, aSource );
    7298           1 :         ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
    7299           1 :         pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, true, true, true );
    7300           1 :     }
    7301           1 : }
    7302             : 
    7303             : // XPrintAreas
    7304             : 
    7305           6 : void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
    7306             : {
    7307             :     //  Umbrueche und Undo
    7308           6 :     ScDocShell* pDocSh = GetDocShell();
    7309           6 :     ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : 0;
    7310             : 
    7311           6 :     if(pDocSh && pDoc)
    7312             :     {
    7313           6 :         const bool bUndo(pDoc->IsUndoEnabled());
    7314           6 :         const SCTAB nTab(GetTab_Impl());
    7315             : 
    7316           6 :         if(bUndo)
    7317             :         {
    7318           2 :             pDocSh->GetUndoManager()->AddUndoAction(
    7319             :                 new ScUndoPrintRange(
    7320             :                     pDocSh,
    7321             :                     nTab,
    7322             :                     pOldRanges,
    7323           2 :                     pDoc->CreatePrintRangeSaver())); // create new ranges
    7324             : 
    7325             :             // #i120105# ownership of old ranges has changed, mark as consumed
    7326           2 :             pOldRanges = 0;
    7327             :         }
    7328             : 
    7329           6 :         ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
    7330           6 :         SfxBindings* pBindings = pDocSh->GetViewBindings();
    7331             : 
    7332           6 :         if(pBindings)
    7333             :         {
    7334           2 :             pBindings->Invalidate(SID_DELETE_PRINTAREA);
    7335             :         }
    7336             : 
    7337           6 :         pDocSh->SetDocumentModified();
    7338             :     }
    7339             : 
    7340             :     // #i120105# pOldRanges not used, need to cleanup
    7341           6 :     delete pOldRanges;
    7342           6 : }
    7343             : 
    7344          22 : uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
    7345             :                                                 throw(uno::RuntimeException, std::exception)
    7346             : {
    7347          22 :     SolarMutexGuard aGuard;
    7348          22 :     ScDocShell* pDocSh = GetDocShell();
    7349          22 :     if ( pDocSh )
    7350             :     {
    7351          22 :         ScDocument* pDoc = pDocSh->GetDocument();
    7352          22 :         SCTAB nTab = GetTab_Impl();
    7353          22 :         sal_uInt16 nCount = pDoc->GetPrintRangeCount( nTab );
    7354             : 
    7355          22 :         table::CellRangeAddress aRangeAddress;
    7356          22 :         uno::Sequence<table::CellRangeAddress> aSeq(nCount);
    7357          22 :         table::CellRangeAddress* pAry = aSeq.getArray();
    7358          22 :         for (sal_uInt16 i=0; i<nCount; i++)
    7359             :         {
    7360           0 :             const ScRange* pRange = pDoc->GetPrintRange( nTab, i );
    7361             :             OSL_ENSURE(pRange,"wo ist der Druckbereich");
    7362           0 :             if (pRange)
    7363             :             {
    7364           0 :                 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
    7365           0 :                 aRangeAddress.Sheet = nTab; // core does not care about sheet index
    7366           0 :                 pAry[i] = aRangeAddress;
    7367             :             }
    7368             :         }
    7369          22 :         return aSeq;
    7370             :     }
    7371           0 :     return uno::Sequence<table::CellRangeAddress>();
    7372             : }
    7373             : 
    7374           0 : void SAL_CALL ScTableSheetObj::setPrintAreas(
    7375             :                     const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
    7376             :                                                 throw(uno::RuntimeException, std::exception)
    7377             : {
    7378           0 :     SolarMutexGuard aGuard;
    7379           0 :     ScPrintRangeSaver* pOldRanges = NULL;
    7380           0 :     ScDocShell* pDocSh = GetDocShell();
    7381           0 :     if ( pDocSh )
    7382             :     {
    7383           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    7384           0 :         SCTAB nTab = GetTab_Impl();
    7385             : 
    7386           0 :         if ( pDoc->IsUndoEnabled() )
    7387           0 :             pOldRanges = pDoc->CreatePrintRangeSaver();
    7388             : 
    7389           0 :         sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength();
    7390           0 :         pDoc->ClearPrintRanges( nTab );
    7391           0 :         if (nCount)
    7392             :         {
    7393           0 :             ScRange aPrintRange;
    7394           0 :             const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
    7395           0 :             for (sal_uInt16 i=0; i<nCount; i++)
    7396             :             {
    7397           0 :                 ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
    7398           0 :                 pDoc->AddPrintRange( nTab, aPrintRange );
    7399             :             }
    7400             :         }
    7401             : 
    7402           0 :         if ( pDoc->IsUndoEnabled() )
    7403           0 :             PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
    7404           0 :     }
    7405           0 : }
    7406             : 
    7407          23 : sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException, std::exception)
    7408             : {
    7409          23 :     SolarMutexGuard aGuard;
    7410          23 :     ScDocShell* pDocSh = GetDocShell();
    7411          23 :     if ( pDocSh )
    7412             :     {
    7413          23 :         ScDocument* pDoc = pDocSh->GetDocument();
    7414          23 :         SCTAB nTab = GetTab_Impl();
    7415          23 :         return ( pDoc->GetRepeatColRange(nTab) != NULL );
    7416             :     }
    7417           0 :     return false;
    7418             : }
    7419             : 
    7420           1 : void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
    7421             :                                                     throw(uno::RuntimeException, std::exception)
    7422             : {
    7423           1 :     SolarMutexGuard aGuard;
    7424           1 :     ScDocShell* pDocSh = GetDocShell();
    7425           1 :     if ( pDocSh )
    7426             :     {
    7427           1 :         ScDocument* pDoc = pDocSh->GetDocument();
    7428           1 :         SCTAB nTab = GetTab_Impl();
    7429             : 
    7430           1 :         ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
    7431             : 
    7432           1 :         if ( bPrintTitleColumns )
    7433             :         {
    7434           1 :             if ( !pDoc->GetRepeatColRange( nTab ) )         // keinen bestehenden Bereich veraendern
    7435             :             {
    7436           1 :                 ScRange aNew( 0, 0, nTab, 0, 0, nTab );     // Default
    7437           1 :                 pDoc->SetRepeatColRange( nTab, &aNew );     // einschalten
    7438             :             }
    7439             :         }
    7440             :         else
    7441           0 :             pDoc->SetRepeatColRange( nTab, NULL );          // abschalten
    7442             : 
    7443           1 :         PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
    7444             : 
    7445             :         //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
    7446           1 :     }
    7447           1 : }
    7448             : 
    7449          22 : table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException, std::exception)
    7450             : {
    7451          22 :     SolarMutexGuard aGuard;
    7452          22 :     table::CellRangeAddress aRet;
    7453          22 :     ScDocShell* pDocSh = GetDocShell();
    7454          22 :     if ( pDocSh )
    7455             :     {
    7456          22 :         ScDocument* pDoc = pDocSh->GetDocument();
    7457          22 :         SCTAB nTab = GetTab_Impl();
    7458          22 :         const ScRange* pRange = pDoc->GetRepeatColRange(nTab);
    7459          22 :         if (pRange)
    7460             :         {
    7461           0 :             ScUnoConversion::FillApiRange( aRet, *pRange );
    7462           0 :             aRet.Sheet = nTab; // core does not care about sheet index
    7463             :         }
    7464             :     }
    7465          22 :     return aRet;
    7466             : }
    7467             : 
    7468           0 : void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
    7469             :                                                     throw(uno::RuntimeException, std::exception)
    7470             : {
    7471           0 :     SolarMutexGuard aGuard;
    7472           0 :     ScDocShell* pDocSh = GetDocShell();
    7473           0 :     if ( pDocSh )
    7474             :     {
    7475           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    7476           0 :         SCTAB nTab = GetTab_Impl();
    7477             : 
    7478           0 :         ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
    7479             : 
    7480           0 :         ScRange aNew;
    7481           0 :         ScUnoConversion::FillScRange( aNew, aTitleColumns );
    7482           0 :         pDoc->SetRepeatColRange( nTab, &aNew );     // immer auch einschalten
    7483             : 
    7484           0 :         PrintAreaUndo_Impl( pOldRanges );           // Undo, Umbrueche, Modified etc.
    7485           0 :     }
    7486           0 : }
    7487             : 
    7488          25 : sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException, std::exception)
    7489             : {
    7490          25 :     SolarMutexGuard aGuard;
    7491          25 :     ScDocShell* pDocSh = GetDocShell();
    7492          25 :     if ( pDocSh )
    7493             :     {
    7494          25 :         ScDocument* pDoc = pDocSh->GetDocument();
    7495          25 :         SCTAB nTab = GetTab_Impl();
    7496          25 :         return ( pDoc->GetRepeatRowRange(nTab) != NULL );
    7497             :     }
    7498           0 :     return false;
    7499             : }
    7500             : 
    7501           3 : void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
    7502             :                                                 throw(uno::RuntimeException, std::exception)
    7503             : {
    7504           3 :     SolarMutexGuard aGuard;
    7505           3 :     ScDocShell* pDocSh = GetDocShell();
    7506           3 :     if ( pDocSh )
    7507             :     {
    7508           3 :         ScDocument* pDoc = pDocSh->GetDocument();
    7509           3 :         SCTAB nTab = GetTab_Impl();
    7510             : 
    7511           3 :         ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
    7512             : 
    7513           3 :         if ( bPrintTitleRows )
    7514             :         {
    7515           3 :             if ( !pDoc->GetRepeatRowRange( nTab ) )         // keinen bestehenden Bereich veraendern
    7516             :             {
    7517           3 :                 ScRange aNew( 0, 0, nTab, 0, 0, nTab );     // Default
    7518           3 :                 pDoc->SetRepeatRowRange( nTab, &aNew );     // einschalten
    7519             :             }
    7520             :         }
    7521             :         else
    7522           0 :             pDoc->SetRepeatRowRange( nTab, NULL );          // abschalten
    7523             : 
    7524           3 :         PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
    7525             : 
    7526             :         //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
    7527           3 :     }
    7528           3 : }
    7529             : 
    7530          22 : table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException, std::exception)
    7531             : {
    7532          22 :     SolarMutexGuard aGuard;
    7533          22 :     table::CellRangeAddress aRet;
    7534          22 :     ScDocShell* pDocSh = GetDocShell();
    7535          22 :     if ( pDocSh )
    7536             :     {
    7537          22 :         ScDocument* pDoc = pDocSh->GetDocument();
    7538          22 :         SCTAB nTab = GetTab_Impl();
    7539          22 :         const ScRange* pRange = pDoc->GetRepeatRowRange(nTab);
    7540          22 :         if (pRange)
    7541             :         {
    7542           0 :             ScUnoConversion::FillApiRange( aRet, *pRange );
    7543           0 :             aRet.Sheet = nTab; // core does not care about sheet index
    7544             :         }
    7545             :     }
    7546          22 :     return aRet;
    7547             : }
    7548             : 
    7549           2 : void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
    7550             :                                                     throw(uno::RuntimeException, std::exception)
    7551             : {
    7552           2 :     SolarMutexGuard aGuard;
    7553           2 :     ScDocShell* pDocSh = GetDocShell();
    7554           2 :     if ( pDocSh )
    7555             :     {
    7556           2 :         ScDocument* pDoc = pDocSh->GetDocument();
    7557           2 :         SCTAB nTab = GetTab_Impl();
    7558             : 
    7559           2 :         ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
    7560             : 
    7561           2 :         ScRange aNew;
    7562           2 :         ScUnoConversion::FillScRange( aNew, aTitleRows );
    7563           2 :         pDoc->SetRepeatRowRange( nTab, &aNew );     // immer auch einschalten
    7564             : 
    7565           2 :         PrintAreaUndo_Impl( pOldRanges );           // Undo, Umbrueche, Modified etc.
    7566           2 :     }
    7567           2 : }
    7568             : 
    7569             : // XSheetLinkable
    7570             : 
    7571          22 : sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException, std::exception)
    7572             : {
    7573          22 :     SolarMutexGuard aGuard;
    7574          22 :     sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
    7575          22 :     ScDocShell* pDocSh = GetDocShell();
    7576          22 :     if ( pDocSh )
    7577             :     {
    7578          22 :         sal_uInt8 nMode = pDocSh->GetDocument()->GetLinkMode( GetTab_Impl() );
    7579          22 :         if ( nMode == SC_LINK_NORMAL )
    7580           0 :             eRet = sheet::SheetLinkMode_NORMAL;
    7581          22 :         else if ( nMode == SC_LINK_VALUE )
    7582           0 :             eRet = sheet::SheetLinkMode_VALUE;
    7583             :     }
    7584          22 :     return eRet;
    7585             : }
    7586             : 
    7587           0 : void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
    7588             :                                                 throw(uno::RuntimeException, std::exception)
    7589             : {
    7590           0 :     SolarMutexGuard aGuard;
    7591             : 
    7592             :     //! Filter und Options aus altem Link suchen
    7593             : 
    7594           0 :     OUString aUrl(getLinkUrl());
    7595           0 :     OUString aSheet(getLinkSheetName());
    7596             : 
    7597           0 :     OUString aEmpty;
    7598           0 :     link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
    7599           0 : }
    7600             : 
    7601           0 : OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException, std::exception)
    7602             : {
    7603           0 :     SolarMutexGuard aGuard;
    7604           0 :     OUString aFile;
    7605           0 :     ScDocShell* pDocSh = GetDocShell();
    7606           0 :     if ( pDocSh )
    7607           0 :         aFile = pDocSh->GetDocument()->GetLinkDoc( GetTab_Impl() );
    7608           0 :     return aFile;
    7609             : }
    7610             : 
    7611           0 : void SAL_CALL ScTableSheetObj::setLinkUrl( const OUString& aLinkUrl )
    7612             :                                                 throw(uno::RuntimeException, std::exception)
    7613             : {
    7614           0 :     SolarMutexGuard aGuard;
    7615             : 
    7616             :     //! Filter und Options aus altem Link suchen
    7617             : 
    7618           0 :     sheet::SheetLinkMode eMode = getLinkMode();
    7619           0 :     OUString aSheet(getLinkSheetName());
    7620             : 
    7621           0 :     OUString aEmpty;
    7622           0 :     link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
    7623           0 : }
    7624             : 
    7625           0 : OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException, std::exception)
    7626             : {
    7627           0 :     SolarMutexGuard aGuard;
    7628           0 :     OUString aSheet;
    7629           0 :     ScDocShell* pDocSh = GetDocShell();
    7630           0 :     if ( pDocSh )
    7631           0 :         aSheet = pDocSh->GetDocument()->GetLinkTab( GetTab_Impl() );
    7632           0 :     return aSheet;
    7633             : }
    7634             : 
    7635           0 : void SAL_CALL ScTableSheetObj::setLinkSheetName( const OUString& aLinkSheetName )
    7636             :                                                 throw(uno::RuntimeException, std::exception)
    7637             : {
    7638           0 :     SolarMutexGuard aGuard;
    7639             : 
    7640             :     //! Filter und Options aus altem Link suchen
    7641             : 
    7642           0 :     sheet::SheetLinkMode eMode = getLinkMode();
    7643           0 :     OUString aUrl(getLinkUrl());
    7644             : 
    7645           0 :     OUString aEmpty;
    7646           0 :     link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
    7647           0 : }
    7648             : 
    7649           2 : void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aSheetName,
    7650             :                         const OUString& aFilterName, const OUString& aFilterOptions,
    7651             :                         sheet::SheetLinkMode nMode ) throw(uno::RuntimeException, std::exception)
    7652             : {
    7653           2 :     SolarMutexGuard aGuard;
    7654           2 :     ScDocShell* pDocSh = GetDocShell();
    7655           2 :     if ( pDocSh )
    7656             :     {
    7657           2 :         ScDocument* pDoc = pDocSh->GetDocument();
    7658           2 :         SCTAB nTab = GetTab_Impl();
    7659             : 
    7660           2 :         OUString aFileString = aUrl;
    7661           4 :         OUString aFilterString = aFilterName;
    7662           4 :         OUString aOptString = aFilterOptions;
    7663           4 :         OUString aSheetString = aSheetName;
    7664             : 
    7665           2 :         aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
    7666           2 :         if (aFilterString.isEmpty())
    7667           2 :             ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false );
    7668             : 
    7669             :         //  remove application prefix from filter name here, so the filter options
    7670             :         //  aren't reset when the filter name is changed in ScTableLink::DataChanged
    7671           2 :         ScDocumentLoader::RemoveAppPrefix( aFilterString );
    7672             : 
    7673           2 :         sal_uInt8 nLinkMode = SC_LINK_NONE;
    7674           2 :         if ( nMode == sheet::SheetLinkMode_NORMAL )
    7675           0 :             nLinkMode = SC_LINK_NORMAL;
    7676           2 :         else if ( nMode == sheet::SheetLinkMode_VALUE )
    7677           2 :             nLinkMode = SC_LINK_VALUE;
    7678             : 
    7679           2 :         sal_uLong nRefresh = 0;
    7680           2 :         pDoc->SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
    7681             : 
    7682           2 :         pDocSh->UpdateLinks();                  // ggf. Link eintragen oder loeschen
    7683           2 :         SfxBindings* pBindings = pDocSh->GetViewBindings();
    7684           2 :         if (pBindings)
    7685           2 :             pBindings->Invalidate(SID_LINKS);
    7686             : 
    7687             :         //! Undo fuer Link-Daten an der Table
    7688             : 
    7689           2 :         if ( nLinkMode != SC_LINK_NONE && pDoc->IsExecuteLinkEnabled() )        // Link updaten
    7690             :         {
    7691             :             //  Update immer, auch wenn der Link schon da war
    7692             :             //! Update nur fuer die betroffene Tabelle???
    7693             : 
    7694           2 :             sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
    7695           2 :             sal_uInt16 nCount = pLinkManager->GetLinks().size();
    7696           4 :             for ( sal_uInt16 i=0; i<nCount; i++ )
    7697             :             {
    7698           2 :                 ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
    7699           2 :                 if (pBase->ISA(ScTableLink))
    7700             :                 {
    7701           2 :                     ScTableLink* pTabLink = (ScTableLink*)pBase;
    7702           2 :                     if ( aFileString.equals(pTabLink->GetFileName()) )
    7703           2 :                         pTabLink->Update();                         // inkl. Paint&Undo
    7704             : 
    7705             :                     //! Der Dateiname sollte nur einmal vorkommen (?)
    7706             :                 }
    7707             :             }
    7708           2 :         }
    7709             : 
    7710             :         //! Notify fuer ScSheetLinkObj Objekte!!!
    7711           2 :     }
    7712           2 : }
    7713             : 
    7714             : // XSheetAuditing
    7715             : 
    7716           0 : sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
    7717             :                                                 throw(uno::RuntimeException, std::exception)
    7718             : {
    7719           0 :     SolarMutexGuard aGuard;
    7720           0 :     ScDocShell* pDocSh = GetDocShell();
    7721           0 :     if ( pDocSh )
    7722             :     {
    7723           0 :         SCTAB nTab = GetTab_Impl();
    7724             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7725           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7726           0 :         return pDocSh->GetDocFunc().DetectiveDelSucc( aPos );
    7727             :     }
    7728           0 :     return false;
    7729             : }
    7730             : 
    7731           0 : sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
    7732             :                                             throw(uno::RuntimeException, std::exception)
    7733             : {
    7734           0 :     SolarMutexGuard aGuard;
    7735           0 :     ScDocShell* pDocSh = GetDocShell();
    7736           0 :     if ( pDocSh )
    7737             :     {
    7738           0 :         SCTAB nTab = GetTab_Impl();
    7739             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7740           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7741           0 :         return pDocSh->GetDocFunc().DetectiveDelPred( aPos );
    7742             :     }
    7743           0 :     return false;
    7744             : }
    7745             : 
    7746           0 : sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
    7747             :                                             throw(uno::RuntimeException, std::exception)
    7748             : {
    7749           0 :     SolarMutexGuard aGuard;
    7750           0 :     ScDocShell* pDocSh = GetDocShell();
    7751           0 :     if ( pDocSh )
    7752             :     {
    7753           0 :         SCTAB nTab = GetTab_Impl();
    7754             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7755           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7756           0 :         return pDocSh->GetDocFunc().DetectiveAddSucc( aPos );
    7757             :     }
    7758           0 :     return false;
    7759             : }
    7760             : 
    7761           1 : sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
    7762             :                                             throw(uno::RuntimeException, std::exception)
    7763             : {
    7764           1 :     SolarMutexGuard aGuard;
    7765           1 :     ScDocShell* pDocSh = GetDocShell();
    7766           1 :     if ( pDocSh )
    7767             :     {
    7768           1 :         SCTAB nTab = GetTab_Impl();
    7769             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7770           1 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7771           1 :         return pDocSh->GetDocFunc().DetectiveAddPred( aPos );
    7772             :     }
    7773           0 :     return false;
    7774             : }
    7775             : 
    7776           0 : sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
    7777             :                                             throw(uno::RuntimeException, std::exception)
    7778             : {
    7779           0 :     SolarMutexGuard aGuard;
    7780           0 :     ScDocShell* pDocSh = GetDocShell();
    7781           0 :     if ( pDocSh )
    7782             :     {
    7783           0 :         SCTAB nTab = GetTab_Impl();
    7784             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7785           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7786           0 :         return pDocSh->GetDocFunc().DetectiveAddError( aPos );
    7787             :     }
    7788           0 :     return false;
    7789             : }
    7790             : 
    7791           0 : sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException, std::exception)
    7792             : {
    7793           0 :     SolarMutexGuard aGuard;
    7794           0 :     ScDocShell* pDocSh = GetDocShell();
    7795           0 :     if ( pDocSh )
    7796           0 :         return pDocSh->GetDocFunc().DetectiveMarkInvalid( GetTab_Impl() );
    7797           0 :     return false;
    7798             : }
    7799             : 
    7800           0 : void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException, std::exception)
    7801             : {
    7802           0 :     SolarMutexGuard aGuard;
    7803           0 :     ScDocShell* pDocSh = GetDocShell();
    7804           0 :     if ( pDocSh )
    7805           0 :         pDocSh->GetDocFunc().DetectiveDelAll( GetTab_Impl() );
    7806           0 : }
    7807             : 
    7808             : // XSheetOutline
    7809             : 
    7810           8 : void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
    7811             :                                         table::TableOrientation nOrientation )
    7812             :                                     throw (uno::RuntimeException,
    7813             :                                            std::exception)
    7814             : {
    7815           8 :     SolarMutexGuard aGuard;
    7816           8 :     ScDocShell* pDocSh = GetDocShell();
    7817           8 :     if ( pDocSh )
    7818             :     {
    7819           8 :         sal_Bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
    7820           8 :         ScRange aGroupRange;
    7821           8 :         ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
    7822           8 :         ScOutlineDocFunc aFunc(*pDocSh);
    7823           8 :         aFunc.MakeOutline( aGroupRange, bColumns, true, true );
    7824           8 :     }
    7825           8 : }
    7826             : 
    7827           4 : void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
    7828             :                                         table::TableOrientation nOrientation )
    7829             :                                     throw (uno::RuntimeException,
    7830             :                                            std::exception)
    7831             : {
    7832           4 :     SolarMutexGuard aGuard;
    7833           4 :     ScDocShell* pDocSh = GetDocShell();
    7834           4 :     if ( pDocSh )
    7835             :     {
    7836           4 :         sal_Bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
    7837           4 :         ScRange aGroupRange;
    7838           4 :         ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
    7839           4 :         ScOutlineDocFunc aFunc(*pDocSh);
    7840           4 :         aFunc.RemoveOutline( aGroupRange, bColumns, true, true );
    7841           4 :     }
    7842           4 : }
    7843             : 
    7844           1 : void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
    7845             :     throw(uno::RuntimeException, std::exception)
    7846             : {
    7847           1 :     SolarMutexGuard aGuard;
    7848           1 :     ScDocShell* pDocSh = GetDocShell();
    7849           1 :     if ( pDocSh )
    7850             :     {
    7851           1 :         ScRange aFormulaRange;
    7852           1 :         ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
    7853           1 :         ScOutlineDocFunc aFunc(*pDocSh);
    7854           1 :         aFunc.AutoOutline( aFormulaRange, true );
    7855           1 :     }
    7856           1 : }
    7857             : 
    7858           7 : void SAL_CALL ScTableSheetObj::clearOutline()
    7859             :     throw(uno::RuntimeException, std::exception)
    7860             : {
    7861           7 :     SolarMutexGuard aGuard;
    7862           7 :     ScDocShell* pDocSh = GetDocShell();
    7863           7 :     if ( pDocSh )
    7864             :     {
    7865           7 :         SCTAB nTab = GetTab_Impl();
    7866           7 :         ScOutlineDocFunc aFunc(*pDocSh);
    7867           7 :         aFunc.RemoveAllOutlines( nTab, true );
    7868           7 :     }
    7869           7 : }
    7870             : 
    7871          13 : void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
    7872             :     throw(uno::RuntimeException, std::exception)
    7873             : {
    7874          13 :     SolarMutexGuard aGuard;
    7875          13 :     ScDocShell* pDocSh = GetDocShell();
    7876          13 :     if ( pDocSh )
    7877             :     {
    7878          13 :         ScRange aMarkRange;
    7879          13 :         ScUnoConversion::FillScRange( aMarkRange, rCellRange );
    7880          13 :         ScOutlineDocFunc aFunc(*pDocSh);
    7881          13 :         aFunc.HideMarkedOutlines( aMarkRange, true );
    7882          13 :     }
    7883          13 : }
    7884             : 
    7885          10 : void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
    7886             :     throw(uno::RuntimeException, std::exception)
    7887             : {
    7888          10 :     SolarMutexGuard aGuard;
    7889          10 :     ScDocShell* pDocSh = GetDocShell();
    7890          10 :     if ( pDocSh )
    7891             :     {
    7892          10 :         ScRange aMarkRange;
    7893          10 :         ScUnoConversion::FillScRange( aMarkRange, rCellRange );
    7894          10 :         ScOutlineDocFunc aFunc(*pDocSh);
    7895          10 :         aFunc.ShowMarkedOutlines( aMarkRange, true );
    7896          10 :     }
    7897          10 : }
    7898             : 
    7899           1 : void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
    7900             :     throw(uno::RuntimeException, std::exception)
    7901             : {
    7902           1 :     SolarMutexGuard aGuard;
    7903           1 :     ScDocShell* pDocSh = GetDocShell();
    7904           1 :     if ( pDocSh )
    7905             :     {
    7906           1 :         sal_Bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
    7907           1 :         SCTAB nTab = GetTab_Impl();
    7908           1 :         ScOutlineDocFunc aFunc(*pDocSh);
    7909           1 :         aFunc.SelectLevel( nTab, bColumns, nLevel, true, true );
    7910           1 :     }
    7911           1 : }
    7912             : 
    7913             : // XProtectable
    7914             : 
    7915           0 : void SAL_CALL ScTableSheetObj::protect( const OUString& aPassword )
    7916             :                                             throw(uno::RuntimeException, std::exception)
    7917             : {
    7918           0 :     SolarMutexGuard aGuard;
    7919           0 :     ScDocShell* pDocSh = GetDocShell();
    7920             :     // #i108245# if already protected, don't change anything
    7921           0 :     if ( pDocSh && !pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() ) )
    7922             :     {
    7923           0 :         OUString aString(aPassword);
    7924           0 :         pDocSh->GetDocFunc().Protect( GetTab_Impl(), aString, true );
    7925           0 :     }
    7926           0 : }
    7927             : 
    7928           0 : void SAL_CALL ScTableSheetObj::unprotect( const OUString& aPassword )
    7929             :                             throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    7930             : {
    7931           0 :     SolarMutexGuard aGuard;
    7932           0 :     ScDocShell* pDocSh = GetDocShell();
    7933           0 :     if ( pDocSh )
    7934             :     {
    7935           0 :         OUString aString(aPassword);
    7936           0 :         sal_Bool bDone = pDocSh->GetDocFunc().Unprotect( GetTab_Impl(), aString, true );
    7937           0 :         if (!bDone)
    7938           0 :             throw lang::IllegalArgumentException();
    7939           0 :     }
    7940           0 : }
    7941             : 
    7942          22 : sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException, std::exception)
    7943             : {
    7944          22 :     SolarMutexGuard aGuard;
    7945          22 :     ScDocShell* pDocSh = GetDocShell();
    7946          22 :     if ( pDocSh )
    7947          22 :         return pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() );
    7948             : 
    7949             :     OSL_FAIL("keine DocShell");     //! Exception oder so?
    7950           0 :     return false;
    7951             : }
    7952             : 
    7953             : // XScenario
    7954             : 
    7955           0 : sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException, std::exception)
    7956             : {
    7957           0 :     SolarMutexGuard aGuard;
    7958           0 :     ScDocShell* pDocSh = GetDocShell();
    7959           0 :     if ( pDocSh )
    7960           0 :         return pDocSh->GetDocument()->IsScenario( GetTab_Impl() );
    7961             : 
    7962           0 :     return false;
    7963             : }
    7964             : 
    7965           0 : OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException, std::exception)
    7966             : {
    7967           0 :     SolarMutexGuard aGuard;
    7968           0 :     ScDocShell* pDocSh = GetDocShell();
    7969           0 :     if ( pDocSh )
    7970             :     {
    7971           0 :         OUString aComment;
    7972           0 :         Color  aColor;
    7973             :         sal_uInt16 nFlags;
    7974           0 :         pDocSh->GetDocument()->GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
    7975           0 :         return aComment;
    7976             :     }
    7977           0 :     return OUString();
    7978             : }
    7979             : 
    7980           0 : void SAL_CALL ScTableSheetObj::setScenarioComment( const OUString& aScenarioComment )
    7981             :                                                 throw(uno::RuntimeException, std::exception)
    7982             : {
    7983           0 :     SolarMutexGuard aGuard;
    7984           0 :     ScDocShell* pDocSh = GetDocShell();
    7985           0 :     if ( pDocSh )
    7986             :     {
    7987           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    7988           0 :         SCTAB nTab = GetTab_Impl();
    7989             : 
    7990           0 :         OUString aName;
    7991           0 :         OUString aComment;
    7992           0 :         Color  aColor;
    7993             :         sal_uInt16 nFlags;
    7994           0 :         pDoc->GetName( nTab, aName );
    7995           0 :         pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    7996             : 
    7997           0 :         aComment = aScenarioComment;
    7998             : 
    7999           0 :         pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8000           0 :     }
    8001           0 : }
    8002             : 
    8003           0 : void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
    8004             :                                                 throw(uno::RuntimeException, std::exception)
    8005             : {
    8006           0 :     SolarMutexGuard aGuard;
    8007           0 :     ScDocShell* pDocSh = GetDocShell();
    8008           0 :     if ( pDocSh )
    8009             :     {
    8010           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    8011           0 :         SCTAB nTab = GetTab_Impl();
    8012             : 
    8013           0 :         if (pDoc->IsScenario(nTab))
    8014             :         {
    8015           0 :             ScMarkData aMarkData;
    8016           0 :             aMarkData.SelectTable( nTab, true );
    8017             : 
    8018           0 :             sal_uInt16 nRangeCount = (sal_uInt16)rScenRanges.getLength();
    8019           0 :             if (nRangeCount)
    8020             :             {
    8021           0 :                 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
    8022           0 :                 for (sal_uInt16 i=0; i<nRangeCount; i++)
    8023             :                 {
    8024             :                     OSL_ENSURE( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
    8025           0 :                     ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
    8026           0 :                                        (SCCOL)pAry[i].EndColumn,   (SCROW)pAry[i].EndRow,   nTab );
    8027             : 
    8028           0 :                     aMarkData.SetMultiMarkArea( aOneRange );
    8029             :                 }
    8030             :             }
    8031             : 
    8032             :             //  Szenario-Ranges sind durch Attribut gekennzeichnet
    8033           0 :             ScPatternAttr aPattern( pDoc->GetPool() );
    8034           0 :             aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
    8035           0 :             aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
    8036           0 :             pDocSh->GetDocFunc().ApplyAttributes( aMarkData, aPattern, true, true );
    8037             :         }
    8038           0 :     }
    8039           0 : }
    8040             : 
    8041           0 : void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException, std::exception)
    8042             : {
    8043           0 :     SolarMutexGuard aGuard;
    8044           0 :     ScDocShell* pDocSh = GetDocShell();
    8045           0 :     if ( pDocSh )
    8046             :     {
    8047           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    8048           0 :         SCTAB nTab = GetTab_Impl();
    8049           0 :         OUString aName;
    8050           0 :         pDoc->GetName( nTab, aName );       // Name dieses Szenarios
    8051             : 
    8052           0 :         SCTAB nDestTab = nTab;
    8053           0 :         while ( nDestTab > 0 && pDoc->IsScenario(nDestTab) )
    8054           0 :             --nDestTab;
    8055             : 
    8056           0 :         if ( !pDoc->IsScenario(nDestTab) )
    8057           0 :             pDocSh->UseScenario( nDestTab, aName );
    8058             : 
    8059             :         //! sonst Fehler oder so
    8060           0 :     }
    8061           0 : }
    8062             : 
    8063             : // XScenarioEnhanced
    8064             : 
    8065           0 : uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges(  )
    8066             :                                     throw(uno::RuntimeException, std::exception)
    8067             : {
    8068           0 :     SolarMutexGuard aGuard;
    8069           0 :     ScDocShell* pDocSh = GetDocShell();
    8070           0 :     if ( pDocSh )
    8071             :     {
    8072           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    8073           0 :         SCTAB nTab = GetTab_Impl();
    8074           0 :         const ScRangeList* pRangeList = pDoc->GetScenarioRanges(nTab);
    8075           0 :         if (pRangeList)
    8076             :         {
    8077           0 :             size_t nCount = pRangeList->size();
    8078           0 :             uno::Sequence< table::CellRangeAddress > aRetRanges( nCount );
    8079           0 :             table::CellRangeAddress* pAry = aRetRanges.getArray();
    8080           0 :             for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
    8081             :             {
    8082           0 :                 const ScRange* pRange = (*pRangeList)[nIndex];
    8083           0 :                 pAry->StartColumn = pRange->aStart.Col();
    8084           0 :                 pAry->StartRow = pRange->aStart.Row();
    8085           0 :                 pAry->EndColumn = pRange->aEnd.Col();
    8086           0 :                 pAry->EndRow = pRange->aEnd.Row();
    8087           0 :                 pAry->Sheet = pRange->aStart.Tab();
    8088           0 :                 ++pAry;
    8089             :             }
    8090           0 :             return aRetRanges;
    8091             :         }
    8092             :     }
    8093           0 :     return uno::Sequence< table::CellRangeAddress > ();
    8094             : }
    8095             : 
    8096             : // XExternalSheetName
    8097             : 
    8098           0 : void ScTableSheetObj::setExternalName( const OUString& aUrl, const OUString& aSheetName )
    8099             :     throw (container::ElementExistException, uno::RuntimeException, std::exception)
    8100             : {
    8101           0 :     SolarMutexGuard aGuard;
    8102           0 :     ScDocShell* pDocSh = GetDocShell();
    8103           0 :     if ( pDocSh )
    8104             :     {
    8105           0 :         ScDocument* pDoc = pDocSh->GetDocument();
    8106           0 :         if ( pDoc )
    8107             :         {
    8108           0 :             const SCTAB nTab = GetTab_Impl();
    8109           0 :             const OUString aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
    8110           0 :             const OUString aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
    8111           0 :             if ( !pDoc->RenameTab( nTab, aDocTabName, false /*bUpdateRef*/, true /*bExternalDocument*/ ) )
    8112             :             {
    8113           0 :                 throw container::ElementExistException( OUString(), *this );
    8114           0 :             }
    8115             :         }
    8116           0 :     }
    8117           0 : }
    8118             : 
    8119             : // XEventsSupplier
    8120             : 
    8121           0 : uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() throw (uno::RuntimeException, std::exception)
    8122             : {
    8123           0 :     SolarMutexGuard aGuard;
    8124           0 :     ScDocShell* pDocSh = GetDocShell();
    8125           0 :     if ( pDocSh )
    8126           0 :         return new ScSheetEventsObj( pDocSh, GetTab_Impl() );
    8127             : 
    8128           0 :     return NULL;
    8129             : }
    8130             : 
    8131             : // XPropertySet erweitert fuer Sheet-Properties
    8132             : 
    8133         246 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
    8134             :                                                         throw(uno::RuntimeException, std::exception)
    8135             : {
    8136         246 :     SolarMutexGuard aGuard;
    8137             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    8138         246 :         new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
    8139         246 :     return aRef;
    8140             : }
    8141             : 
    8142         959 : void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    8143             :     throw(lang::IllegalArgumentException, uno::RuntimeException,
    8144             :           std::exception)
    8145             : {
    8146         959 :     if ( pEntry )
    8147             :     {
    8148         959 :         if ( IsScItemWid( pEntry->nWID ) )
    8149             :         {
    8150             :             //  for Item WIDs, call ScCellRangesBase directly
    8151           0 :             ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
    8152           0 :             return;
    8153             :         }
    8154             : 
    8155             :         //  own properties
    8156             : 
    8157         959 :         ScDocShell* pDocSh = GetDocShell();
    8158         959 :         if (!pDocSh)
    8159           0 :             return;                                                 //! Exception oder so?
    8160         959 :         ScDocument* pDoc = pDocSh->GetDocument();
    8161         959 :         SCTAB nTab = GetTab_Impl();
    8162         959 :         ScDocFunc &rFunc = pDocSh->GetDocFunc();
    8163             : 
    8164         959 :         if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
    8165             :         {
    8166         223 :             OUString aStrVal;
    8167         223 :             aValue >>= aStrVal;
    8168             :             OUString aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
    8169         446 :                                                 aStrVal, SFX_STYLE_FAMILY_PAGE ));
    8170             : 
    8171             :             //! Undo? (auch bei SID_STYLE_APPLY an der View)
    8172             : 
    8173         223 :             if ( pDoc->GetPageStyle( nTab ) != aNewStr )
    8174             :             {
    8175          11 :                 pDoc->SetPageStyle( nTab, aNewStr );
    8176          11 :                 if (!pDoc->IsImportingXML())
    8177             :                 {
    8178           2 :                     ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
    8179             : 
    8180           2 :                     SfxBindings* pBindings = pDocSh->GetViewBindings();
    8181           2 :                     if (pBindings)
    8182             :                     {
    8183           2 :                         pBindings->Invalidate( SID_STYLE_FAMILY4 );
    8184           2 :                         pBindings->Invalidate( SID_STATUS_PAGESTYLE );
    8185           2 :                         pBindings->Invalidate( FID_RESET_PRINTZOOM );
    8186           2 :                         pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
    8187           2 :                         pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
    8188             :                     }
    8189             :                 }
    8190          11 :                 pDocSh->SetDocumentModified();
    8191         223 :             }
    8192             :         }
    8193         736 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8194             :         {
    8195         352 :             sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8196         352 :             rFunc.SetTableVisible( nTab, bVis, true );
    8197             :         }
    8198         384 :         else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
    8199             :         {
    8200           0 :             if (pDoc->IsScenario(nTab))
    8201           0 :                 pDoc->SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
    8202             :         }
    8203         384 :         else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
    8204             :         {
    8205           0 :             if (pDoc->IsScenario(nTab))
    8206             :             {
    8207           0 :                 sal_Int32 nNewColor = 0;
    8208           0 :                 if (aValue >>= nNewColor)
    8209             :                 {
    8210           0 :                     OUString aName;
    8211           0 :                     OUString aComment;
    8212           0 :                     Color  aColor;
    8213             :                     sal_uInt16 nFlags;
    8214           0 :                     pDoc->GetName( nTab, aName );
    8215           0 :                     pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8216             : 
    8217           0 :                     aColor = Color(static_cast<sal_uInt32>(nNewColor));
    8218             : 
    8219           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8220             :                 }
    8221             :             }
    8222             :         }
    8223         384 :         else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
    8224             :         {
    8225           0 :             if (pDoc->IsScenario(nTab))
    8226             :             {
    8227           0 :                 OUString aName;
    8228           0 :                 OUString aComment;
    8229           0 :                 Color  aColor;
    8230             :                 sal_uInt16 nFlags;
    8231           0 :                 pDoc->GetName( nTab, aName );
    8232           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8233           0 :                 sal_Bool bModify(false);
    8234             : 
    8235           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8236             :                 {
    8237           0 :                     if (!(nFlags & SC_SCENARIO_PROTECT))
    8238             :                     {
    8239           0 :                         nFlags |= SC_SCENARIO_PROTECT;
    8240           0 :                         bModify = sal_True;
    8241             :                     }
    8242             :                 }
    8243             :                 else
    8244             :                 {
    8245           0 :                     if (nFlags & SC_SCENARIO_PROTECT)
    8246             :                     {
    8247           0 :                         nFlags -= SC_SCENARIO_PROTECT;
    8248           0 :                         bModify = sal_True;
    8249             :                     }
    8250             :                 }
    8251             : 
    8252           0 :                 if (bModify)
    8253           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8254             :             }
    8255             :         }
    8256         384 :         else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
    8257             :         {
    8258           0 :             if (pDoc->IsScenario(nTab))
    8259             :             {
    8260           0 :                 OUString aName;
    8261           0 :                 OUString aComment;
    8262           0 :                 Color  aColor;
    8263             :                 sal_uInt16 nFlags;
    8264           0 :                 pDoc->GetName( nTab, aName );
    8265           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8266           0 :                 sal_Bool bModify(false);
    8267             : 
    8268           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8269             :                 {
    8270           0 :                     if (!(nFlags & SC_SCENARIO_SHOWFRAME))
    8271             :                     {
    8272           0 :                         nFlags |= SC_SCENARIO_SHOWFRAME;
    8273           0 :                         bModify = sal_True;
    8274             :                     }
    8275             :                 }
    8276             :                 else
    8277             :                 {
    8278           0 :                     if (nFlags & SC_SCENARIO_SHOWFRAME)
    8279             :                     {
    8280           0 :                         nFlags -= SC_SCENARIO_SHOWFRAME;
    8281           0 :                         bModify = sal_True;
    8282             :                     }
    8283             :                 }
    8284             : 
    8285           0 :                 if (bModify)
    8286           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8287             :             }
    8288             :         }
    8289         384 :         else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
    8290             :         {
    8291           0 :             if (pDoc->IsScenario(nTab))
    8292             :             {
    8293           0 :                 OUString aName;
    8294           0 :                 OUString aComment;
    8295           0 :                 Color  aColor;
    8296             :                 sal_uInt16 nFlags;
    8297           0 :                 pDoc->GetName( nTab, aName );
    8298           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8299           0 :                 sal_Bool bModify(false);
    8300             : 
    8301           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8302             :                 {
    8303           0 :                     if (!(nFlags & SC_SCENARIO_PRINTFRAME))
    8304             :                     {
    8305           0 :                         nFlags |= SC_SCENARIO_PRINTFRAME;
    8306           0 :                         bModify = sal_True;
    8307             :                     }
    8308             :                 }
    8309             :                 else
    8310             :                 {
    8311           0 :                     if (nFlags & SC_SCENARIO_PRINTFRAME)
    8312             :                     {
    8313           0 :                         nFlags -= SC_SCENARIO_PRINTFRAME;
    8314           0 :                         bModify = sal_True;
    8315             :                     }
    8316             :                 }
    8317             : 
    8318           0 :                 if (bModify)
    8319           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8320             :             }
    8321             :         }
    8322         384 :         else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
    8323             :         {
    8324           0 :             if (pDoc->IsScenario(nTab))
    8325             :             {
    8326           0 :                 OUString aName;
    8327           0 :                 OUString aComment;
    8328           0 :                 Color  aColor;
    8329             :                 sal_uInt16 nFlags;
    8330           0 :                 pDoc->GetName( nTab, aName );
    8331           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8332           0 :                 sal_Bool bModify(false);
    8333             : 
    8334           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8335             :                 {
    8336           0 :                     if (!(nFlags & SC_SCENARIO_TWOWAY))
    8337             :                     {
    8338           0 :                         nFlags |= SC_SCENARIO_TWOWAY;
    8339           0 :                         bModify = sal_True;
    8340             :                     }
    8341             :                 }
    8342             :                 else
    8343             :                 {
    8344           0 :                     if (nFlags & SC_SCENARIO_TWOWAY)
    8345             :                     {
    8346           0 :                         nFlags -= SC_SCENARIO_TWOWAY;
    8347           0 :                         bModify = sal_True;
    8348             :                     }
    8349             :                 }
    8350             : 
    8351           0 :                 if (bModify)
    8352           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8353             :             }
    8354             :         }
    8355         384 :         else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
    8356             :         {
    8357           0 :             if (pDoc->IsScenario(nTab))
    8358             :             {
    8359           0 :                 OUString aName;
    8360           0 :                 OUString aComment;
    8361           0 :                 Color  aColor;
    8362             :                 sal_uInt16 nFlags;
    8363           0 :                 pDoc->GetName( nTab, aName );
    8364           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8365           0 :                 sal_Bool bModify(false);
    8366             : 
    8367           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8368             :                 {
    8369           0 :                     if (!(nFlags & SC_SCENARIO_ATTRIB))
    8370             :                     {
    8371           0 :                         nFlags |= SC_SCENARIO_ATTRIB;
    8372           0 :                         bModify = sal_True;
    8373             :                     }
    8374             :                 }
    8375             :                 else
    8376             :                 {
    8377           0 :                     if (nFlags & SC_SCENARIO_ATTRIB)
    8378             :                     {
    8379           0 :                         nFlags -= SC_SCENARIO_ATTRIB;
    8380           0 :                         bModify = sal_True;
    8381             :                     }
    8382             :                 }
    8383             : 
    8384           0 :                 if (bModify)
    8385           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8386             :             }
    8387             :         }
    8388         384 :         else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
    8389             :         {
    8390           0 :             if (pDoc->IsScenario(nTab))
    8391             :             {
    8392           0 :                 OUString aName;
    8393           0 :                 OUString aComment;
    8394           0 :                 Color  aColor;
    8395             :                 sal_uInt16 nFlags;
    8396           0 :                 pDoc->GetName( nTab, aName );
    8397           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8398           0 :                 sal_Bool bModify(false);
    8399             : 
    8400           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8401             :                 {
    8402           0 :                     if (nFlags & SC_SCENARIO_VALUE)
    8403             :                     {
    8404           0 :                         nFlags -= SC_SCENARIO_VALUE;
    8405           0 :                         bModify = sal_True;
    8406             :                     }
    8407             :                 }
    8408             :                 else
    8409             :                 {
    8410           0 :                     if (!(nFlags & SC_SCENARIO_VALUE))
    8411             :                     {
    8412           0 :                         nFlags |= SC_SCENARIO_VALUE;
    8413           0 :                         bModify = sal_True;
    8414             :                     }
    8415             :                 }
    8416             : 
    8417           0 :                 if (bModify)
    8418           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8419             :             }
    8420             :         }
    8421         384 :         else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
    8422             :         {
    8423         210 :             sal_Int16 nValue = 0;
    8424         210 :             if (aValue >>= nValue)
    8425             :             {
    8426         210 :                 if (nValue == com::sun::star::text::WritingMode2::RL_TB)
    8427           2 :                     rFunc.SetLayoutRTL(nTab, true, true);
    8428             :                 else
    8429         208 :                     rFunc.SetLayoutRTL(nTab, false, true);
    8430             :             }
    8431             :         }
    8432         174 :         else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
    8433             :         {
    8434           0 :             sal_Bool bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8435           0 :             if (bAutoPrint)
    8436           0 :                 pDoc->SetPrintEntireSheet( nTab ); // clears all print ranges
    8437             :             else
    8438             :             {
    8439           0 :                 if (pDoc->IsPrintEntireSheet( nTab ))
    8440           0 :                     pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
    8441             :             }
    8442             :         }
    8443         174 :         else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
    8444             :         {
    8445          87 :             sal_Int32 nColor = COL_AUTO;
    8446          87 :             if ( aValue >>= nColor )
    8447             :             {
    8448          87 :                 const Color aColor( static_cast< ColorData >( nColor ) );
    8449          87 :                 if ( pDoc->GetTabBgColor( nTab ) != aColor )
    8450          34 :                     rFunc.SetTabBgColor( nTab, aColor, true, true );
    8451             :             }
    8452             :         }
    8453          87 :         else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
    8454             :         {
    8455          85 :             OUString aCodeName;
    8456          85 :             if ( pDocSh && ( aValue >>= aCodeName ) )
    8457             :             {
    8458          85 :                 pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), aCodeName );
    8459          85 :             }
    8460             :         }
    8461             :         else
    8462           2 :             ScCellRangeObj::SetOnePropertyValue(pEntry, aValue);        // base class, no Item WID
    8463             :     }
    8464             : }
    8465             : 
    8466        1842 : void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
    8467             :                                             uno::Any& rAny )
    8468             :     throw(uno::RuntimeException,
    8469             :           std::exception)
    8470             : {
    8471        1842 :     if ( pEntry )
    8472             :     {
    8473        1842 :         ScDocShell* pDocSh = GetDocShell();
    8474        1842 :         if (!pDocSh)
    8475           0 :             throw uno::RuntimeException();
    8476        1842 :         ScDocument* pDoc = pDocSh->GetDocument();
    8477        1842 :         SCTAB nTab = GetTab_Impl();
    8478             : 
    8479        1842 :         if ( pEntry->nWID == SC_WID_UNO_NAMES )
    8480             :         {
    8481           0 :             rAny <<= uno::Reference<sheet::XNamedRanges>(new ScLocalNamedRangesObj(pDocSh, this));
    8482             :         }
    8483        1842 :         else if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
    8484             :         {
    8485         164 :             rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
    8486          82 :                                 pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
    8487             :         }
    8488        1760 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8489             :         {
    8490          26 :             sal_Bool bVis = pDoc->IsVisible( nTab );
    8491          26 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
    8492             :         }
    8493        1734 :         else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
    8494             :         {
    8495             :             //  no target bitmaps for individual entries (would be all equal)
    8496             :             // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
    8497             :         }
    8498        1734 :         else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
    8499             :         {
    8500             :             //  LinkDisplayName for hyperlink dialog
    8501           0 :             rAny <<= getName();     // sheet name
    8502             :         }
    8503        1734 :         else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
    8504             :         {
    8505           0 :             if (pDoc->IsScenario(nTab))
    8506           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, pDoc->IsActiveScenario( nTab ));
    8507             :         }
    8508        1734 :         else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
    8509             :         {
    8510           0 :             if (pDoc->IsScenario(nTab))
    8511             :             {
    8512           0 :                 OUString aComment;
    8513           0 :                 Color  aColor;
    8514             :                 sal_uInt16 nFlags;
    8515           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8516             : 
    8517           0 :                 rAny <<= static_cast<sal_Int32>(aColor.GetColor());
    8518             :             }
    8519             :         }
    8520        1734 :         else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
    8521             :         {
    8522           0 :             if (pDoc->IsScenario(nTab))
    8523             :             {
    8524           0 :                 OUString aComment;
    8525           0 :                 Color  aColor;
    8526             :                 sal_uInt16 nFlags;
    8527           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8528             : 
    8529           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
    8530             :             }
    8531             :         }
    8532        1734 :         else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
    8533             :         {
    8534           0 :             if (pDoc->IsScenario(nTab))
    8535             :             {
    8536           0 :                 OUString aComment;
    8537           0 :                 Color  aColor;
    8538             :                 sal_uInt16 nFlags;
    8539           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8540             : 
    8541           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
    8542             :             }
    8543             :         }
    8544        1734 :         else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
    8545             :         {
    8546           0 :             if (pDoc->IsScenario(nTab))
    8547             :             {
    8548           0 :                 OUString aComment;
    8549           0 :                 Color  aColor;
    8550             :                 sal_uInt16 nFlags;
    8551           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8552             : 
    8553           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
    8554             :             }
    8555             :         }
    8556        1734 :         else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
    8557             :         {
    8558           0 :             if (pDoc->IsScenario(nTab))
    8559             :             {
    8560           0 :                 OUString aComment;
    8561           0 :                 Color  aColor;
    8562             :                 sal_uInt16 nFlags;
    8563           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8564             : 
    8565           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
    8566             :             }
    8567             :         }
    8568        1734 :         else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
    8569             :         {
    8570           0 :             if (pDoc->IsScenario(nTab))
    8571             :             {
    8572           0 :                 OUString aComment;
    8573           0 :                 Color  aColor;
    8574             :                 sal_uInt16 nFlags;
    8575           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8576             : 
    8577           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
    8578             :             }
    8579             :         }
    8580        1734 :         else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
    8581             :         {
    8582           0 :             if (pDoc->IsScenario(nTab))
    8583             :             {
    8584           0 :                 OUString aComment;
    8585           0 :                 Color  aColor;
    8586             :                 sal_uInt16 nFlags;
    8587           0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
    8588             : 
    8589           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
    8590             :             }
    8591             :         }
    8592        1734 :         else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
    8593             :         {
    8594          30 :             if (pDoc->IsLayoutRTL(nTab))
    8595           4 :                 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
    8596             :             else
    8597          26 :                 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
    8598             :         }
    8599        1704 :         else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
    8600             :         {
    8601           0 :             sal_Bool bAutoPrint = pDoc->IsPrintEntireSheet( nTab );
    8602           0 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
    8603             :         }
    8604        1704 :         else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
    8605             :         {
    8606          22 :             rAny <<= sal_Int32(pDoc->GetTabBgColor(nTab).GetColor());
    8607             :         }
    8608        1682 :         else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
    8609             :         {
    8610        1677 :             OUString aCodeName;
    8611        1677 :             if ( pDocSh )
    8612        1677 :                 pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName );
    8613        1677 :             rAny <<= OUString( aCodeName );
    8614             :         }
    8615             :         else
    8616           5 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    8617             :     }
    8618        1842 : }
    8619             : 
    8620        2306 : const SfxItemPropertyMap& ScTableSheetObj::GetItemPropertyMap()
    8621             : {
    8622        2306 :     return pSheetPropSet->getPropertyMap();
    8623             : }
    8624             : 
    8625             : // XServiceInfo
    8626             : 
    8627           0 : OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    8628             : {
    8629           0 :     return OUString( "ScTableSheetObj" );
    8630             : }
    8631             : 
    8632           0 : sal_Bool SAL_CALL ScTableSheetObj::supportsService( const OUString& rServiceName )
    8633             :                                                     throw(uno::RuntimeException, std::exception)
    8634             : {
    8635           0 :     return cppu::supportsService(this, rServiceName);
    8636             : }
    8637             : 
    8638           0 : uno::Sequence<OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
    8639             :                                                     throw(uno::RuntimeException, std::exception)
    8640             : {
    8641           0 :     uno::Sequence<OUString> aRet(7);
    8642           0 :     OUString* pArray = aRet.getArray();
    8643           0 :     pArray[0] = OUString( SCSPREADSHEET_SERVICE );
    8644           0 :     pArray[1] = OUString( SCSHEETCELLRANGE_SERVICE );
    8645           0 :     pArray[2] = OUString( SCCELLRANGE_SERVICE );
    8646           0 :     pArray[3] = OUString( SCCELLPROPERTIES_SERVICE );
    8647           0 :     pArray[4] = OUString( SCCHARPROPERTIES_SERVICE );
    8648           0 :     pArray[5] = OUString( SCPARAPROPERTIES_SERVICE );
    8649           0 :     pArray[6] = OUString( SCLINKTARGET_SERVICE );
    8650           0 :     return aRet;
    8651             : }
    8652             : 
    8653             : // XUnoTunnel
    8654             : 
    8655        3425 : sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
    8656             :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
    8657             : {
    8658        6850 :     if ( rId.getLength() == 16 &&
    8659        3425 :           0 == memcmp( getUnoTunnelId().getConstArray(),
    8660        6850 :                                     rId.getConstArray(), 16 ) )
    8661             :     {
    8662         313 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
    8663             :     }
    8664             : 
    8665        3112 :     return ScCellRangeObj::getSomething( rId );
    8666             : }
    8667             : 
    8668             : namespace
    8669             : {
    8670             :     class theScTableSheetObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableSheetObjUnoTunnelId> {};
    8671             : }
    8672             : 
    8673        6273 : const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
    8674             : {
    8675        6273 :     return theScTableSheetObjUnoTunnelId::get().getSeq();
    8676             : }
    8677             : 
    8678        2848 : ScTableSheetObj* ScTableSheetObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
    8679             : {
    8680        2848 :     ScTableSheetObj* pRet = NULL;
    8681        2848 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
    8682        2848 :     if (xUT.is())
    8683        2848 :         pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
    8684        2848 :     return pRet;
    8685             : }
    8686             : 
    8687        1088 : ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
    8688             :     ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
    8689        1088 :     pColPropSet(lcl_GetColumnPropertySet())
    8690             : {
    8691        1088 : }
    8692             : 
    8693        2174 : ScTableColumnObj::~ScTableColumnObj()
    8694             : {
    8695        2174 : }
    8696             : 
    8697        1164 : uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    8698             : {
    8699        1164 :     SC_QUERYINTERFACE( container::XNamed )
    8700             : 
    8701        1164 :     return ScCellRangeObj::queryInterface( rType );
    8702             : }
    8703             : 
    8704        6654 : void SAL_CALL ScTableColumnObj::acquire() throw()
    8705             : {
    8706        6654 :     ScCellRangeObj::acquire();
    8707        6654 : }
    8708             : 
    8709        6651 : void SAL_CALL ScTableColumnObj::release() throw()
    8710             : {
    8711        6651 :     ScCellRangeObj::release();
    8712        6651 : }
    8713             : 
    8714           0 : uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException, std::exception)
    8715             : {
    8716           0 :     static uno::Sequence<uno::Type> aTypes;
    8717           0 :     if ( aTypes.getLength() == 0 )
    8718             :     {
    8719           0 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
    8720           0 :         long nParentLen = aParentTypes.getLength();
    8721           0 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    8722             : 
    8723           0 :         aTypes.realloc( nParentLen + 1 );
    8724           0 :         uno::Type* pPtr = aTypes.getArray();
    8725           0 :         pPtr[nParentLen + 0] = getCppuType((const uno::Reference<container::XNamed>*)0);
    8726             : 
    8727           0 :         for (long i=0; i<nParentLen; i++)
    8728           0 :             pPtr[i] = pParentPtr[i];                // parent types first
    8729             :     }
    8730           0 :     return aTypes;
    8731             : }
    8732             : 
    8733           0 : uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException, std::exception)
    8734             : {
    8735           0 :     return css::uno::Sequence<sal_Int8>();
    8736             : }
    8737             : 
    8738             : // XNamed
    8739             : 
    8740           0 : OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException, std::exception)
    8741             : {
    8742           0 :     SolarMutexGuard aGuard;
    8743             : 
    8744           0 :     const ScRange& rRange = GetRange();
    8745             :     OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
    8746           0 :     SCCOL nCol = rRange.aStart.Col();
    8747             : 
    8748           0 :     return ScColToAlpha( nCol );        // from global.hxx
    8749             : }
    8750             : 
    8751           0 : void SAL_CALL ScTableColumnObj::setName( const OUString& /* aNewName */ )
    8752             :                                                 throw(uno::RuntimeException, std::exception)
    8753             : {
    8754           0 :     SolarMutexGuard aGuard;
    8755           0 :     throw uno::RuntimeException();      // read-only
    8756             : }
    8757             : 
    8758             : // XPropertySet erweitert fuer Spalten-Properties
    8759             : 
    8760          29 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
    8761             :                                                         throw(uno::RuntimeException, std::exception)
    8762             : {
    8763          29 :     SolarMutexGuard aGuard;
    8764             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    8765          29 :         new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
    8766          29 :     return aRef;
    8767             : }
    8768             : 
    8769           4 : void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue)
    8770             :     throw(lang::IllegalArgumentException, uno::RuntimeException,
    8771             :           std::exception)
    8772             : {
    8773           4 :     if ( pEntry )
    8774             :     {
    8775           4 :         if ( IsScItemWid( pEntry->nWID ) )
    8776             :         {
    8777             :             //  for Item WIDs, call ScCellRangesBase directly
    8778           0 :             ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
    8779           0 :             return;
    8780             :         }
    8781             : 
    8782             :         //  own properties
    8783             : 
    8784           4 :         ScDocShell* pDocSh = GetDocShell();
    8785           4 :         if (!pDocSh)
    8786           0 :             return;                                                 //! Exception oder so?
    8787           4 :         const ScRange& rRange = GetRange();
    8788             :         OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
    8789           4 :         SCCOL nCol = rRange.aStart.Col();
    8790           4 :         SCTAB nTab = rRange.aStart.Tab();
    8791           4 :         ScDocFunc &rFunc = pDocSh->GetDocFunc();
    8792             : 
    8793           4 :         std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nCol,nCol));
    8794             : 
    8795           4 :         if ( pEntry->nWID == SC_WID_UNO_CELLWID )
    8796             :         {
    8797           0 :             sal_Int32 nNewWidth = 0;
    8798           0 :             if ( aValue >>= nNewWidth )
    8799             :             {
    8800             :                 //  property is 1/100mm, column width is twips
    8801           0 :                 nNewWidth = HMMToTwips(nNewWidth);
    8802             :                 rFunc.SetWidthOrHeight(
    8803           0 :                     true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewWidth, true, true);
    8804             :             }
    8805             :         }
    8806           4 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8807             :         {
    8808           0 :             sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8809           0 :             ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
    8810           0 :             rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true);
    8811             :             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
    8812             :         }
    8813           4 :         else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
    8814             :         {
    8815           2 :             sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8816           2 :             if (bOpt)
    8817             :                 rFunc.SetWidthOrHeight(
    8818           2 :                     true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true);
    8819             :             // sal_False bei Spalten momentan ohne Auswirkung
    8820             :         }
    8821           2 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
    8822             :         {
    8823           2 :             sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8824           2 :             if (bSet)
    8825           1 :                 rFunc.InsertPageBreak( true, rRange.aStart, true, true, true );
    8826             :             else
    8827           1 :                 rFunc.RemovePageBreak( true, rRange.aStart, true, true, true );
    8828             :         }
    8829             :         else
    8830           0 :             ScCellRangeObj::SetOnePropertyValue(pEntry, aValue);        // base class, no Item WID
    8831             :     }
    8832             : }
    8833             : 
    8834          89 : void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    8835             :     throw(uno::RuntimeException, std::exception)
    8836             : {
    8837          89 :     if ( pEntry )
    8838             :     {
    8839          89 :         ScDocShell* pDocSh = GetDocShell();
    8840          89 :         if (!pDocSh)
    8841           0 :             throw uno::RuntimeException();
    8842             : 
    8843          89 :         ScDocument* pDoc = pDocSh->GetDocument();
    8844          89 :         const ScRange& rRange = GetRange();
    8845             :         OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
    8846          89 :         SCCOL nCol = rRange.aStart.Col();
    8847          89 :         SCTAB nTab = rRange.aStart.Tab();
    8848             : 
    8849          89 :         if ( pEntry->nWID == SC_WID_UNO_CELLWID )
    8850             :         {
    8851             :             // for hidden column, return original height
    8852          29 :             sal_uInt16 nWidth = pDoc->GetOriginalWidth( nCol, nTab );
    8853             :             //  property is 1/100mm, column width is twips
    8854          29 :             nWidth = (sal_uInt16) TwipsToHMM(nWidth);
    8855          29 :             rAny <<= (sal_Int32)( nWidth );
    8856             :         }
    8857          60 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8858             :         {
    8859          29 :             bool bHidden = pDoc->ColHidden(nCol, nTab);
    8860          29 :             ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
    8861             :         }
    8862          31 :         else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
    8863             :         {
    8864             :             //! momentan immer gesetzt ??!?!
    8865           0 :             sal_Bool bOpt = !(pDoc->GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
    8866           0 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
    8867             :         }
    8868          31 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
    8869             :         {
    8870           2 :             ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
    8871           2 :             ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
    8872             :         }
    8873          29 :         else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
    8874             :         {
    8875          29 :             ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
    8876          29 :             ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL) != 0);
    8877             :         }
    8878             :         else
    8879           0 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    8880             :     }
    8881          89 : }
    8882             : 
    8883          35 : const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap()
    8884             : {
    8885          35 :     return pColPropSet->getPropertyMap();
    8886             : }
    8887             : 
    8888         107 : ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
    8889             :     ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
    8890         107 :     pRowPropSet(lcl_GetRowPropertySet())
    8891             : {
    8892         107 : }
    8893             : 
    8894         214 : ScTableRowObj::~ScTableRowObj()
    8895             : {
    8896         214 : }
    8897             : 
    8898             : // XPropertySet erweitert fuer Zeilen-Properties
    8899             : 
    8900          49 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
    8901             :                                                         throw(uno::RuntimeException, std::exception)
    8902             : {
    8903          49 :     SolarMutexGuard aGuard;
    8904             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    8905          49 :         new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
    8906          49 :     return aRef;
    8907             : }
    8908             : 
    8909           4 : void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    8910             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    8911             : {
    8912           4 :     if ( pEntry )
    8913             :     {
    8914           4 :         if ( IsScItemWid( pEntry->nWID ) )
    8915             :         {
    8916             :             //  for Item WIDs, call ScCellRangesBase directly
    8917           0 :             ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
    8918           0 :             return;
    8919             :         }
    8920             : 
    8921             :         //  own properties
    8922             : 
    8923           4 :         ScDocShell* pDocSh = GetDocShell();
    8924           4 :         if (!pDocSh)
    8925           0 :             return;                                                 //! Exception oder so?
    8926           4 :         ScDocument* pDoc = pDocSh->GetDocument();
    8927           4 :         const ScRange& rRange = GetRange();
    8928             :         OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
    8929           4 :         SCROW nRow = rRange.aStart.Row();
    8930           4 :         SCTAB nTab = rRange.aStart.Tab();
    8931           4 :         ScDocFunc &rFunc = pDocSh->GetDocFunc();
    8932             : 
    8933           4 :         std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow,nRow));
    8934             : 
    8935           4 :         if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
    8936             :         {
    8937           0 :             sal_Int32 nNewHeight = 0;
    8938           0 :             if ( aValue >>= nNewHeight )
    8939             :             {
    8940             :                 //  property is 1/100mm, row height is twips
    8941           0 :                 nNewHeight = HMMToTwips(nNewHeight);
    8942             :                 rFunc.SetWidthOrHeight(
    8943           0 :                     false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewHeight, true, true);
    8944             :             }
    8945             :         }
    8946           4 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8947             :         {
    8948           2 :             sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8949           2 :             ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
    8950           2 :             rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true);
    8951             :             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
    8952             :         }
    8953           2 :         else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
    8954             :         {
    8955           0 :             sal_Bool bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8956             :             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
    8957           0 :             pDoc->SetRowFiltered(nRow, nRow, nTab, bFil);
    8958             :         }
    8959           2 :         else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
    8960             :         {
    8961           0 :             sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8962           0 :             if (bOpt)
    8963           0 :                 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
    8964             :             else
    8965             :             {
    8966             :                 //  set current height again manually
    8967           0 :                 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
    8968           0 :                 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true);
    8969             :             }
    8970             :         }
    8971           2 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
    8972             :         {
    8973           2 :             sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8974           2 :             if (bSet)
    8975           1 :                 rFunc.InsertPageBreak( false, rRange.aStart, true, true, true );
    8976             :             else
    8977           1 :                 rFunc.RemovePageBreak( false, rRange.aStart, true, true, true );
    8978             :         }
    8979             :         else
    8980           0 :             ScCellRangeObj::SetOnePropertyValue(pEntry, aValue);        // base class, no Item WID
    8981             :     }
    8982             : }
    8983             : 
    8984         158 : void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    8985             :     throw(uno::RuntimeException, std::exception)
    8986             : {
    8987         158 :     if ( pEntry )
    8988             :     {
    8989         158 :         ScDocShell* pDocSh = GetDocShell();
    8990         158 :         if (!pDocSh)
    8991           0 :             throw uno::RuntimeException();
    8992         158 :         ScDocument* pDoc = pDocSh->GetDocument();
    8993         158 :         const ScRange& rRange = GetRange();
    8994             :         OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
    8995         158 :         SCROW nRow = rRange.aStart.Row();
    8996         158 :         SCTAB nTab = rRange.aStart.Tab();
    8997             : 
    8998         158 :         if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
    8999             :         {
    9000             :             // for hidden row, return original height
    9001          49 :             sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
    9002             :             //  property is 1/100mm, row height is twips
    9003          49 :             nHeight = (sal_uInt16) TwipsToHMM(nHeight);
    9004          49 :             rAny <<= (sal_Int32)( nHeight );
    9005             :         }
    9006         109 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    9007             :         {
    9008           9 :             bool bHidden = pDoc->RowHidden(nRow, nTab);
    9009           9 :             ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
    9010             :         }
    9011         100 :         else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
    9012             :         {
    9013           0 :             bool bVis = pDoc->RowFiltered(nRow, nTab);
    9014           0 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
    9015             :         }
    9016         100 :         else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
    9017             :         {
    9018          49 :             sal_Bool bOpt = !(pDoc->GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
    9019          49 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
    9020             :         }
    9021          51 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
    9022             :         {
    9023           2 :             ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab);
    9024           2 :             ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
    9025             :         }
    9026          49 :         else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
    9027             :         {
    9028          49 :             ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL);
    9029          49 :             ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
    9030             :         }
    9031             :         else
    9032           0 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    9033             :     }
    9034         158 : }
    9035             : 
    9036          64 : const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap()
    9037             : {
    9038          64 :     return pRowPropSet->getPropertyMap();
    9039             : }
    9040             : 
    9041           4 : ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
    9042             :     pDocShell( pDocSh ),
    9043           4 :     aRanges( rR )
    9044             : {
    9045           4 :     pDocShell->GetDocument()->AddUnoObject(*this);
    9046           4 : }
    9047             : 
    9048          12 : ScCellsObj::~ScCellsObj()
    9049             : {
    9050           4 :     if (pDocShell)
    9051           0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    9052           8 : }
    9053             : 
    9054           8 : void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9055             : {
    9056           8 :     if ( rHint.ISA( ScUpdateRefHint ) )
    9057             :     {
    9058           0 :         const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
    9059           0 :         aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
    9060           0 :                                         rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
    9061             :     }
    9062          16 :     else if ( rHint.ISA( SfxSimpleHint ) &&
    9063           8 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
    9064             :     {
    9065           4 :         pDocShell = NULL;       // ungueltig geworden
    9066             :     }
    9067           8 : }
    9068             : 
    9069             : // XEnumerationAccess
    9070             : 
    9071           3 : uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
    9072             :                                                     throw(uno::RuntimeException, std::exception)
    9073             : {
    9074           3 :     SolarMutexGuard aGuard;
    9075           3 :     if (pDocShell)
    9076           3 :         return new ScCellsEnumeration( pDocShell, aRanges );
    9077           0 :     return NULL;
    9078             : }
    9079             : 
    9080           1 : uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException, std::exception)
    9081             : {
    9082           1 :     SolarMutexGuard aGuard;
    9083           1 :     return getCppuType((uno::Reference<table::XCell>*)0);
    9084             : }
    9085             : 
    9086           1 : sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException, std::exception)
    9087             : {
    9088           1 :     SolarMutexGuard aGuard;
    9089           1 :     sal_Bool bHas = false;
    9090           1 :     if ( pDocShell )
    9091             :     {
    9092             :         //! schneller selber testen?
    9093             : 
    9094           1 :         uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
    9095           1 :         bHas = xEnum->hasMoreElements();
    9096             :     }
    9097           1 :     return bHas;
    9098             : }
    9099             : 
    9100           4 : ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
    9101             :     pDocShell( pDocSh ),
    9102             :     aRanges( rR ),
    9103             :     pMark( NULL ),
    9104           4 :     bAtEnd( false )
    9105             : {
    9106           4 :     ScDocument* pDoc = pDocShell->GetDocument();
    9107           4 :     pDoc->AddUnoObject(*this);
    9108             : 
    9109           4 :     if ( aRanges.empty() )
    9110           0 :         bAtEnd = true;
    9111             :     else
    9112             :     {
    9113           4 :         SCTAB nTab = 0;
    9114           4 :         const ScRange* pFirst = aRanges[ 0 ];
    9115           4 :         if (pFirst)
    9116           4 :             nTab = pFirst->aStart.Tab();
    9117           4 :         aPos = ScAddress(0,0,nTab);
    9118           4 :         CheckPos_Impl();                    // aPos auf erste passende Zelle setzen
    9119             :     }
    9120           4 : }
    9121             : 
    9122           4 : void ScCellsEnumeration::CheckPos_Impl()
    9123             : {
    9124           4 :     if (!pDocShell)
    9125           4 :         return;
    9126             : 
    9127           4 :     bool bFound = false;
    9128           4 :     ScDocument* pDoc = pDocShell->GetDocument();
    9129           4 :     ScRefCellValue aCell;
    9130           4 :     aCell.assign(*pDoc, aPos);
    9131           4 :     if (!aCell.isEmpty())
    9132             :     {
    9133           4 :         if (!pMark)
    9134             :         {
    9135           4 :             pMark = new ScMarkData;
    9136           4 :             pMark->MarkFromRangeList(aRanges, false);
    9137           4 :             pMark->MarkToMulti();   // needed for GetNextMarkedCell
    9138             :         }
    9139           4 :         bFound = pMark->IsCellMarked(aPos.Col(), aPos.Row());
    9140             :     }
    9141           4 :     if (!bFound)
    9142           1 :         Advance_Impl();
    9143             : }
    9144             : 
    9145          12 : ScCellsEnumeration::~ScCellsEnumeration()
    9146             : {
    9147           4 :     if (pDocShell)
    9148           1 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    9149           4 :     delete pMark;
    9150           8 : }
    9151             : 
    9152           2 : void ScCellsEnumeration::Advance_Impl()
    9153             : {
    9154             :     OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
    9155           2 :     if (!pMark)
    9156             :     {
    9157           0 :         pMark = new ScMarkData;
    9158           0 :         pMark->MarkFromRangeList( aRanges, false );
    9159           0 :         pMark->MarkToMulti();   // needed for GetNextMarkedCell
    9160             :     }
    9161             : 
    9162           2 :     SCCOL nCol = aPos.Col();
    9163           2 :     SCROW nRow = aPos.Row();
    9164           2 :     SCTAB nTab = aPos.Tab();
    9165           2 :     sal_Bool bFound = pDocShell->GetDocument()->GetNextMarkedCell( nCol, nRow, nTab, *pMark );
    9166           2 :     if (bFound)
    9167           1 :         aPos.Set( nCol, nRow, nTab );
    9168             :     else
    9169           1 :         bAtEnd = true;      // kommt nix mehr
    9170           2 : }
    9171             : 
    9172           7 : void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9173             : {
    9174           7 :     if ( rHint.ISA( ScUpdateRefHint ) )
    9175             :     {
    9176           0 :         if (pDocShell)
    9177             :         {
    9178           0 :             const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
    9179           0 :             aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
    9180           0 :                                             rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
    9181             : 
    9182           0 :             delete pMark;       // aus verschobenen Bereichen neu erzeugen
    9183           0 :             pMark = NULL;
    9184             : 
    9185           0 :             if (!bAtEnd)        // aPos anpassen
    9186             :             {
    9187           0 :                 ScRangeList aNew;
    9188           0 :                 aNew.Append(ScRange(aPos));
    9189           0 :                 aNew.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
    9190           0 :                                         rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
    9191           0 :                 if (aNew.size()==1)
    9192             :                 {
    9193           0 :                     aPos = aNew[ 0 ]->aStart;
    9194           0 :                     CheckPos_Impl();
    9195           0 :                 }
    9196             :             }
    9197             :         }
    9198             :     }
    9199          14 :     else if ( rHint.ISA( SfxSimpleHint ) &&
    9200           7 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
    9201             :     {
    9202           3 :         pDocShell = NULL;       // ungueltig geworden
    9203             :     }
    9204           7 : }
    9205             : 
    9206             : // XEnumeration
    9207             : 
    9208           4 : sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
    9209             : {
    9210           4 :     SolarMutexGuard aGuard;
    9211           4 :     return !bAtEnd;
    9212             : }
    9213             : 
    9214           2 : uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
    9215             :                                         lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9216             : {
    9217           2 :     SolarMutexGuard aGuard;
    9218           2 :     if (pDocShell && !bAtEnd)
    9219             :     {
    9220             :         // Interface-Typ muss zu ScCellsObj::getElementType passen
    9221             : 
    9222           1 :         ScAddress aTempPos(aPos);
    9223           1 :         Advance_Impl();
    9224           2 :         return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
    9225             :     }
    9226             : 
    9227           1 :     throw container::NoSuchElementException();      // no more elements
    9228             : }
    9229             : 
    9230           3 : ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
    9231             :     pDocShell( pDocSh ),
    9232           3 :     aTotalRange( rRange )
    9233             : {
    9234           3 :     ScDocument* pDoc = pDocShell->GetDocument();
    9235           3 :     pDoc->AddUnoObject(*this);
    9236             : 
    9237             :     OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
    9238           3 : }
    9239             : 
    9240           9 : ScCellFormatsObj::~ScCellFormatsObj()
    9241             : {
    9242           3 :     if (pDocShell)
    9243           0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    9244           6 : }
    9245             : 
    9246           8 : void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9247             : {
    9248           8 :     if ( rHint.ISA( ScUpdateRefHint ) )
    9249             :     {
    9250             :         //! aTotalRange...
    9251             :     }
    9252          14 :     else if ( rHint.ISA( SfxSimpleHint ) &&
    9253           6 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
    9254             :     {
    9255           3 :         pDocShell = NULL;       // ungueltig geworden
    9256             :     }
    9257           8 : }
    9258             : 
    9259           5 : ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
    9260             : {
    9261             :     //! direkt auf die AttrArrays zugreifen !!!!
    9262             : 
    9263           5 :     ScCellRangeObj* pRet = NULL;
    9264           5 :     if (pDocShell)
    9265             :     {
    9266           5 :         ScDocument* pDoc = pDocShell->GetDocument();
    9267           5 :         long nPos = 0;
    9268           5 :         ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
    9269           5 :                                     aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
    9270          15 :                                     aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
    9271             :         SCCOL nCol1, nCol2;
    9272             :         SCROW nRow1, nRow2;
    9273          15 :         while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9274             :         {
    9275           5 :             if ( nPos == nIndex )
    9276             :             {
    9277           4 :                 SCTAB nTab = aTotalRange.aStart.Tab();
    9278           4 :                 ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
    9279             : 
    9280           4 :                 if ( aNext.aStart == aNext.aEnd )
    9281           0 :                     pRet = new ScCellObj( pDocShell, aNext.aStart );
    9282             :                 else
    9283           4 :                     pRet = new ScCellRangeObj( pDocShell, aNext );
    9284             :             }
    9285           5 :             ++nPos;
    9286           5 :         }
    9287             :     }
    9288           5 :     return pRet;
    9289             : }
    9290             : 
    9291             : // XIndexAccess
    9292             : 
    9293           3 : sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
    9294             : {
    9295           3 :     SolarMutexGuard aGuard;
    9296             : 
    9297             :     //! direkt auf die AttrArrays zugreifen !!!!
    9298             : 
    9299           3 :     long nCount = 0;
    9300           3 :     if (pDocShell)
    9301             :     {
    9302           3 :         ScDocument* pDoc = pDocShell->GetDocument();
    9303           3 :         ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
    9304           3 :                                     aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
    9305           9 :                                     aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
    9306             :         SCCOL nCol1, nCol2;
    9307             :         SCROW nRow1, nRow2;
    9308           9 :         while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9309           6 :             ++nCount;
    9310             :     }
    9311           3 :     return nCount;
    9312             : }
    9313             : 
    9314           5 : uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
    9315             :                             throw(lang::IndexOutOfBoundsException,
    9316             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9317             : {
    9318           5 :     SolarMutexGuard aGuard;
    9319             : 
    9320          10 :     uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
    9321           5 :     if (xRange.is())
    9322           8 :         return uno::makeAny(xRange);
    9323             :     else
    9324           6 :         throw lang::IndexOutOfBoundsException();
    9325             : }
    9326             : 
    9327           1 : uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
    9328             : {
    9329           1 :     SolarMutexGuard aGuard;
    9330           1 :     return getCppuType((uno::Reference<table::XCellRange>*)0);
    9331             : }
    9332             : 
    9333           1 : sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
    9334             : {
    9335           1 :     SolarMutexGuard aGuard;
    9336           1 :     return ( getCount() != 0 );     //! immer groesser 0 ??
    9337             : }
    9338             : 
    9339             : // XEnumerationAccess
    9340             : 
    9341           2 : uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
    9342             :                                                     throw(uno::RuntimeException, std::exception)
    9343             : {
    9344           2 :     SolarMutexGuard aGuard;
    9345           2 :     if (pDocShell)
    9346           2 :         return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
    9347           0 :     return NULL;
    9348             : }
    9349             : 
    9350           2 : ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
    9351             :     pDocShell( pDocSh ),
    9352           2 :     nTab( rRange.aStart.Tab() ),
    9353             :     pIter( NULL ),
    9354             :     bAtEnd( false ),
    9355           4 :     bDirty( false )
    9356             : {
    9357           2 :     ScDocument* pDoc = pDocShell->GetDocument();
    9358           2 :     pDoc->AddUnoObject(*this);
    9359             : 
    9360             :     OSL_ENSURE( rRange.aStart.Tab() == rRange.aEnd.Tab(),
    9361             :                 "CellFormatsEnumeration: unterschiedliche Tabellen" );
    9362             : 
    9363             :     pIter = new ScAttrRectIterator( pDoc, nTab,
    9364           4 :                                     rRange.aStart.Col(), rRange.aStart.Row(),
    9365           4 :                                     rRange.aEnd.Col(), rRange.aEnd.Row() );
    9366           2 :     Advance_Impl();
    9367           2 : }
    9368             : 
    9369           6 : ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
    9370             : {
    9371           2 :     if (pDocShell)
    9372           0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    9373           2 :     delete pIter;
    9374           4 : }
    9375             : 
    9376           3 : void ScCellFormatsEnumeration::Advance_Impl()
    9377             : {
    9378             :     OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
    9379             : 
    9380           3 :     if ( pIter )
    9381             :     {
    9382           3 :         if ( bDirty )
    9383             :         {
    9384           0 :             pIter->DataChanged();   // AttrArray-Index neu suchen
    9385           0 :             bDirty = false;
    9386             :         }
    9387             : 
    9388             :         SCCOL nCol1, nCol2;
    9389             :         SCROW nRow1, nRow2;
    9390           3 :         if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9391           2 :             aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
    9392             :         else
    9393           1 :             bAtEnd = true;      // kommt nix mehr
    9394             :     }
    9395             :     else
    9396           0 :         bAtEnd = true;          // Dok weggekommen oder so
    9397           3 : }
    9398             : 
    9399           1 : ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
    9400             : {
    9401           1 :     ScCellRangeObj* pRet = NULL;
    9402           1 :     if (pDocShell && !bAtEnd)
    9403             :     {
    9404           1 :         if ( aNext.aStart == aNext.aEnd )
    9405           0 :             pRet = new ScCellObj( pDocShell, aNext.aStart );
    9406             :         else
    9407           1 :             pRet = new ScCellRangeObj( pDocShell, aNext );
    9408           1 :         Advance_Impl();
    9409             :     }
    9410           1 :     return pRet;
    9411             : }
    9412             : 
    9413           2 : void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9414             : {
    9415           2 :     if ( rHint.ISA( ScUpdateRefHint ) )
    9416             :     {
    9417             :         //! und nun ???
    9418             :     }
    9419           2 :     else if ( rHint.ISA( SfxSimpleHint ) )
    9420             :     {
    9421           2 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
    9422           2 :         if ( nId == SFX_HINT_DYING )
    9423             :         {
    9424           2 :             pDocShell = NULL;                       // ungueltig geworden
    9425           2 :             delete pIter;
    9426           2 :             pIter = NULL;
    9427             :         }
    9428           0 :         else if ( nId == SFX_HINT_DATACHANGED )
    9429             :         {
    9430           0 :             bDirty = true;          // AttrArray-Index evtl. ungueltig geworden
    9431             :         }
    9432             :     }
    9433           2 : }
    9434             : 
    9435             : // XEnumeration
    9436             : 
    9437           2 : sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
    9438             : {
    9439           2 :     SolarMutexGuard aGuard;
    9440           2 :     return !bAtEnd;
    9441             : }
    9442             : 
    9443           2 : uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
    9444             :                                         lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9445             : {
    9446           2 :     SolarMutexGuard aGuard;
    9447             : 
    9448           2 :     if ( bAtEnd || !pDocShell )
    9449           1 :         throw container::NoSuchElementException();      // no more elements
    9450             : 
    9451             :     // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
    9452             : 
    9453           1 :     return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
    9454             : }
    9455             : 
    9456          25 : ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
    9457             :     pDocShell( pDocSh ),
    9458             :     aTotalRange( rRange ),
    9459          25 :     aRangeLists()
    9460             : {
    9461          25 :     pDocShell->GetDocument()->AddUnoObject(*this);
    9462             : 
    9463             :     OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
    9464             : 
    9465          25 :     GetObjects_Impl();
    9466          25 : }
    9467             : 
    9468          75 : ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
    9469             : {
    9470          25 :     if (pDocShell)
    9471          22 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    9472          50 : }
    9473             : 
    9474           3 : void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9475             : {
    9476           3 :     if ( rHint.ISA( ScUpdateRefHint ) )
    9477             :     {
    9478             :         //! aTotalRange...
    9479             :     }
    9480           3 :     else if ( rHint.ISA( SfxSimpleHint ) )
    9481             :     {
    9482           3 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
    9483           3 :         if ( nId == SFX_HINT_DYING )
    9484           3 :             pDocShell = NULL;                       // ungueltig geworden
    9485             :     }
    9486           3 : }
    9487             : 
    9488             : 
    9489             : //  Fill the list of formats from the document
    9490             : 
    9491             : 
    9492             : // hash code to access the range lists by ScPatternAttr pointer
    9493             : struct ScPatternHashCode
    9494             : {
    9495         144 :     size_t operator()( const ScPatternAttr* pPattern ) const
    9496             :     {
    9497         144 :         return reinterpret_cast<size_t>(pPattern);
    9498             :     }
    9499             : };
    9500             : 
    9501             : // Hash map to find a range by its start row
    9502             : typedef ::boost::unordered_map< SCROW, ScRange > ScRowRangeHashMap;
    9503             : 
    9504             : typedef ::std::vector<ScRange> ScRangeVector;
    9505             : 
    9506             : // Hash map entry.
    9507             : // The Join method depends on the column-wise order of ScAttrRectIterator
    9508             : class ScUniqueFormatsEntry
    9509             : {
    9510             :     enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
    9511             : 
    9512             :     EntryState          eState;
    9513             :     ScRange             aSingleRange;
    9514             :     ScRowRangeHashMap   aJoinedRanges;      // "active" ranges to be merged
    9515             :     ScRangeVector       aCompletedRanges;   // ranges that will no longer be touched
    9516             :     ScRangeListRef      aReturnRanges;      // result as ScRangeList for further use
    9517             : 
    9518             : public:
    9519          71 :                         ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
    9520             :                         ScUniqueFormatsEntry( const ScUniqueFormatsEntry& r ) :
    9521             :                             eState( r.eState ),
    9522             :                             aSingleRange( r.aSingleRange ),
    9523             :                             aJoinedRanges( r.aJoinedRanges ),
    9524             :                             aCompletedRanges( r.aCompletedRanges ),
    9525             :                             aReturnRanges( r.aReturnRanges ) {}
    9526          71 :                         ~ScUniqueFormatsEntry() {}
    9527             : 
    9528             :     void                Join( const ScRange& rNewRange );
    9529             :     const ScRangeList&  GetRanges();
    9530          71 :     void                Clear() { aReturnRanges.Clear(); }  // aJoinedRanges and aCompletedRanges are cleared in GetRanges
    9531             : };
    9532             : 
    9533         144 : void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
    9534             : {
    9535             :     // Special-case handling for single range
    9536             : 
    9537         144 :     if ( eState == STATE_EMPTY )
    9538             :     {
    9539          71 :         aSingleRange = rNewRange;
    9540          71 :         eState = STATE_SINGLE;
    9541         153 :         return;
    9542             :     }
    9543          73 :     if ( eState == STATE_SINGLE )
    9544             :     {
    9545          63 :         if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
    9546          35 :              aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
    9547          11 :              aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
    9548             :         {
    9549          11 :             aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
    9550          11 :             return;     // still a single range
    9551             :         }
    9552             : 
    9553          13 :         SCROW nSingleRow = aSingleRange.aStart.Row();
    9554          13 :         aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
    9555          13 :         eState = STATE_COMPLEX;
    9556             :         // continue normally
    9557             :     }
    9558             : 
    9559             :     // This is called in the order of ScAttrRectIterator results.
    9560             :     // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
    9561             :     // If the old entry for the start row extends to a different end row, or ends in a different column, it
    9562             :     // can be moved to aCompletedRanges because it can't be joined with following iterator results.
    9563             :     // Everything happens within one sheet, so Tab can be ignored.
    9564             : 
    9565          62 :     SCROW nStartRow = rNewRange.aStart.Row();
    9566          62 :     ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) );       // find the active entry for the start row
    9567          62 :     if ( aIter != aJoinedRanges.end() )
    9568             :     {
    9569          47 :         ScRange& rOldRange = aIter->second;
    9570          59 :         if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
    9571          12 :              rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
    9572             :         {
    9573             :             // extend existing range
    9574           1 :             rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
    9575             :         }
    9576             :         else
    9577             :         {
    9578             :             // move old range to aCompletedRanges, keep rNewRange for joining
    9579          46 :             aCompletedRanges.push_back( rOldRange );
    9580          46 :             rOldRange = rNewRange;  // replace in hash map
    9581             :         }
    9582             :     }
    9583             :     else
    9584             :     {
    9585             :         // keep rNewRange for joining
    9586          15 :         aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
    9587             :     }
    9588             : }
    9589             : 
    9590          71 : const ScRangeList& ScUniqueFormatsEntry::GetRanges()
    9591             : {
    9592          71 :     if ( eState == STATE_SINGLE )
    9593             :     {
    9594          58 :         aReturnRanges = new ScRangeList;
    9595          58 :         aReturnRanges->Append( aSingleRange );
    9596          58 :         return *aReturnRanges;
    9597             :     }
    9598             : 
    9599             :     // move remaining entries from aJoinedRanges to aCompletedRanges
    9600             : 
    9601          13 :     ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
    9602          41 :     for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
    9603          28 :         aCompletedRanges.push_back( aJoinedIter->second );
    9604          13 :     aJoinedRanges.clear();
    9605             : 
    9606             :     // sort all ranges for a predictable API result
    9607             : 
    9608          13 :     std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
    9609             : 
    9610             :     // fill and return ScRangeList
    9611             : 
    9612          13 :     aReturnRanges = new ScRangeList;
    9613          13 :     ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
    9614          87 :     for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
    9615          74 :         aReturnRanges->Append( *aCompIter );
    9616          13 :     aCompletedRanges.clear();
    9617             : 
    9618          13 :     return *aReturnRanges;
    9619             : }
    9620             : 
    9621             : typedef ::boost::unordered_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
    9622             : 
    9623             : // function object to sort the range lists by start of first range
    9624             : struct ScUniqueFormatsOrder
    9625             : {
    9626          74 :     bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
    9627             :     {
    9628             :         // all range lists have at least one entry
    9629             :         OSL_ENSURE( rList1.size() > 0 && rList2.size() > 0, "ScUniqueFormatsOrder: empty list" );
    9630             : 
    9631             :         // compare start positions using ScAddress comparison operator
    9632          74 :         return ( rList1[ 0 ]->aStart < rList2[ 0 ]->aStart );
    9633             :     }
    9634             : };
    9635             : 
    9636          25 : void ScUniqueCellFormatsObj::GetObjects_Impl()
    9637             : {
    9638          25 :     if (pDocShell)
    9639             :     {
    9640          25 :         ScDocument* pDoc = pDocShell->GetDocument();
    9641          25 :         SCTAB nTab = aTotalRange.aStart.Tab();
    9642             :         ScAttrRectIterator aIter( pDoc, nTab,
    9643          25 :                                     aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
    9644          50 :                                     aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
    9645             :         SCCOL nCol1, nCol2;
    9646             :         SCROW nRow1, nRow2;
    9647             : 
    9648             :         // Collect the ranges for each format in a hash map, to avoid nested loops
    9649             : 
    9650          50 :         ScUniqueFormatsHashMap aHashMap;
    9651         194 :         while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9652             :         {
    9653         144 :             ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
    9654         144 :             const ScPatternAttr* pPattern = pDoc->GetPattern(nCol1, nRow1, nTab);
    9655         144 :             aHashMap[pPattern].Join( aRange );
    9656             :         }
    9657             : 
    9658             :         // Fill the vector aRangeLists with the range lists from the hash map
    9659             : 
    9660          25 :         aRangeLists.reserve( aHashMap.size() );
    9661          25 :         ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
    9662          25 :         ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
    9663         121 :         while ( aMapIter != aMapEnd )
    9664             :         {
    9665          71 :             ScUniqueFormatsEntry& rEntry = aMapIter->second;
    9666          71 :             const ScRangeList& rRanges = rEntry.GetRanges();
    9667          71 :             aRangeLists.push_back( rRanges );       // copy ScRangeList
    9668          71 :             rEntry.Clear();                         // free memory, don't hold both copies of all ranges
    9669          71 :             ++aMapIter;
    9670             :         }
    9671             : 
    9672             :         // Sort the vector by first range's start position, to avoid random shuffling
    9673             :         // due to using the ScPatterAttr pointers
    9674             : 
    9675             :         ScUniqueFormatsOrder aComp;
    9676          50 :         ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
    9677             :     }
    9678          25 : }
    9679             : 
    9680             : // XIndexAccess
    9681             : 
    9682          24 : sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
    9683             : {
    9684          24 :     SolarMutexGuard aGuard;
    9685             : 
    9686          24 :     return aRangeLists.size();
    9687             : }
    9688             : 
    9689          67 : uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
    9690             :                             throw(lang::IndexOutOfBoundsException,
    9691             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9692             : {
    9693          67 :     SolarMutexGuard aGuard;
    9694             : 
    9695          67 :     if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
    9696         132 :         return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
    9697             :     else
    9698          66 :         throw lang::IndexOutOfBoundsException();
    9699             : }
    9700             : 
    9701           1 : uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
    9702             : {
    9703           1 :     SolarMutexGuard aGuard;
    9704           1 :     return getCppuType((uno::Reference<sheet::XSheetCellRangeContainer>*)0);
    9705             : }
    9706             : 
    9707           1 : sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
    9708             : {
    9709           1 :     SolarMutexGuard aGuard;
    9710           1 :     return ( aRangeLists.size() != 0 );
    9711             : }
    9712             : 
    9713             : // XEnumerationAccess
    9714             : 
    9715           2 : uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
    9716             :                                                     throw(uno::RuntimeException, std::exception)
    9717             : {
    9718           2 :     SolarMutexGuard aGuard;
    9719           2 :     if (pDocShell)
    9720           2 :         return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
    9721           0 :     return NULL;
    9722             : }
    9723             : 
    9724           2 : ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
    9725             :     aRangeLists(rRangeLists),
    9726             :     pDocShell( pDocSh ),
    9727           2 :     nCurrentPosition(0)
    9728             : {
    9729           2 :     pDocShell->GetDocument()->AddUnoObject(*this);
    9730           2 : }
    9731             : 
    9732           6 : ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
    9733             : {
    9734           2 :     if (pDocShell)
    9735           0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    9736           4 : }
    9737             : 
    9738           2 : void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9739             : {
    9740           2 :     if ( rHint.ISA( ScUpdateRefHint ) )
    9741             :     {
    9742             :         //! und nun ???
    9743             :     }
    9744           2 :     else if ( rHint.ISA( SfxSimpleHint ) )
    9745             :     {
    9746           2 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
    9747           2 :         if ( nId == SFX_HINT_DYING )
    9748           2 :             pDocShell = NULL;                       // ungueltig geworden
    9749             :     }
    9750           2 : }
    9751             : 
    9752             : // XEnumeration
    9753             : 
    9754          10 : sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
    9755             : {
    9756          10 :     SolarMutexGuard aGuard;
    9757          10 :     return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
    9758             : }
    9759             : 
    9760           5 : uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
    9761             :                                         lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9762             : {
    9763           5 :     SolarMutexGuard aGuard;
    9764             : 
    9765           5 :     if ( !hasMoreElements() || !pDocShell )
    9766           1 :         throw container::NoSuchElementException();      // no more elements
    9767             : 
    9768             :     // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
    9769             : 
    9770           4 :     return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));
    9771         102 : }
    9772             : 
    9773             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10