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