LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - cellsuno.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 4230 5382 78.6 %
Date: 2014-11-03 Functions: 381 473 80.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "scitems.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : #include <svx/svdpool.hxx>
      23             : 
      24             : #include <svx/algitem.hxx>
      25             : #include <editeng/boxitem.hxx>
      26             : #include <editeng/brushitem.hxx>
      27             : #include <editeng/editeng.hxx>
      28             : #include <editeng/flditem.hxx>
      29             : #include <editeng/justifyitem.hxx>
      30             : #include <editeng/editobj.hxx>
      31             : #include <svx/fmdpage.hxx>
      32             : #include <editeng/langitem.hxx>
      33             : #include <sfx2/linkmgr.hxx>
      34             : #include <svl/srchitem.hxx>
      35             : #include <svl/sharedstringpool.hxx>
      36             : #include <svx/unomid.hxx>
      37             : #include <editeng/unoprnms.hxx>
      38             : #include <editeng/unotext.hxx>
      39             : #include <svx/svdpage.hxx>
      40             : #include <sfx2/bindings.hxx>
      41             : #include <svl/zforlist.hxx>
      42             : #include <svl/zformat.hxx>
      43             : #include <comphelper/servicehelper.hxx>
      44             : #include <cppuhelper/supportsservice.hxx>
      45             : #include <float.h>
      46             : 
      47             : #include <com/sun/star/awt/XBitmap.hpp>
      48             : #include <com/sun/star/util/CellProtection.hpp>
      49             : #include <com/sun/star/table/CellHoriJustify.hpp>
      50             : #include <com/sun/star/table/CellOrientation.hpp>
      51             : #include <com/sun/star/table/CellVertJustify2.hpp>
      52             : #include <com/sun/star/table/ShadowFormat.hpp>
      53             : #include <com/sun/star/table/TableBorder.hpp>
      54             : #include <com/sun/star/table/BorderLineStyle.hpp>
      55             : #include <com/sun/star/sheet/CellFlags.hpp>
      56             : #include <com/sun/star/sheet/FormulaResult.hpp>
      57             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      58             : #include <com/sun/star/lang/Locale.hpp>
      59             : #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
      60             : #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
      61             : #include <com/sun/star/text/WritingMode2.hpp>
      62             : #include <com/sun/star/text/textfield/Type.hpp>
      63             : 
      64             : #include "autoform.hxx"
      65             : #include "cellmergeoption.hxx"
      66             : #include "cellsuno.hxx"
      67             : #include "cursuno.hxx"
      68             : #include "textuno.hxx"
      69             : #include "editsrc.hxx"
      70             : #include "notesuno.hxx"
      71             : #include "fielduno.hxx"
      72             : #include "docuno.hxx"
      73             : #include "datauno.hxx"
      74             : #include "dapiuno.hxx"
      75             : #include "chartuno.hxx"
      76             : #include "fmtuno.hxx"
      77             : #include "miscuno.hxx"
      78             : #include "convuno.hxx"
      79             : #include "srchuno.hxx"
      80             : #include "nameuno.hxx"
      81             : #include "targuno.hxx"
      82             : #include "tokenuno.hxx"
      83             : #include "eventuno.hxx"
      84             : #include "docsh.hxx"
      85             : #include "markdata.hxx"
      86             : #include "patattr.hxx"
      87             : #include "docpool.hxx"
      88             : #include "docfunc.hxx"
      89             : #include "dbdocfun.hxx"
      90             : #include "olinefun.hxx"
      91             : #include "hints.hxx"
      92             : #include "formulacell.hxx"
      93             : #include "undocell.hxx"
      94             : #include "undotab.hxx"
      95             : #include "undoblk.hxx"
      96             : #include "stlsheet.hxx"
      97             : #include "dbdata.hxx"
      98             : #include "attrib.hxx"
      99             : #include "chartarr.hxx"
     100             : #include "chartlis.hxx"
     101             : #include "drwlayer.hxx"
     102             : #include "printfun.hxx"
     103             : #include "prnsave.hxx"
     104             : #include "tablink.hxx"
     105             : #include "dociter.hxx"
     106             : #include "rangeutl.hxx"
     107             : #include "conditio.hxx"
     108             : #include "validat.hxx"
     109             : #include "sc.hrc"
     110             : #include "brdcst.hxx"
     111             : #include "cellform.hxx"
     112             : #include "globstr.hrc"
     113             : #include "unonames.hxx"
     114             : #include "styleuno.hxx"
     115             : #include "rangeseq.hxx"
     116             : #include "unowids.hxx"
     117             : #include "paramisc.hxx"
     118             : #include "queryentry.hxx"
     119             : #include <formula/errorcodes.hxx>
     120             : #include "unoreflist.hxx"
     121             : #include <formula/grammar.hxx>
     122             : #include <editeng/escapementitem.hxx>
     123             : #include "stringutil.hxx"
     124             : #include "formulaiter.hxx"
     125             : #include "tokenarray.hxx"
     126             : #include "stylehelper.hxx"
     127             : #include "dputil.hxx"
     128             : #include <sortparam.hxx>
     129             : 
     130             : #include <list>
     131             : #include <boost/scoped_array.hpp>
     132             : #include <boost/scoped_ptr.hpp>
     133             : 
     134             : using namespace com::sun::star;
     135             : 
     136          70 : class ScNamedEntry
     137             : {
     138             :     OUString  aName;
     139             :     ScRange   aRange;
     140             : 
     141             : public:
     142          70 :             ScNamedEntry(const OUString& rN, const ScRange& rR) :
     143          70 :                 aName(rN), aRange(rR) {}
     144             : 
     145         288 :     const OUString& GetName() const     { return aName; }
     146         158 :     const ScRange&  GetRange() const    { return aRange; }
     147             : };
     148             : 
     149             : //  The names in the maps must be sorted according to strcmp!
     150             : //! Instead of Which-ID 0 use special IDs and do not compare via names!
     151             : 
     152             : //  Left/Right/Top/BottomBorder are mapped directly to the core items,
     153             : //  not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
     154             : 
     155       79846 : static const SfxItemPropertySet* lcl_GetCellsPropertySet()
     156             : {
     157             :     static const SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
     158             :     {
     159          62 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(),        0 | beans::PropertyAttribute::READONLY, 0 },
     160          62 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     161          62 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     162          62 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     163          62 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    cppu::UnoType<sal_Int32>::get(),            0, MID_BACK_COLOR },
     164          62 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    cppu::UnoType<util::CellProtection>::get(), 0, 0 },
     165          62 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(),        0, 0 },
     166          62 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    cppu::UnoType<sal_Int32>::get(),            0, 0 },
     167          62 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     168          62 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     169          62 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(),         0, MID_EMPHASIS },
     170          62 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     171          62 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     172          62 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     173          62 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     174          62 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     175          62 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     176          62 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     177          62 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     178          62 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     179          62 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     180          62 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     181          62 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     182          62 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     183          62 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     184          62 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     185          62 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     186          62 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   cppu::UnoType<float>::get(),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     187          62 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     188          62 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     189          62 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(),         0, MID_LANG_LOCALE },
     190          62 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     191          62 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     192          62 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     193          62 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     194          62 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     195          62 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  cppu::UnoType<awt::FontSlant>::get(),       0, MID_POSTURE },
     196          62 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     197          62 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     198          62 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   cppu::UnoType<sal_Int16>::get(),            0, MID_RELIEF },
     199          62 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     200          62 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(),           0, MID_CROSS_OUT },
     201          62 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     202          62 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     203          62 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     204          62 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   cppu::UnoType<float>::get(),                0, MID_WEIGHT },
     205          62 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     206          62 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     207          62 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     208          62 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     209          62 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     210          62 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     211          62 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     212          62 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     213          62 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     214          62 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     215          62 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     216          62 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     217          62 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
     218          62 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     219          62 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     220          62 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     221          62 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     222          62 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     223          62 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     224          62 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
     225          62 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
     226          62 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     227          62 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     228          62 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        cppu::UnoType<sal_Int16>::get(),            0, 0 }, //! CONVERT_TWIPS
     229          62 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     230          62 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     231          62 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     232          62 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     233          62 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     234          62 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     235          62 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     236          62 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     237          62 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     238          62 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     239          62 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     240          62 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     241          62 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        cppu::UnoType<table::ShadowFormat>::get(),  0, 0 | CONVERT_TWIPS },
     242          62 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     243          62 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(),   0, 0 | CONVERT_TWIPS },
     244          62 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(),   0, 0 | CONVERT_TWIPS },
     245          62 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     246          62 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     247          62 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
     248          62 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     249          62 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     250          62 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     251          62 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     252          62 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     253          62 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    cppu::UnoType<sal_Int16>::get(),            0, 0 },
     254          62 :         {OUString(SC_UNONAME_HYPERLINK),  ATTR_HYPERLINK, cppu::UnoType<OUString>::get(),        0, 0 },
     255             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     256       85860 :     };
     257       79846 :     static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
     258       79846 :     return &aCellsPropertySet;
     259             : }
     260             : 
     261             : //  CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
     262             : //  mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
     263             : 
     264       49422 : static const SfxItemPropertySet* lcl_GetRangePropertySet()
     265             : {
     266             :     static const SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
     267             :     {
     268          62 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(),        0 | beans::PropertyAttribute::READONLY, 0 },
     269          62 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     270          62 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     271          62 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     272          62 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    cppu::UnoType<sal_Int32>::get(),            0, MID_BACK_COLOR },
     273          62 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    cppu::UnoType<util::CellProtection>::get(), 0, 0 },
     274          62 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(),        0, 0 },
     275          62 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    cppu::UnoType<sal_Int32>::get(),            0, 0 },
     276          62 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     277          62 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     278          62 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(),         0, MID_EMPHASIS },
     279          62 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     280          62 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     281          62 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     282          62 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     283          62 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     284          62 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     285          62 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     286          62 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     287          62 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     288          62 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     289          62 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     290          62 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     291          62 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     292          62 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     293          62 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     294          62 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     295          62 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   cppu::UnoType<float>::get(),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     296          62 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     297          62 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     298          62 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(),         0, MID_LANG_LOCALE },
     299          62 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     300          62 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     301          62 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     302          62 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     303          62 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     304          62 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  cppu::UnoType<awt::FontSlant>::get(),       0, MID_POSTURE },
     305          62 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     306          62 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     307          62 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   cppu::UnoType<sal_Int16>::get(),            0, MID_RELIEF },
     308          62 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     309          62 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(),           0, MID_CROSS_OUT },
     310          62 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     311          62 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     312          62 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     313          62 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   cppu::UnoType<float>::get(),                0, MID_WEIGHT },
     314          62 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     315          62 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     316          62 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     317          62 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     318          62 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     319          62 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     320          62 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     321          62 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     322          62 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     323          62 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     324          62 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     325          62 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     326          62 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   cppu::UnoType<table::CellHoriJustify>::get(),   0, MID_HORJUST_HORJUST },
     327          62 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     328          62 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     329          62 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     330          62 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     331          62 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     332          62 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     333          62 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
     334          62 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
     335          62 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     336          62 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     337          62 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        cppu::UnoType<sal_Int16>::get(),            0, 0 }, //! CONVERT_TWIPS
     338          62 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     339          62 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     340          62 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     341          62 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     342          62 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     343          62 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     344          62 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     345          62 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     346          62 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     cppu::UnoType<awt::Point>::get(),           0 | beans::PropertyAttribute::READONLY, 0 },
     347          62 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     348          62 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     349          62 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     350          62 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     351          62 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        cppu::UnoType<table::ShadowFormat>::get(),  0, 0 | CONVERT_TWIPS },
     352          62 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     353          62 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    cppu::UnoType<awt::Size>::get(),            0 | beans::PropertyAttribute::READONLY, 0 },
     354          62 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(),   0, 0 | CONVERT_TWIPS },
     355          62 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(),   0, 0 | CONVERT_TWIPS },
     356          62 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     357          62 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     358          62 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
     359          62 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     360          62 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     361          62 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     362          62 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     363          62 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     364          62 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    cppu::UnoType<sal_Int16>::get(),            0, 0 },
     365             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     366       55498 :     };
     367       49422 :     static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
     368       49422 :     return &aRangePropertySet;
     369             : }
     370             : 
     371             : //  Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
     372             : //  mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
     373             : 
     374       25732 : static const SfxItemPropertySet* lcl_GetCellPropertySet()
     375             : {
     376             :     static const SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
     377             :     {
     378          42 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(),        0 | beans::PropertyAttribute::READONLY, 0 },
     379          42 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     380          42 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     381          42 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     382          42 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    cppu::UnoType<sal_Int32>::get(),            0, MID_BACK_COLOR },
     383          42 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    cppu::UnoType<util::CellProtection>::get(), 0, 0 },
     384          42 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(),        0, 0 },
     385          42 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    cppu::UnoType<sal_Int32>::get(),            0, 0 },
     386          42 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     387          42 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     388          42 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(),         0, MID_EMPHASIS },
     389          42 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     390          42 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     391          42 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     392          42 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     393          42 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     394          42 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     395          42 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     396          42 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     397          42 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     398          42 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     399          42 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     400          42 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     401          42 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     402          42 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     403          42 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     404          42 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     405          42 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   cppu::UnoType<float>::get(),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     406          42 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     407          42 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     408          42 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(),         0, MID_LANG_LOCALE },
     409          42 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     410          42 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     411          42 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     412          42 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     413          42 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     414          42 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  cppu::UnoType<awt::FontSlant>::get(),       0, MID_POSTURE },
     415          42 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     416          42 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     417          42 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   cppu::UnoType<sal_Int16>::get(),            0, MID_RELIEF },
     418          42 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     419          42 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(),           0, MID_CROSS_OUT },
     420          42 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     421          42 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     422          42 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     423          42 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   cppu::UnoType<float>::get(),                0, MID_WEIGHT },
     424          42 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     425          42 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     426          42 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     427          42 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     428          42 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     429          42 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     430          42 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     431          42 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     432          42 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     433          42 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     434          42 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     435          42 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     436          42 :         {OUString(SC_UNONAME_FORMLOC),  SC_WID_UNO_FORMLOC, cppu::UnoType<OUString>::get(),        0, 0 },
     437          42 :         {OUString(SC_UNONAME_FORMRT),   SC_WID_UNO_FORMRT,  cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
     438          42 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
     439          42 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     440          42 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     441          42 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     442          42 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     443          42 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     444          42 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     445          42 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
     446          42 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
     447          42 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     448          42 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     449          42 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        cppu::UnoType<sal_Int16>::get(),            0, 0 }, //! CONVERT_TWIPS
     450          42 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     451          42 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     452          42 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     453          42 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     454          42 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     455          42 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     456          42 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     457          42 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     458          42 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     cppu::UnoType<awt::Point>::get(),           0 | beans::PropertyAttribute::READONLY, 0 },
     459          42 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     460          42 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     461          42 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     462          42 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     463          42 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        cppu::UnoType<table::ShadowFormat>::get(),  0, 0 | CONVERT_TWIPS },
     464          42 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     465          42 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    cppu::UnoType<awt::Size>::get(),            0 | beans::PropertyAttribute::READONLY, 0 },
     466          42 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(),   0, 0 | CONVERT_TWIPS },
     467          42 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(),   0, 0 | CONVERT_TWIPS },
     468          42 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     469          42 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     470          42 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
     471          42 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     472          42 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     473          42 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     474          42 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     475          42 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     476          42 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    cppu::UnoType<sal_Int16>::get(),            0, 0 },
     477          42 :         {OUString(UNO_NAME_EDIT_CHAR_ESCAPEMENT),   EE_CHAR_ESCAPEMENT, cppu::UnoType<sal_Int32>::get(),            0, 0 },
     478          42 :         {OUString(SC_UNONAME_HYPERLINK),  ATTR_HYPERLINK, cppu::UnoType<OUString>::get(),        0, 0 },
     479             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     480       30016 :     };
     481       25732 :     static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
     482       25732 :     return &aCellPropertySet;
     483             : }
     484             : 
     485             : //  Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
     486             : //  mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
     487             : 
     488        2188 : static const SfxItemPropertySet* lcl_GetColumnPropertySet()
     489             : {
     490             :     static const SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
     491             :     {
     492          14 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(),        0 | beans::PropertyAttribute::READONLY, 0 },
     493          14 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     494          14 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     495          14 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     496          14 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    cppu::UnoType<sal_Int32>::get(),            0, MID_BACK_COLOR },
     497          14 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    cppu::UnoType<util::CellProtection>::get(), 0, 0 },
     498          14 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(),        0, 0 },
     499          14 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    cppu::UnoType<sal_Int32>::get(),            0, 0 },
     500          14 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     501          14 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     502          14 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(),         0, MID_EMPHASIS },
     503          14 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     504          14 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     505          14 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     506          14 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     507          14 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     508          14 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     509          14 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     510          14 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     511          14 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     512          14 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     513          14 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     514          14 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     515          14 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     516          14 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     517          14 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     518          14 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     519          14 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   cppu::UnoType<float>::get(),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     520          14 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     521          14 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     522          14 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(),         0, MID_LANG_LOCALE },
     523          14 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     524          14 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     525          14 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     526          14 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     527          14 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     528          14 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  cppu::UnoType<awt::FontSlant>::get(),       0, MID_POSTURE },
     529          14 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     530          14 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     531          14 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   cppu::UnoType<sal_Int16>::get(),            0, MID_RELIEF },
     532          14 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     533          14 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(),           0, MID_CROSS_OUT },
     534          14 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     535          14 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     536          14 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     537          14 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   cppu::UnoType<float>::get(),                0, MID_WEIGHT },
     538          14 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     539          14 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     540          14 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     541          14 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     542          14 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     543          14 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     544          14 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     545          14 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     546          14 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     547          14 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     548          14 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     549          14 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     550          14 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
     551          14 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     552          14 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     553          14 :         {OUString(SC_UNONAME_MANPAGE),  SC_WID_UNO_MANPAGE, getBooleanCppuType(),                  0, 0 },
     554          14 :         {OUString(SC_UNONAME_NEWPAGE),  SC_WID_UNO_NEWPAGE, getBooleanCppuType(),                  0, 0 },
     555          14 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     556          14 :         {OUString(SC_UNONAME_CELLVIS),  SC_WID_UNO_CELLVIS, getBooleanCppuType(),                  0, 0 },
     557          14 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     558          14 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     559          14 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     560          14 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
     561          14 :         {OUString(SC_UNONAME_OWIDTH),   SC_WID_UNO_OWIDTH,  getBooleanCppuType(),                  0, 0 },
     562          14 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
     563          14 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     564          14 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     565          14 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        cppu::UnoType<sal_Int16>::get(),            0, 0 }, //! CONVERT_TWIPS
     566          14 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     567          14 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     568          14 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     569          14 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     570          14 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     571          14 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     572          14 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     573          14 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     574          14 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     cppu::UnoType<awt::Point>::get(),           0 | beans::PropertyAttribute::READONLY, 0 },
     575          14 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     576          14 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     577          14 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     578          14 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     579          14 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        cppu::UnoType<table::ShadowFormat>::get(),  0, 0 | CONVERT_TWIPS },
     580          14 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     581          14 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    cppu::UnoType<awt::Size>::get(),            0 | beans::PropertyAttribute::READONLY, 0 },
     582          14 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(),   0, 0 | CONVERT_TWIPS },
     583          14 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(),   0, 0 | CONVERT_TWIPS },
     584          14 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     585          14 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     586          14 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
     587          14 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     588          14 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     589          14 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     590          14 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     591          14 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     592          14 :         {OUString(SC_UNONAME_CELLWID),  SC_WID_UNO_CELLWID, cppu::UnoType<sal_Int32>::get(),            0, 0 },
     593          14 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    cppu::UnoType<sal_Int16>::get(),            0, 0 },
     594             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     595        3630 :     };
     596        2188 :     static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
     597        2188 :     return &aColumnPropertySet;
     598             : }
     599             : 
     600         230 : static const SfxItemPropertySet* lcl_GetRowPropertySet()
     601             : {
     602             :     static const SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
     603             :     {
     604          16 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(),        0 | beans::PropertyAttribute::READONLY, 0 },
     605          16 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     606          16 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     607          16 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     608          16 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    cppu::UnoType<sal_Int32>::get(),            0, MID_BACK_COLOR },
     609          16 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    cppu::UnoType<util::CellProtection>::get(), 0, 0 },
     610          16 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(),        0, 0 },
     611          16 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    cppu::UnoType<sal_Int32>::get(),            0, 0 },
     612          16 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     613          16 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     614          16 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(),         0, MID_EMPHASIS },
     615          16 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     616          16 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     617          16 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     618          16 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     619          16 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     620          16 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     621          16 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     622          16 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     623          16 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     624          16 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     625          16 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     626          16 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     627          16 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     628          16 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     629          16 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     630          16 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     631          16 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   cppu::UnoType<float>::get(),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     632          16 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     633          16 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     634          16 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(),         0, MID_LANG_LOCALE },
     635          16 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     636          16 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     637          16 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     638          16 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     639          16 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     640          16 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  cppu::UnoType<awt::FontSlant>::get(),       0, MID_POSTURE },
     641          16 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     642          16 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     643          16 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   cppu::UnoType<sal_Int16>::get(),            0, MID_RELIEF },
     644          16 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     645          16 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(),           0, MID_CROSS_OUT },
     646          16 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     647          16 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     648          16 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     649          16 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   cppu::UnoType<float>::get(),                0, MID_WEIGHT },
     650          16 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     651          16 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     652          16 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     653          16 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     654          16 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     655          16 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     656          16 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     657          16 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     658          16 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     659          16 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     660          16 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     661          16 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     662          16 :         {OUString(SC_UNONAME_CELLHGT),  SC_WID_UNO_CELLHGT, cppu::UnoType<sal_Int32>::get(),            0, 0 },
     663          16 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
     664          16 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     665          16 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     666          16 :         {OUString(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,getBooleanCppuType(),                  0, 0 },
     667          16 :         {OUString(SC_UNONAME_MANPAGE),  SC_WID_UNO_MANPAGE, getBooleanCppuType(),                  0, 0 },
     668          16 :         {OUString(SC_UNONAME_NEWPAGE),  SC_WID_UNO_NEWPAGE, getBooleanCppuType(),                  0, 0 },
     669          16 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     670          16 :         {OUString(SC_UNONAME_CELLVIS),  SC_WID_UNO_CELLVIS, getBooleanCppuType(),                  0, 0 },
     671          16 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     672          16 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     673          16 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     674          16 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
     675          16 :         {OUString(SC_UNONAME_OHEIGHT),  SC_WID_UNO_OHEIGHT, getBooleanCppuType(),                  0, 0 },
     676          16 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
     677          16 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     678          16 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     679          16 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        cppu::UnoType<sal_Int16>::get(),            0, 0 }, //! CONVERT_TWIPS
     680          16 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     681          16 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     682          16 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     683          16 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     684          16 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     685          16 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     686          16 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     687          16 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     688          16 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     cppu::UnoType<awt::Point>::get(),           0 | beans::PropertyAttribute::READONLY, 0 },
     689          16 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     690          16 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     691          16 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     692          16 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     693          16 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        cppu::UnoType<table::ShadowFormat>::get(),  0, 0 | CONVERT_TWIPS },
     694          16 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     695          16 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    cppu::UnoType<awt::Size>::get(),            0 | beans::PropertyAttribute::READONLY, 0 },
     696          16 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(),   0, 0 | CONVERT_TWIPS },
     697          16 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(),   0, 0 | CONVERT_TWIPS },
     698          16 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     699          16 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     700          16 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
     701          16 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     702          16 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     703          16 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     704          16 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     705          16 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     706          16 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    cppu::UnoType<sal_Int16>::get(),            0, 0 },
     707             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     708        1894 :     };
     709         230 :     static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
     710         230 :     return &aRowPropertySet;
     711             : }
     712             : 
     713        6236 : static const SfxItemPropertySet* lcl_GetSheetPropertySet()
     714             : {
     715             :     static const SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
     716             :     {
     717          62 :         {OUString(SC_UNONAME_ABSNAME),  SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(),        0 | beans::PropertyAttribute::READONLY, 0 },
     718          62 :         {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(),                  0, 0 },
     719          62 :         {OUString(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,getBooleanCppuType(),                 0, 0 },
     720          62 :         {OUString(SC_UNONAME_BORDCOL),  SC_WID_UNO_BORDCOL, cppu::UnoType<sal_Int32>::get(),            0, 0 },
     721          62 :         {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     722          62 :         {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
     723          62 :         {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    cppu::UnoType<sal_Int32>::get(),            0, MID_BACK_COLOR },
     724          62 :         {OUString(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    cppu::UnoType<util::CellProtection>::get(), 0, 0 },
     725          62 :         {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(),        0, 0 },
     726          62 :         {OUString(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    cppu::UnoType<sal_Int32>::get(),            0, 0 },
     727          62 :         {OUString(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  getBooleanCppuType(),                  0, 0 },
     728          62 :         {OUString(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,getBooleanCppuType(),                 0, MID_CROSSED_OUT },
     729          62 :         {OUString(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(),         0, MID_EMPHASIS },
     730          62 :         {OUString(SC_UNONAME_CFONT),    ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     731          62 :         {OUString(SC_UNONAME_CFCHARS),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     732          62 :         {OUString(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     733          62 :         {OUString(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_CHAR_SET },
     734          62 :         {OUString(SC_UNONAME_CFFAMIL),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     735          62 :         {OUString(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     736          62 :         {OUString(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_FAMILY },
     737          62 :         {OUString(SC_UNONAME_CFNAME),   ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     738          62 :         {OUString(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     739          62 :         {OUString(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_FAMILY_NAME },
     740          62 :         {OUString(SC_UNONAME_CFPITCH),  ATTR_FONT,          cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     741          62 :         {OUString(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     742          62 :         {OUString(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      cppu::UnoType<sal_Int16>::get(),            0, MID_FONT_PITCH },
     743          62 :         {OUString(SC_UNONAME_CFSTYLE),  ATTR_FONT,          cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     744          62 :         {OUString(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     745          62 :         {OUString(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      cppu::UnoType<OUString>::get(),        0, MID_FONT_STYLE_NAME },
     746          62 :         {OUString(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   cppu::UnoType<float>::get(),                0, MID_FONTHEIGHT | CONVERT_TWIPS },
     747          62 :         {OUString(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     748          62 :         {OUString(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(),               0, MID_FONTHEIGHT | CONVERT_TWIPS },
     749          62 :         {OUString(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(),         0, MID_LANG_LOCALE },
     750          62 :         {OUString(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     751          62 :         {OUString(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(),          0, MID_LANG_LOCALE },
     752          62 :         {OUString(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     753          62 :         {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     754          62 :         {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     755          62 :         {OUString(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  cppu::UnoType<awt::FontSlant>::get(),       0, MID_POSTURE },
     756          62 :         {OUString(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     757          62 :         {OUString(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(),     0, MID_POSTURE },
     758          62 :         {OUString(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   cppu::UnoType<sal_Int16>::get(),            0, MID_RELIEF },
     759          62 :         {OUString(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, getBooleanCppuType(),                  0, 0 },
     760          62 :         {OUString(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(),           0, MID_CROSS_OUT },
     761          62 :         {OUString(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(),            0, MID_TL_STYLE },
     762          62 :         {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(),            0, MID_TL_COLOR },
     763          62 :         {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
     764          62 :         {OUString(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   cppu::UnoType<float>::get(),                0, MID_WEIGHT },
     765          62 :         {OUString(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     766          62 :         {OUString(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(),               0, MID_WEIGHT },
     767          62 :         {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(),                  0, 0 },
     768          62 :         {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(),                  0, 0 },
     769          62 :         {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(),                  0, 0 },
     770          62 :         {OUString(SC_UNONAME_CONDFMT),  SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     771          62 :         {OUString(SC_UNONAME_CONDLOC),  SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     772          62 :         {OUString(SC_UNONAME_CONDXML),  SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
     773          62 :         {OUString(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,getBooleanCppuType(),                  0, 0 },
     774          62 :         {OUString(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,getBooleanCppuType(),                  0, 0 },
     775          62 :         {OUString(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,getBooleanCppuType(),                  0, 0 },
     776          62 :         {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     777          62 :         {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     778          62 :         {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
     779          62 :         {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
     780          62 :         {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
     781          62 :         {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     782          62 :         {OUString(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,getBooleanCppuType(),                  0, 0 },
     783          62 :         {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    getBooleanCppuType(),                  0, MID_GRAPHIC_TRANSPARENT },
     784          62 :         {OUString(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     getBooleanCppuType(),                  0, 0 },
     785          62 :         {OUString(SC_UNONAME_CELLVIS),  SC_WID_UNO_CELLVIS, getBooleanCppuType(),                  0, 0 },
     786          62 :         {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     787          62 :         {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
     788          62 :         {OUString(SC_UNO_LINKDISPBIT),  SC_WID_UNO_LINKDISPBIT,cppu::UnoType<awt::XBitmap>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
     789          62 :         {OUString(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,cppu::UnoType<OUString>::get(),    0 | beans::PropertyAttribute::READONLY, 0 },
     790          62 :         {OUString(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     791          62 :         {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
     792          62 :         {OUString(SC_UNONAME_CELLORI),  ATTR_STACKED,       cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
     793          62 :         {OUString(SC_UNONAME_PAGESTL),  SC_WID_UNO_PAGESTL, cppu::UnoType<OUString>::get(),        0, 0 },
     794          62 :         {OUString(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     795          62 :         {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
     796          62 :         {OUString(SC_UNONAME_PINDENT),  ATTR_INDENT,        cppu::UnoType<sal_Int16>::get(),            0, 0 }, //! CONVERT_TWIPS
     797          62 :         {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   getBooleanCppuType(),                  0, 0 },
     798          62 :         {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(),                 0, 0 },
     799          62 :         {OUString(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,getBooleanCppuType(),                 0, 0 },
     800          62 :         {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     getBooleanCppuType(),                  0, 0 },
     801          62 :         {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   ::cppu::UnoType<sal_Int16>::get(),    0, MID_HORJUST_ADJUST },
     802          62 :         {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
     803          62 :         {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
     804          62 :         {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        cppu::UnoType<sal_Int32>::get(),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
     805          62 :         {OUString(SC_UNONAME_POS),      SC_WID_UNO_POS,     cppu::UnoType<awt::Point>::get(),           0 | beans::PropertyAttribute::READONLY, 0 },
     806          62 :         {OUString(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,getBooleanCppuType(),                 0, 0 },
     807          62 :         {OUString(SC_UNONAME_PROTECT),  SC_WID_UNO_PROTECT, getBooleanCppuType(),                  0, 0 },
     808          62 :         {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     809          62 :         {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER,     ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
     810          62 :         {OUString(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  cppu::UnoType<sal_Int32>::get(),            0, 0 },
     811          62 :         {OUString(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     812          62 :         {OUString(SC_UNONAME_SHADOW),   ATTR_SHADOW,        cppu::UnoType<table::ShadowFormat>::get(),  0, 0 | CONVERT_TWIPS },
     813          62 :         {OUString(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,getBooleanCppuType(),                  0, 0 },
     814          62 :         {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(),               0, 0 },
     815          62 :         {OUString(SC_UNONAME_SIZE),     SC_WID_UNO_SIZE,    cppu::UnoType<awt::Size>::get(),            0 | beans::PropertyAttribute::READONLY, 0 },
     816          62 :         {OUString(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(),   0, 0 | CONVERT_TWIPS },
     817          62 :         {OUString(SC_UNONAME_TBLBORD2),  SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(),   0, 0 | CONVERT_TWIPS },
     818          62 :         {OUString(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,cppu::UnoType<sal_Int16>::get(),           0, 0 },
     819          62 :         {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER,        ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     820          62 :         {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER,       ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
     821          62 :         {OUString(SC_UNONAME_USERDEF),  ATTR_USERDEF,       cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
     822          62 :         {OUString(SC_UNONAME_VALIDAT),  SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     823          62 :         {OUString(SC_UNONAME_VALILOC),  SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     824          62 :         {OUString(SC_UNONAME_VALIXML),  SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
     825          62 :         {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   cppu::UnoType<sal_Int32>::get(), 0, 0 },
     826          62 :         {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(),   0, 0 },
     827          62 :         {OUString(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    cppu::UnoType<sal_Int16>::get(),            0, 0 },
     828          62 :         {OUString(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
     829          62 :         {OUString(SC_UNO_CODENAME),        SC_WID_UNO_CODENAME, cppu::UnoType<OUString>::get(),    0, 0},
     830          62 :         {OUString(SC_UNO_NAMEDRANGES), SC_WID_UNO_NAMES, cppu::UnoType<sheet::XNamedRanges>::get(), 0, 0 },
     831             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     832       13366 :     };
     833        6236 :     static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
     834        6236 :     return &aSheetPropertySet;
     835             : }
     836             : 
     837           4 : static const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
     838             : {
     839             :     static const SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
     840             :     {
     841         196 :         SVX_UNOEDIT_CHAR_PROPERTIES,
     842           4 :         SVX_UNOEDIT_FONT_PROPERTIES,
     843          56 :         SVX_UNOEDIT_PARA_PROPERTIES,
     844           8 :         SVX_UNOEDIT_NUMBERING_PROPERTIE,    // for completeness of service ParagraphProperties
     845           4 :         {OUString(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
     846           4 :         {OUString(SC_UNONAME_USERDEF),  EE_PARA_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
     847             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     848         280 :     };
     849           4 :     return aEditPropertyMap_Impl;
     850             : }
     851          20 : static const SvxItemPropertySet* lcl_GetEditPropertySet()
     852             : {
     853          20 :     static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() );
     854          20 :     return &aEditPropertySet;
     855             : }
     856             : 
     857             : using sc::HMMToTwips;
     858             : using sc::TwipsToHMM;
     859             : 
     860             : #define SCCHARPROPERTIES_SERVICE    "com.sun.star.style.CharacterProperties"
     861             : #define SCPARAPROPERTIES_SERVICE    "com.sun.star.style.ParagraphProperties"
     862             : #define SCCELLPROPERTIES_SERVICE    "com.sun.star.table.CellProperties"
     863             : #define SCCELLRANGE_SERVICE         "com.sun.star.table.CellRange"
     864             : #define SCCELL_SERVICE              "com.sun.star.table.Cell"
     865             : #define SCSHEETCELLRANGES_SERVICE   "com.sun.star.sheet.SheetCellRanges"
     866             : #define SCSHEETCELLRANGE_SERVICE    "com.sun.star.sheet.SheetCellRange"
     867             : #define SCSPREADSHEET_SERVICE       "com.sun.star.sheet.Spreadsheet"
     868             : #define SCSHEETCELL_SERVICE         "com.sun.star.sheet.SheetCell"
     869             : 
     870           0 : SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
     871           0 : SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
     872           2 : SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
     873           2 : SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
     874           0 : SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
     875           0 : SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
     876           0 : SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
     877           0 : SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
     878           0 : SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
     879             : 
     880             : //! ScLinkListener in anderes File verschieben !!!
     881             : 
     882       14500 : ScLinkListener::~ScLinkListener()
     883             : {
     884       14500 : }
     885             : 
     886         738 : void ScLinkListener::Notify( const SfxHint& rHint )
     887             : {
     888         738 :     aLink.Call( (SfxHint*)&rHint );
     889         738 : }
     890             : 
     891           2 : static void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
     892             : {
     893           2 :     uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
     894           2 :     if (xInfo.is())
     895             :     {
     896           2 :         uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
     897           2 :         const beans::Property* pAry = aSeq.getConstArray();
     898           2 :         sal_uLong nCount = aSeq.getLength();
     899          20 :         for (sal_uLong i=0; i<nCount; i++)
     900             :         {
     901          18 :             OUString aName(pAry[i].Name);
     902          18 :             rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
     903          20 :         }
     904           2 :     }
     905           2 : }
     906             : 
     907         114 : static SCTAB lcl_FirstTab( const ScRangeList& rRanges )
     908             : {
     909             :     OSL_ENSURE(rRanges.size() >= 1, "was fuer Ranges ?!?!");
     910         114 :     const ScRange* pFirst = rRanges[ 0 ];
     911         114 :     if (pFirst)
     912         114 :         return pFirst->aStart.Tab();
     913             : 
     914           0 :     return 0;   // soll nicht sein
     915             : }
     916             : 
     917         142 : static bool lcl_WholeSheet( const ScRangeList& rRanges )
     918             : {
     919         142 :     if ( rRanges.size() == 1 )
     920             :     {
     921         128 :         const ScRange* pRange = rRanges[0];
     922         280 :         if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
     923         176 :                        pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
     924          24 :             return true;
     925             :     }
     926         118 :     return false;
     927             : }
     928             : 
     929             : namespace {
     930             : template<typename BorderLineType>
     931          72 : const ::editeng::SvxBorderLine* lcl_getBorderLine(
     932             :         ::editeng::SvxBorderLine& rLine, const BorderLineType& rStruct )
     933             : {
     934             :     // Convert from 1/100mm to Twips.
     935          72 :     if (!SvxBoxItem::LineToSvxLine( rStruct, rLine, true))
     936          72 :         return NULL;
     937             : 
     938           0 :     if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
     939           0 :         return &rLine;
     940             :     else
     941           0 :         return NULL;
     942             : }
     943             : }
     944             : 
     945          72 : const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
     946             :         ::editeng::SvxBorderLine& rLine, const table::BorderLine& rStruct )
     947             : {
     948          72 :     return lcl_getBorderLine( rLine, rStruct);
     949             : }
     950             : 
     951           0 : const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
     952             :         ::editeng::SvxBorderLine& rLine, const table::BorderLine2& rStruct )
     953             : {
     954           0 :     return lcl_getBorderLine( rLine, rStruct);
     955             : }
     956             : 
     957             : namespace {
     958             : template<typename TableBorderType>
     959          12 : void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder )
     960             : {
     961          12 :     ::editeng::SvxBorderLine aLine;
     962          12 :     rOuter.SetDistance( (sal_uInt16)HMMToTwips( rBorder.Distance ) );
     963          12 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ),         BOX_LINE_TOP );
     964          12 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ),      BOX_LINE_BOTTOM );
     965          12 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ),        BOX_LINE_LEFT );
     966          12 :     rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ),       BOX_LINE_RIGHT );
     967          12 :     rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ),  BOXINFO_LINE_HORI );
     968          12 :     rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ),    BOXINFO_LINE_VERT );
     969          12 :     rInner.SetValid( VALID_TOP,      rBorder.IsTopLineValid );
     970          12 :     rInner.SetValid( VALID_BOTTOM,   rBorder.IsBottomLineValid );
     971          12 :     rInner.SetValid( VALID_LEFT,     rBorder.IsLeftLineValid );
     972          12 :     rInner.SetValid( VALID_RIGHT,    rBorder.IsRightLineValid );
     973          12 :     rInner.SetValid( VALID_HORI,     rBorder.IsHorizontalLineValid );
     974          12 :     rInner.SetValid( VALID_VERT,     rBorder.IsVerticalLineValid );
     975          12 :     rInner.SetValid( VALID_DISTANCE, rBorder.IsDistanceValid );
     976          12 :     rInner.SetTable( true );
     977          12 : }
     978             : }
     979             : 
     980          12 : void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
     981             : {
     982          12 :     lcl_fillBoxItems( rOuter, rInner, rBorder);
     983          12 : }
     984             : 
     985           0 : void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder2& rBorder )
     986             : {
     987           0 :     lcl_fillBoxItems( rOuter, rInner, rBorder);
     988           0 : }
     989             : 
     990         372 : void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine )
     991             : {
     992             :     // Convert from Twips to 1/100mm.
     993         372 :     table::BorderLine2 aStruct( SvxBoxItem::SvxLineToLine( pLine, true));
     994         372 :     rStruct = aStruct;
     995         372 : }
     996             : 
     997         180 : void ScHelperFunctions::FillBorderLine( table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine )
     998             : {
     999         180 :     rStruct = SvxBoxItem::SvxLineToLine( pLine, true);
    1000         180 : }
    1001             : 
    1002             : namespace {
    1003             : template<typename TableBorderItem>
    1004          92 : void lcl_fillTableBorder( TableBorderItem& rBorder, const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner,
    1005             :         bool bInvalidateHorVerDist )
    1006             : {
    1007          92 :     ScHelperFunctions::FillBorderLine( rBorder.TopLine,         rOuter.GetTop() );
    1008          92 :     ScHelperFunctions::FillBorderLine( rBorder.BottomLine,      rOuter.GetBottom() );
    1009          92 :     ScHelperFunctions::FillBorderLine( rBorder.LeftLine,        rOuter.GetLeft() );
    1010          92 :     ScHelperFunctions::FillBorderLine( rBorder.RightLine,       rOuter.GetRight() );
    1011          92 :     ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine,  rInner.GetHori() );
    1012          92 :     ScHelperFunctions::FillBorderLine( rBorder.VerticalLine,    rInner.GetVert() );
    1013             : 
    1014          92 :     rBorder.Distance                = rOuter.GetDistance();
    1015          92 :     rBorder.IsTopLineValid          = rInner.IsValid(VALID_TOP);
    1016          92 :     rBorder.IsBottomLineValid       = rInner.IsValid(VALID_BOTTOM);
    1017          92 :     rBorder.IsLeftLineValid         = rInner.IsValid(VALID_LEFT);
    1018          92 :     rBorder.IsRightLineValid        = rInner.IsValid(VALID_RIGHT);
    1019          92 :     rBorder.IsHorizontalLineValid   = !bInvalidateHorVerDist && rInner.IsValid(VALID_HORI);
    1020          92 :     rBorder.IsVerticalLineValid     = !bInvalidateHorVerDist && rInner.IsValid(VALID_VERT);
    1021          92 :     rBorder.IsDistanceValid         = !bInvalidateHorVerDist && rInner.IsValid(VALID_DISTANCE);
    1022          92 : }
    1023             : }
    1024             : 
    1025          62 : void ScHelperFunctions::AssignTableBorderToAny( uno::Any& rAny,
    1026             :         const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
    1027             : {
    1028          62 :     table::TableBorder aBorder;
    1029          62 :     lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
    1030          62 :     rAny <<= aBorder;
    1031          62 : }
    1032             : 
    1033          30 : void ScHelperFunctions::AssignTableBorder2ToAny( uno::Any& rAny,
    1034             :         const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
    1035             : {
    1036          30 :     table::TableBorder2 aBorder;
    1037          30 :     lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
    1038          30 :     rAny <<= aBorder;
    1039          30 : }
    1040             : 
    1041             : //! lcl_ApplyBorder nach docfunc verschieben!
    1042             : 
    1043           8 : void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
    1044             :                         const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
    1045             : {
    1046           8 :     ScDocument& rDoc = pDocShell->GetDocument();
    1047           8 :     bool bUndo(rDoc.IsUndoEnabled());
    1048           8 :     ScDocument* pUndoDoc = NULL;
    1049           8 :     if (bUndo)
    1050           8 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1051           8 :     size_t nCount = rRanges.size();
    1052          16 :     for (size_t i = 0; i < nCount; ++i)
    1053             :     {
    1054           8 :         ScRange aRange( *rRanges[ i ] );
    1055           8 :         SCTAB nTab = aRange.aStart.Tab();
    1056             : 
    1057           8 :         if (bUndo)
    1058             :         {
    1059           8 :             if ( i==0 )
    1060           8 :                 pUndoDoc->InitUndo( &rDoc, nTab, nTab );
    1061             :             else
    1062           0 :                 pUndoDoc->AddUndoTab( nTab, nTab );
    1063           8 :             rDoc.CopyToDocument( aRange, IDF_ATTRIB, false, pUndoDoc );
    1064             :         }
    1065             : 
    1066           8 :         ScMarkData aMark;
    1067           8 :         aMark.SetMarkArea( aRange );
    1068           8 :         aMark.SelectTable( nTab, true );
    1069             : 
    1070           8 :         rDoc.ApplySelectionFrame( aMark, &rOuter, &rInner );
    1071             :         // RowHeight bei Umrandung alleine nicht noetig
    1072           8 :     }
    1073             : 
    1074           8 :     if (bUndo)
    1075             :     {
    1076           8 :         pDocShell->GetUndoManager()->AddUndoAction(
    1077           8 :                 new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
    1078             :     }
    1079             : 
    1080          16 :     for (size_t i = 0; i < nCount; ++i )
    1081           8 :         pDocShell->PostPaint( *rRanges[ i ], PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
    1082             : 
    1083           8 :     pDocShell->SetDocumentModified();
    1084           8 : }
    1085             : 
    1086             : //! move lcl_PutDataArray to docfunc?
    1087             : //! merge loop with ScFunctionAccess::callFunction
    1088             : 
    1089          16 : static bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
    1090             :                         const uno::Sequence< uno::Sequence<uno::Any> >& aData )
    1091             : {
    1092          16 :     ScDocument& rDoc = rDocShell.GetDocument();
    1093          16 :     SCTAB nTab = rRange.aStart.Tab();
    1094          16 :     SCCOL nStartCol = rRange.aStart.Col();
    1095          16 :     SCROW nStartRow = rRange.aStart.Row();
    1096          16 :     SCCOL nEndCol = rRange.aEnd.Col();
    1097          16 :     SCROW nEndRow = rRange.aEnd.Row();
    1098          16 :     bool bUndo(rDoc.IsUndoEnabled());
    1099             : 
    1100          16 :     if ( !rDoc.IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
    1101             :     {
    1102             :         //! error message
    1103           0 :         return false;
    1104             :     }
    1105             : 
    1106          16 :     long nCols = 0;
    1107          16 :     long nRows = aData.getLength();
    1108          16 :     const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
    1109          16 :     if ( nRows )
    1110          16 :         nCols = pArray[0].getLength();
    1111             : 
    1112          16 :     if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
    1113             :     {
    1114             :         //! error message?
    1115           0 :         return false;
    1116             :     }
    1117             : 
    1118          16 :     ScDocument* pUndoDoc = NULL;
    1119          16 :     if ( bUndo )
    1120             :     {
    1121          16 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1122          16 :         pUndoDoc->InitUndo( &rDoc, nTab, nTab );
    1123          16 :         rDoc.CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, false, pUndoDoc );
    1124             :     }
    1125             : 
    1126          16 :     rDoc.DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
    1127             : 
    1128          16 :     bool bError = false;
    1129          16 :     SCROW nDocRow = nStartRow;
    1130         832 :     for (long nRow=0; nRow<nRows; nRow++)
    1131             :     {
    1132         816 :         const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
    1133         816 :         if ( rColSeq.getLength() == nCols )
    1134             :         {
    1135         816 :             SCCOL nDocCol = nStartCol;
    1136         816 :             const uno::Any* pColArr = rColSeq.getConstArray();
    1137       40880 :             for (long nCol=0; nCol<nCols; nCol++)
    1138             :             {
    1139       40064 :                 ScAddress aPos(nDocCol, nDocRow, nTab);
    1140             : 
    1141       40064 :                 const uno::Any& rElement = pColArr[nCol];
    1142       40064 :                 switch( rElement.getValueTypeClass() )
    1143             :                 {
    1144             :                     case uno::TypeClass_VOID:
    1145             :                     {
    1146             :                         // void = "no value"
    1147           0 :                         rDoc.SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
    1148             :                     }
    1149           0 :                     break;
    1150             : 
    1151             :                     //  #87871# accept integer types because Basic passes a floating point
    1152             :                     //  variable as byte, short or long if it's an integer number.
    1153             :                     case uno::TypeClass_BYTE:
    1154             :                     case uno::TypeClass_SHORT:
    1155             :                     case uno::TypeClass_UNSIGNED_SHORT:
    1156             :                     case uno::TypeClass_LONG:
    1157             :                     case uno::TypeClass_UNSIGNED_LONG:
    1158             :                     case uno::TypeClass_FLOAT:
    1159             :                     case uno::TypeClass_DOUBLE:
    1160             :                     {
    1161       40064 :                         double fVal(0.0);
    1162       40064 :                         rElement >>= fVal;
    1163       40064 :                         rDoc.SetValue(aPos, fVal);
    1164             :                     }
    1165       40064 :                     break;
    1166             : 
    1167             :                     case uno::TypeClass_STRING:
    1168             :                     {
    1169           0 :                         OUString aUStr;
    1170           0 :                         rElement >>= aUStr;
    1171           0 :                         if ( !aUStr.isEmpty() )
    1172             :                         {
    1173           0 :                             ScSetStringParam aParam;
    1174           0 :                             aParam.setTextInput();
    1175           0 :                             rDoc.SetString(aPos, aUStr, &aParam);
    1176           0 :                         }
    1177             :                     }
    1178           0 :                     break;
    1179             : 
    1180             :                     // accept Sequence<FormulaToken> for formula cells
    1181             :                     case uno::TypeClass_SEQUENCE:
    1182             :                     {
    1183           0 :                         uno::Sequence< sheet::FormulaToken > aTokens;
    1184           0 :                         if ( rElement >>= aTokens )
    1185             :                         {
    1186           0 :                             ScTokenArray aTokenArray;
    1187           0 :                             ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, aTokens );
    1188           0 :                             rDoc.SetFormula(aPos, aTokenArray);
    1189             :                         }
    1190             :                         else
    1191           0 :                             bError = true;
    1192             :                     }
    1193           0 :                     break;
    1194             : 
    1195             :                     default:
    1196           0 :                         bError = true;      // invalid type
    1197             :                 }
    1198       40064 :                 ++nDocCol;
    1199             :             }
    1200             :         }
    1201             :         else
    1202           0 :             bError = true;                          // wrong size
    1203             : 
    1204         816 :         ++nDocRow;
    1205             :     }
    1206             : 
    1207          16 :     bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
    1208             : 
    1209          16 :     if ( pUndoDoc )
    1210             :     {
    1211          16 :         ScMarkData aDestMark;
    1212          16 :         aDestMark.SelectOneTable( nTab );
    1213          16 :         rDocShell.GetUndoManager()->AddUndoAction(
    1214             :             new ScUndoPaste(
    1215             :                 &rDocShell, ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab),
    1216          16 :                 aDestMark, pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
    1217             :     }
    1218             : 
    1219          16 :     if (!bHeight)
    1220          16 :         rDocShell.PostPaint( rRange, PAINT_GRID );      // AdjustRowHeight may have painted already
    1221             : 
    1222          16 :     rDocShell.SetDocumentModified();
    1223             : 
    1224          16 :     return !bError;
    1225             : }
    1226             : 
    1227           4 : static bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
    1228             :         const uno::Sequence< uno::Sequence<OUString> >& aData,
    1229             :         const formula::FormulaGrammar::Grammar eGrammar )
    1230             : {
    1231           4 :     ScDocument& rDoc = rDocShell.GetDocument();
    1232           4 :     SCTAB nTab = rRange.aStart.Tab();
    1233           4 :     SCCOL nStartCol = rRange.aStart.Col();
    1234           4 :     SCROW nStartRow = rRange.aStart.Row();
    1235           4 :     SCCOL nEndCol = rRange.aEnd.Col();
    1236           4 :     SCROW nEndRow = rRange.aEnd.Row();
    1237           4 :     bool bUndo(rDoc.IsUndoEnabled());
    1238             : 
    1239           4 :     if ( !rDoc.IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
    1240             :     {
    1241             :         //! error message
    1242           0 :         return false;
    1243             :     }
    1244             : 
    1245           4 :     long nCols = 0;
    1246           4 :     long nRows = aData.getLength();
    1247           4 :     const uno::Sequence<OUString>* pArray = aData.getConstArray();
    1248           4 :     if ( nRows )
    1249           4 :         nCols = pArray[0].getLength();
    1250             : 
    1251           4 :     if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
    1252             :     {
    1253             :         //! error message?
    1254           0 :         return false;
    1255             :     }
    1256             : 
    1257           4 :     ScDocument* pUndoDoc = NULL;
    1258           4 :     if ( bUndo )
    1259             :     {
    1260           4 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1261           4 :         pUndoDoc->InitUndo( &rDoc, nTab, nTab );
    1262           4 :         rDoc.CopyToDocument( rRange, IDF_CONTENTS, false, pUndoDoc );
    1263             :     }
    1264             : 
    1265           4 :     rDoc.DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
    1266             : 
    1267           4 :     bool bError = false;
    1268           4 :     SCROW nDocRow = nStartRow;
    1269          24 :     for (long nRow=0; nRow<nRows; nRow++)
    1270             :     {
    1271          20 :         const uno::Sequence<OUString>& rColSeq = pArray[nRow];
    1272          20 :         if ( rColSeq.getLength() == nCols )
    1273             :         {
    1274          20 :             SCCOL nDocCol = nStartCol;
    1275          20 :             const OUString* pColArr = rColSeq.getConstArray();
    1276         100 :             for (long nCol=0; nCol<nCols; nCol++)
    1277             :             {
    1278          80 :                 OUString aText(pColArr[nCol]);
    1279          80 :                 ScAddress aPos( nDocCol, nDocRow, nTab );
    1280             : 
    1281             :                 ScInputStringType aRes =
    1282             :                     ScStringUtil::parseInputString(
    1283         160 :                         *rDoc.GetFormatTable(), aText, LANGUAGE_ENGLISH_US);
    1284          80 :                 switch (aRes.meType)
    1285             :                 {
    1286             :                     case ScInputStringType::Formula:
    1287           0 :                         rDoc.SetFormula(aPos, aRes.maText, eGrammar);
    1288           0 :                     break;
    1289             :                     case ScInputStringType::Number:
    1290           0 :                         rDoc.SetValue(aPos, aRes.mfValue);
    1291           0 :                     break;
    1292             :                     case ScInputStringType::Text:
    1293           2 :                         rDoc.SetTextCell(aPos, aRes.maText);
    1294           2 :                     break;
    1295             :                     default:
    1296             :                         ;
    1297             :                 }
    1298             : 
    1299          80 :                 ++nDocCol;
    1300          80 :             }
    1301             :         }
    1302             :         else
    1303           0 :             bError = true;                          // wrong size
    1304             : 
    1305          20 :         ++nDocRow;
    1306             :     }
    1307             : 
    1308           4 :     bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
    1309             : 
    1310           4 :     if ( pUndoDoc )
    1311             :     {
    1312           4 :         ScMarkData aDestMark;
    1313           4 :         aDestMark.SelectOneTable( nTab );
    1314           4 :         rDocShell.GetUndoManager()->AddUndoAction(
    1315             :             new ScUndoPaste( &rDocShell,
    1316             :                 ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark,
    1317           4 :                 pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
    1318             :     }
    1319             : 
    1320           4 :     if (!bHeight)
    1321           4 :         rDocShell.PostPaint( rRange, PAINT_GRID );      // AdjustRowHeight may have painted already
    1322             : 
    1323           4 :     rDocShell.SetDocumentModified();
    1324             : 
    1325           4 :     return !bError;
    1326             : }
    1327             : 
    1328             : //  used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
    1329         452 : static OUString lcl_GetInputString( ScDocument& rDoc, const ScAddress& rPos, bool bEnglish )
    1330             : {
    1331         452 :     ScRefCellValue aCell;
    1332         452 :     aCell.assign(rDoc, rPos);
    1333         452 :     if (aCell.isEmpty())
    1334         222 :         return EMPTY_OUSTRING;
    1335             : 
    1336         460 :     OUString aVal;
    1337             : 
    1338         230 :     CellType eType = aCell.meType;
    1339         230 :     if (eType == CELLTYPE_FORMULA)
    1340             :     {
    1341         122 :         ScFormulaCell* pForm = aCell.mpFormula;
    1342         122 :         pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
    1343         122 :         return aVal;
    1344             :     }
    1345             : 
    1346             :     SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
    1347         108 :                                                 rDoc.GetFormatTable();
    1348             :     // Since the English formatter was constructed with
    1349             :     // LANGUAGE_ENGLISH_US the "General" format has index key 0,
    1350             :     // we don't have to query.
    1351         108 :     sal_uInt32 nNumFmt = bEnglish ? 0 : rDoc.GetNumberFormat(rPos);
    1352             : 
    1353         108 :     if (eType == CELLTYPE_EDIT)
    1354             :     {
    1355             :         //  GetString an der EditCell macht Leerzeichen aus Umbruechen,
    1356             :         //  hier werden die Umbrueche aber gebraucht
    1357           0 :         const EditTextObject* pData = aCell.mpEditText;
    1358           0 :         if (pData)
    1359             :         {
    1360           0 :             EditEngine& rEngine = rDoc.GetEditEngine();
    1361           0 :             rEngine.SetText(*pData);
    1362           0 :             aVal = rEngine.GetText(LINEEND_LF);
    1363             :         }
    1364             :     }
    1365             :     else
    1366         108 :         ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, &rDoc);
    1367             : 
    1368             :     //  ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
    1369         108 :     if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
    1370             :     {
    1371             :         double fDummy;
    1372          48 :         OUString aTempString = aVal;
    1373          48 :         bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
    1374          48 :         if ( bIsNumberFormat )
    1375           0 :             aTempString = "'" + aTempString;
    1376          48 :         else if ( aTempString.startsWith("'") )
    1377             :         {
    1378             :             //  if the string starts with a "'", add another one because setFormula
    1379             :             //  strips one (like text input, except for "text" number formats)
    1380           0 :             if ( bEnglish || ( pFormatter->GetType(nNumFmt) != NUMBERFORMAT_TEXT ) )
    1381           0 :                 aTempString = "'" + aTempString;
    1382             :         }
    1383          48 :         aVal = aTempString;
    1384             :     }
    1385         560 :     return aVal;
    1386             : }
    1387             : 
    1388       49422 : ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
    1389       49422 :     pPropSet(lcl_GetCellsPropertySet()),
    1390             :     pDocShell( pDocSh ),
    1391             :     pValueListener( NULL ),
    1392             :     pCurrentFlat( NULL ),
    1393             :     pCurrentDeep( NULL ),
    1394             :     pCurrentDataSet( NULL ),
    1395             :     pNoDfltCurrentDataSet( NULL ),
    1396             :     pMarkData( NULL ),
    1397             :     nObjectId( 0 ),
    1398             :     bChartColAsHdr( false ),
    1399             :     bChartRowAsHdr( false ),
    1400             :     bCursorOnly( false ),
    1401             :     bGotDataChangedHint( false ),
    1402       98844 :     aValueListeners( 0 )
    1403             : {
    1404             :     // this is a hack to get m_wThis initialized; ideally there would be
    1405             :     // factory functions doing this but there are so many subclasses of this...
    1406       49422 :     ++m_refCount;
    1407             :     {
    1408       98844 :         m_wThis = uno::Reference<uno::XInterface>(
    1409       49422 :                     static_cast<cppu::OWeakObject*>(this));
    1410             :     }
    1411       49422 :     --m_refCount;
    1412             : 
    1413       49422 :     ScRange aCellRange(rR);
    1414       49422 :     aCellRange.Justify();
    1415       49422 :     aRanges.Append( aCellRange );
    1416             : 
    1417       49422 :     if (pDocShell)  // Null if created with createInstance
    1418             :     {
    1419       49420 :         ScDocument& rDoc = pDocShell->GetDocument();
    1420       49420 :         rDoc.AddUnoObject(*this);
    1421       49420 :         nObjectId = rDoc.GetNewUnoId();
    1422             :     }
    1423       49422 : }
    1424             : 
    1425        3442 : ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
    1426        3442 :     pPropSet(lcl_GetCellsPropertySet()),
    1427             :     pDocShell( pDocSh ),
    1428             :     pValueListener( NULL ),
    1429             :     pCurrentFlat( NULL ),
    1430             :     pCurrentDeep( NULL ),
    1431             :     pCurrentDataSet( NULL ),
    1432             :     pNoDfltCurrentDataSet( NULL ),
    1433             :     pMarkData( NULL ),
    1434             :     aRanges( rR ),
    1435             :     nObjectId( 0 ),
    1436             :     bChartColAsHdr( false ),
    1437             :     bChartRowAsHdr( false ),
    1438             :     bCursorOnly( false ),
    1439             :     bGotDataChangedHint( false ),
    1440        6884 :     aValueListeners( 0 )
    1441             : {
    1442             :     // this is a hack to get m_wThis initialized; ideally there would be
    1443             :     // factory functions doing this but there are so many subclasses of this...
    1444        3442 :     ++m_refCount;
    1445             :     {
    1446        6884 :         m_wThis = uno::Reference<uno::XInterface>(
    1447        3442 :                     static_cast<cppu::OWeakObject*>(this));
    1448             :     }
    1449        3442 :     --m_refCount;
    1450             : 
    1451        3442 :     if (pDocShell)  // Null if created with createInstance
    1452             :     {
    1453        3442 :         ScDocument& rDoc = pDocShell->GetDocument();
    1454        3442 :         rDoc.AddUnoObject(*this);
    1455        3442 :         nObjectId = rDoc.GetNewUnoId();
    1456             :     }
    1457        3442 : }
    1458             : 
    1459      105304 : ScCellRangesBase::~ScCellRangesBase()
    1460             : {
    1461       52652 :     SolarMutexGuard g;
    1462             : 
    1463             :     //  call RemoveUnoObject first, so no notification can happen
    1464             :     //  during ForgetCurrentAttrs
    1465             : 
    1466       52652 :     if (pDocShell)
    1467       45328 :         pDocShell->GetDocument().RemoveUnoObject(*this);
    1468             : 
    1469       52652 :     ForgetCurrentAttrs();
    1470       52652 :     ForgetMarkData();
    1471             : 
    1472       52652 :     delete pValueListener;
    1473             : 
    1474             :     //! XChartDataChangeEventListener abmelden ??
    1475             :     //! (ChartCollection haelt dann auch dieses Objekt fest!)
    1476       52652 : }
    1477             : 
    1478      407758 : void ScCellRangesBase::ForgetCurrentAttrs()
    1479             : {
    1480      407758 :     delete pCurrentFlat;
    1481      407758 :     delete pCurrentDeep;
    1482      407758 :     delete pCurrentDataSet;
    1483      407758 :     delete pNoDfltCurrentDataSet;
    1484      407758 :     pCurrentFlat = NULL;
    1485      407758 :     pCurrentDeep = NULL;
    1486      407758 :     pCurrentDataSet = NULL;
    1487      407758 :     pNoDfltCurrentDataSet = NULL;
    1488             : 
    1489             :     // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
    1490      407758 : }
    1491             : 
    1492       65262 : void ScCellRangesBase::ForgetMarkData()
    1493             : {
    1494       65262 :     delete pMarkData;
    1495       65262 :     pMarkData = NULL;
    1496       65262 : }
    1497             : 
    1498       15020 : const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
    1499             : {
    1500             :     //  get and cache direct cell attributes for this object's range
    1501             : 
    1502       15020 :     if ( !pCurrentFlat && pDocShell )
    1503             :     {
    1504         332 :         ScDocument& rDoc = pDocShell->GetDocument();
    1505         332 :         pCurrentFlat = rDoc.CreateSelectionPattern( *GetMarkData(), false );
    1506             :     }
    1507       15020 :     return pCurrentFlat;
    1508             : }
    1509             : 
    1510       14452 : const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
    1511             : {
    1512             :     //  get and cache cell attributes (incl. styles) for this object's range
    1513             : 
    1514       14452 :     if ( !pCurrentDeep && pDocShell )
    1515             :     {
    1516       13458 :         ScDocument& rDoc = pDocShell->GetDocument();
    1517       13458 :         pCurrentDeep = rDoc.CreateSelectionPattern( *GetMarkData(), true );
    1518             :     }
    1519       14452 :     return pCurrentDeep;
    1520             : }
    1521             : 
    1522       18758 : SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
    1523             : {
    1524       18758 :     if(!pCurrentDataSet)
    1525             :     {
    1526       10756 :         const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
    1527       10756 :         if ( pPattern )
    1528             :         {
    1529             :             //  Dontcare durch Default ersetzen, damit man immer eine Reflection hat
    1530       10756 :             pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
    1531       10756 :             pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
    1532       10756 :             pCurrentDataSet->ClearInvalidItems();
    1533             :         }
    1534             :     }
    1535       18758 :     return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
    1536             : }
    1537             : 
    1538       20482 : const ScMarkData* ScCellRangesBase::GetMarkData()
    1539             : {
    1540       20482 :     if (!pMarkData)
    1541             :     {
    1542       12522 :         pMarkData = new ScMarkData();
    1543       12522 :         pMarkData->MarkFromRangeList( aRanges, false );
    1544             :     }
    1545       20482 :     return pMarkData;
    1546             : }
    1547             : 
    1548      352778 : void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1549             : {
    1550      352778 :     uno::Reference<uno::XInterface> const xThis(m_wThis);
    1551      352778 :     if (!xThis.is())
    1552             :     {   // fdo#72695: if UNO object is already dead, don't revive it with event
    1553      352778 :         return;
    1554             :     }
    1555      352778 :     if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
    1556             :     {
    1557        6126 :         const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint);
    1558             : 
    1559        6126 :         ScDocument& rDoc = pDocShell->GetDocument();
    1560        6126 :         boost::scoped_ptr<ScRangeList> pUndoRanges;
    1561        6126 :         if ( rDoc.HasUnoRefUndo() )
    1562        3478 :             pUndoRanges.reset(new ScRangeList( aRanges ));
    1563             : 
    1564       12252 :         if ( aRanges.UpdateReference( rRef.GetMode(), &rDoc, rRef.GetRange(),
    1565       12252 :                                     rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
    1566             :         {
    1567       17488 :             if (  rRef.GetMode() == URM_INSDEL
    1568        5804 :                && aRanges.size() == 1
    1569       28890 :                && ScTableSheetObj::getImplementation(xThis)
    1570             :                )
    1571             :             {
    1572             :                 // #101755#; the range size of a sheet does not change
    1573         712 :                 ScRange* pR = aRanges.front();
    1574         712 :                 if (pR)
    1575             :                 {
    1576         712 :                     pR->aStart.SetCol(0);
    1577         712 :                     pR->aStart.SetRow(0);
    1578         712 :                     pR->aEnd.SetCol(MAXCOL);
    1579         712 :                     pR->aEnd.SetRow(MAXROW);
    1580             :                 }
    1581             :             }
    1582        5806 :             RefChanged();
    1583             : 
    1584             :             // any change of the range address is broadcast to value (modify) listeners
    1585        5806 :             if ( !aValueListeners.empty() )
    1586           0 :                 bGotDataChangedHint = true;
    1587             : 
    1588        5806 :             if ( pUndoRanges )
    1589        3270 :                 rDoc.AddUnoRefChange( nObjectId, *pUndoRanges );
    1590        6126 :         }
    1591             :     }
    1592      346652 :     else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
    1593             :     {
    1594      343258 :         sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
    1595      343258 :         if ( nId == SFX_HINT_DYING )
    1596             :         {
    1597        7534 :             ForgetCurrentAttrs();
    1598        7534 :             pDocShell = NULL;           // invalid
    1599             : 
    1600        7534 :             if ( !aValueListeners.empty() )
    1601             :             {
    1602             :                 //  dispose listeners
    1603             : 
    1604           8 :                 lang::EventObject aEvent;
    1605           8 :                 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
    1606          16 :                 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
    1607           8 :                     aValueListeners[n]->disposing( aEvent );
    1608             : 
    1609           8 :                 aValueListeners.clear();
    1610             : 
    1611             :                 //  The listeners can't have the last ref to this, as it's still held
    1612             :                 //  by the DocShell.
    1613             :             }
    1614             :         }
    1615      335724 :         else if ( nId == SFX_HINT_DATACHANGED )
    1616             :         {
    1617             :             // document content changed -> forget cached attributes
    1618      334962 :             ForgetCurrentAttrs();
    1619             : 
    1620      334962 :             if ( bGotDataChangedHint && pDocShell )
    1621             :             {
    1622             :                 //  This object was notified of content changes, so one call
    1623             :                 //  for each listener is generated now.
    1624             :                 //  The calls can't be executed directly because the document's
    1625             :                 //  UNO broadcaster list must not be modified.
    1626             :                 //  Instead, add to the document's list of listener calls,
    1627             :                 //  which will be executed directly after the broadcast of
    1628             :                 //  SFX_HINT_DATACHANGED.
    1629             : 
    1630           0 :                 lang::EventObject aEvent;
    1631           0 :                 aEvent.Source.set((cppu::OWeakObject*)this);
    1632             : 
    1633             :                 // the EventObject holds a Ref to this object until after the listener calls
    1634             : 
    1635           0 :                 ScDocument& rDoc = pDocShell->GetDocument();
    1636           0 :                 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
    1637           0 :                     rDoc.AddUnoListenerCall( aValueListeners[n], aEvent );
    1638             : 
    1639           0 :                 bGotDataChangedHint = false;
    1640             :             }
    1641             :         }
    1642         762 :         else if ( nId == SC_HINT_CALCALL )
    1643             :         {
    1644             :             // broadcast from DoHardRecalc - set bGotDataChangedHint
    1645             :             // (SFX_HINT_DATACHANGED follows separately)
    1646             : 
    1647         762 :             if ( !aValueListeners.empty() )
    1648           0 :                 bGotDataChangedHint = true;
    1649      343258 :         }
    1650             :     }
    1651        3394 :     else if ( dynamic_cast<const ScUnoRefUndoHint*>(&rHint) )
    1652             :     {
    1653           0 :         const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
    1654           0 :         if ( rUndoHint.GetObjectId() == nObjectId )
    1655             :         {
    1656             :             // restore ranges from hint
    1657             : 
    1658           0 :             aRanges = rUndoHint.GetRanges();
    1659             : 
    1660           0 :             RefChanged();
    1661           0 :             if ( !aValueListeners.empty() )
    1662           0 :                 bGotDataChangedHint = true;     // need to broadcast the undo, too
    1663             :         }
    1664      352778 :     }
    1665             : }
    1666             : 
    1667       12610 : void ScCellRangesBase::RefChanged()
    1668             : {
    1669             :     //! adjust XChartDataChangeEventListener
    1670             : 
    1671       12610 :     if ( pValueListener && !aValueListeners.empty() )
    1672             :     {
    1673           0 :         pValueListener->EndListeningAll();
    1674             : 
    1675           0 :         ScDocument& rDoc = pDocShell->GetDocument();
    1676           0 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    1677           0 :             rDoc.StartListeningArea( *aRanges[ i ], pValueListener );
    1678             :     }
    1679             : 
    1680       12610 :     ForgetCurrentAttrs();
    1681       12610 :     ForgetMarkData();
    1682       12610 : }
    1683             : 
    1684           0 : ScDocument* ScCellRangesBase::GetDocument() const
    1685             : {
    1686           0 :     if (pDocShell)
    1687           0 :         return &pDocShell->GetDocument();
    1688             :     else
    1689           0 :         return NULL;
    1690             : }
    1691             : 
    1692           0 : void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
    1693             : {
    1694           0 :     if ( !pDocShell && pDocSh )
    1695             :     {
    1696           0 :         pDocShell = pDocSh;
    1697             : 
    1698           0 :         ScRange aCellRange(rR);
    1699           0 :         aCellRange.Justify();
    1700           0 :         aRanges.RemoveAll();
    1701           0 :         aRanges.Append( aCellRange );
    1702             : 
    1703           0 :         pDocShell->GetDocument().AddUnoObject(*this);
    1704             : 
    1705           0 :         RefChanged();   // Range im Range-Objekt anpassen
    1706             :     }
    1707           0 : }
    1708             : 
    1709        6058 : void ScCellRangesBase::AddRange(const ScRange& rRange, const bool bMergeRanges)
    1710             : {
    1711        6058 :     if (bMergeRanges)
    1712           0 :         aRanges.Join(rRange);
    1713             :     else
    1714        6058 :         aRanges.Append(rRange);
    1715        6058 :     RefChanged();
    1716        6058 : }
    1717             : 
    1718         654 : void ScCellRangesBase::SetNewRange(const ScRange& rNew)
    1719             : {
    1720         654 :     ScRange aCellRange(rNew);
    1721         654 :     aCellRange.Justify();
    1722             : 
    1723         654 :     aRanges.RemoveAll();
    1724         654 :     aRanges.Append( aCellRange );
    1725         654 :     RefChanged();
    1726         654 : }
    1727             : 
    1728          92 : void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
    1729             : {
    1730          92 :     aRanges = rNew;
    1731          92 :     RefChanged();
    1732          92 : }
    1733             : 
    1734         574 : void ScCellRangesBase::SetCursorOnly( bool bSet )
    1735             : {
    1736             :     //  set for a selection object that is created from the cursor position
    1737             :     //  without anything selected (may contain several sheets)
    1738             : 
    1739         574 :     bCursorOnly = bSet;
    1740         574 : }
    1741             : 
    1742      475976 : uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
    1743             :                                                 throw(uno::RuntimeException, std::exception)
    1744             : {
    1745      475976 :     SC_QUERYINTERFACE( beans::XPropertySet )
    1746      451732 :     SC_QUERYINTERFACE( beans::XMultiPropertySet )
    1747      449756 :     SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
    1748      447056 :     SC_QUERYINTERFACE( beans::XPropertyState )
    1749      446904 :     SC_QUERYINTERFACE( sheet::XSheetOperation )
    1750      446750 :     SC_QUERYINTERFACE( chart::XChartDataArray )
    1751      446744 :     SC_QUERYINTERFACE( chart::XChartData )
    1752      446742 :     SC_QUERYINTERFACE( util::XIndent )
    1753      446736 :     SC_QUERYINTERFACE( sheet::XCellRangesQuery )
    1754      446576 :     SC_QUERYINTERFACE( sheet::XFormulaQuery )
    1755      446570 :     SC_QUERYINTERFACE( util::XReplaceable )
    1756      446522 :     SC_QUERYINTERFACE( util::XSearchable )
    1757      446506 :     SC_QUERYINTERFACE( util::XModifyBroadcaster )
    1758      446494 :     SC_QUERYINTERFACE( lang::XServiceInfo )
    1759      446430 :     SC_QUERYINTERFACE( lang::XUnoTunnel )
    1760      416348 :     SC_QUERYINTERFACE( lang::XTypeProvider )
    1761             : 
    1762      416332 :     return OWeakObject::queryInterface( rType );
    1763             : }
    1764             : 
    1765     1616058 : void SAL_CALL ScCellRangesBase::acquire() throw()
    1766             : {
    1767     1616058 :     OWeakObject::acquire();
    1768     1616058 : }
    1769             : 
    1770     1615846 : void SAL_CALL ScCellRangesBase::release() throw()
    1771             : {
    1772     1615846 :     OWeakObject::release();
    1773     1615846 : }
    1774             : 
    1775           4 : uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException, std::exception)
    1776             : {
    1777           4 :     static uno::Sequence<uno::Type> aTypes;
    1778           4 :     if ( aTypes.getLength() == 0 )
    1779             :     {
    1780           4 :         aTypes.realloc(13);
    1781           4 :         uno::Type* pPtr = aTypes.getArray();
    1782           4 :         pPtr[0] = cppu::UnoType<beans::XPropertySet>::get();
    1783           4 :         pPtr[1] = cppu::UnoType<beans::XMultiPropertySet>::get();
    1784           4 :         pPtr[2] = cppu::UnoType<beans::XPropertyState>::get();
    1785           4 :         pPtr[3] = cppu::UnoType<sheet::XSheetOperation>::get();
    1786           4 :         pPtr[4] = cppu::UnoType<chart::XChartDataArray>::get();
    1787           4 :         pPtr[5] = cppu::UnoType<util::XIndent>::get();
    1788           4 :         pPtr[6] = cppu::UnoType<sheet::XCellRangesQuery>::get();
    1789           4 :         pPtr[7] = cppu::UnoType<sheet::XFormulaQuery>::get();
    1790           4 :         pPtr[8] = cppu::UnoType<util::XReplaceable>::get();
    1791           4 :         pPtr[9] = cppu::UnoType<util::XModifyBroadcaster>::get();
    1792           4 :         pPtr[10]= cppu::UnoType<lang::XServiceInfo>::get();
    1793           4 :         pPtr[11]= cppu::UnoType<lang::XUnoTunnel>::get();
    1794           4 :         pPtr[12]= cppu::UnoType<lang::XTypeProvider>::get();
    1795             :     }
    1796           4 :     return aTypes;
    1797             : }
    1798             : 
    1799           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
    1800             :                                                     throw(uno::RuntimeException, std::exception)
    1801             : {
    1802           0 :     return css::uno::Sequence<sal_Int8>();
    1803             : }
    1804             : 
    1805          16 : void ScCellRangesBase::PaintRanges_Impl( sal_uInt16 nPart )
    1806             : {
    1807          62 :     for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
    1808          46 :         pDocShell->PostPaint( *aRanges[ i ], nPart );
    1809          16 : }
    1810             : 
    1811             : // XSheetOperation
    1812             : 
    1813           8 : double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
    1814             :     throw(uno::Exception, uno::RuntimeException, std::exception)
    1815             : {
    1816           8 :     SolarMutexGuard aGuard;
    1817          16 :     ScMarkData aMark(*GetMarkData());
    1818           8 :     aMark.MarkToSimple();
    1819           8 :     if (!aMark.IsMarked())
    1820           4 :         aMark.SetMarkNegative(true);    // um Dummy Position angeben zu koennen
    1821             : 
    1822           8 :     ScAddress aDummy;                   // wenn nicht Marked, ignoriert wegen Negative
    1823             :     double fVal;
    1824           8 :     ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(nFunction);
    1825           8 :     ScDocument& rDoc = pDocShell->GetDocument();
    1826           8 :     if ( !rDoc.GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
    1827             :     {
    1828           0 :         throw uno::RuntimeException();      //! own exception?
    1829             :     }
    1830             : 
    1831          16 :     return fVal;
    1832             : }
    1833             : 
    1834         154 : void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException, std::exception)
    1835             : {
    1836         154 :     SolarMutexGuard aGuard;
    1837         154 :     if ( !aRanges.empty() )
    1838             :     {
    1839             :         // only for clearContents: EDITATTR is only used if no contents are deleted
    1840         154 :         InsertDeleteFlags nDelFlags = InsertDeleteFlags::fromInt(nContentFlags) & IDF_ALL;
    1841         154 :         if ( ( nDelFlags & IDF_EDITATTR ) && ( nDelFlags & IDF_CONTENTS ) == IDF_NONE )
    1842           0 :             nDelFlags |= IDF_EDITATTR;
    1843             : 
    1844         154 :         pDocShell->GetDocFunc().DeleteContents( *GetMarkData(), nDelFlags, true, true );
    1845         154 :     }
    1846             :     // sonst ist nichts zu tun
    1847         154 : }
    1848             : 
    1849             : // XPropertyState
    1850             : 
    1851        4700 : const SfxItemPropertyMap& ScCellRangesBase::GetItemPropertyMap()
    1852             : {
    1853        4700 :     return pPropSet->getPropertyMap();
    1854             : }
    1855             : 
    1856       16210 : static void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
    1857             :                                                 sal_uInt16& rItemWhich )
    1858             : {
    1859             :     //  Which-ID des betroffenen Items, auch wenn das Item die Property
    1860             :     //  nicht alleine behandeln kann
    1861       16210 :     if ( pEntry )
    1862             :     {
    1863       16210 :         if ( IsScItemWid( pEntry->nWID ) )
    1864       14468 :             rItemWhich = pEntry->nWID;
    1865             :         else
    1866        1742 :             switch ( pEntry->nWID )
    1867             :             {
    1868             :                 case SC_WID_UNO_TBLBORD:
    1869             :                 case SC_WID_UNO_TBLBORD2:
    1870          60 :                     rItemWhich = ATTR_BORDER;
    1871          60 :                     break;
    1872             :                 case SC_WID_UNO_CONDFMT:
    1873             :                 case SC_WID_UNO_CONDLOC:
    1874             :                 case SC_WID_UNO_CONDXML:
    1875         246 :                     rItemWhich = ATTR_CONDITIONAL;
    1876         246 :                     break;
    1877             :                 case SC_WID_UNO_VALIDAT:
    1878             :                 case SC_WID_UNO_VALILOC:
    1879             :                 case SC_WID_UNO_VALIXML:
    1880         246 :                     rItemWhich = ATTR_VALIDDATA;
    1881         246 :                     break;
    1882             :             }
    1883             :     }
    1884             : 
    1885       16210 : }
    1886             : 
    1887       16210 : beans::PropertyState ScCellRangesBase::GetOnePropertyState( sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
    1888             : {
    1889       16210 :     beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
    1890       16210 :     if ( nItemWhich )                   // item wid (from map or special case)
    1891             :     {
    1892             :         //  For items that contain several properties (like background),
    1893             :         //  "ambiguous" is returned too often here
    1894             : 
    1895             :         //  for PropertyState, don't look at styles
    1896       15020 :         const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
    1897       15020 :         if ( pPattern )
    1898             :         {
    1899       15020 :             SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, false );
    1900             : 
    1901       15020 :             if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SfxItemState::DEFAULT )
    1902         142 :                 eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, false );
    1903             : 
    1904       15020 :             if ( eState == SfxItemState::SET )
    1905        2080 :                 eRet = beans::PropertyState_DIRECT_VALUE;
    1906       12940 :             else if ( eState == SfxItemState::DEFAULT )
    1907       12936 :                 eRet = beans::PropertyState_DEFAULT_VALUE;
    1908           4 :             else if ( eState == SfxItemState::DONTCARE )
    1909           4 :                 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
    1910             :             else
    1911             :             {
    1912             :                 OSL_FAIL("unbekannter ItemState");
    1913             :             }
    1914             :         }
    1915             :     }
    1916        1190 :     else if ( pEntry )
    1917             :     {
    1918        1190 :         if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
    1919          90 :             eRet = beans::PropertyState_DIRECT_VALUE;
    1920        1100 :         else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    1921             :         {
    1922             :             //  a style is always set, there's no default state
    1923         186 :             const ScStyleSheet* pStyle = pDocShell->GetDocument().GetSelectionStyle(*GetMarkData());
    1924         186 :             if (pStyle)
    1925         186 :                 eRet = beans::PropertyState_DIRECT_VALUE;
    1926             :             else
    1927           0 :                 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
    1928             :         }
    1929         914 :         else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
    1930          30 :             eRet = beans::PropertyState_DEFAULT_VALUE;      // numbering rules are always default
    1931             :     }
    1932       16210 :     return eRet;
    1933             : }
    1934             : 
    1935         688 : beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const OUString& aPropertyName )
    1936             :                                 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1937             : {
    1938         688 :     SolarMutexGuard aGuard;
    1939         688 :     if ( aRanges.empty() )
    1940           0 :         throw uno::RuntimeException();
    1941             : 
    1942         688 :     const SfxItemPropertyMap& rMap = GetItemPropertyMap();     // from derived class
    1943         688 :     sal_uInt16 nItemWhich = 0;
    1944         688 :     const SfxItemPropertySimpleEntry* pEntry  = rMap.getByName( aPropertyName );
    1945         688 :     lcl_GetPropertyWhich( pEntry, nItemWhich );
    1946         688 :     return GetOnePropertyState( nItemWhich, pEntry );
    1947             : }
    1948             : 
    1949           0 : uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
    1950             :                                 const uno::Sequence<OUString>& aPropertyNames )
    1951             :                             throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1952             : {
    1953           0 :     SolarMutexGuard aGuard;
    1954             : 
    1955           0 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    1956             : 
    1957           0 :     uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
    1958           0 :     beans::PropertyState* pStates = aRet.getArray();
    1959           0 :     for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
    1960             :     {
    1961           0 :         sal_uInt16 nItemWhich = 0;
    1962           0 :         const SfxItemPropertySimpleEntry* pEntry  = rPropertyMap.getByName( aPropertyNames[i] );
    1963           0 :         lcl_GetPropertyWhich( pEntry, nItemWhich );
    1964           0 :         pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
    1965             :     }
    1966           0 :     return aRet;
    1967             : }
    1968             : 
    1969           0 : void SAL_CALL ScCellRangesBase::setPropertyToDefault( const OUString& aPropertyName )
    1970             :                             throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1971             : {
    1972           0 :     SolarMutexGuard aGuard;
    1973           0 :     if ( pDocShell )
    1974             :     {
    1975           0 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    1976           0 :         sal_uInt16 nItemWhich = 0;
    1977           0 :         const SfxItemPropertySimpleEntry* pEntry  = rPropertyMap.getByName( aPropertyName );
    1978           0 :         lcl_GetPropertyWhich( pEntry, nItemWhich );
    1979           0 :         if ( nItemWhich )               // item wid (from map or special case)
    1980             :         {
    1981           0 :             if ( !aRanges.empty() )     // leer = nichts zu tun
    1982             :             {
    1983             :                 //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
    1984             :                 //! wird hier zuviel zurueckgesetzt
    1985             :                 //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
    1986             : 
    1987             :                 sal_uInt16 aWIDs[3];
    1988           0 :                 aWIDs[0] = nItemWhich;
    1989           0 :                 if ( nItemWhich == ATTR_VALUE_FORMAT )
    1990             :                 {
    1991           0 :                     aWIDs[1] = ATTR_LANGUAGE_FORMAT; // language for number formats
    1992           0 :                     aWIDs[2] = 0;
    1993             :                 }
    1994             :                 else
    1995           0 :                     aWIDs[1] = 0;
    1996           0 :                 pDocShell->GetDocFunc().ClearItems( *GetMarkData(), aWIDs, true );
    1997             :             }
    1998             :         }
    1999           0 :         else if ( pEntry )
    2000             :         {
    2001           0 :             if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
    2002           0 :                 bChartColAsHdr = false;
    2003           0 :             else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
    2004           0 :                 bChartRowAsHdr = false;
    2005           0 :             else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    2006             :             {
    2007           0 :                 OUString aStyleName( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ) );
    2008           0 :                 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aStyleName, true, true );
    2009             :             }
    2010             :         }
    2011           0 :     }
    2012           0 : }
    2013             : 
    2014           0 : uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropertyName )
    2015             :                                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
    2016             :                                         uno::RuntimeException, std::exception)
    2017             : {
    2018             :     //! mit getPropertyValue zusammenfassen
    2019             : 
    2020           0 :     SolarMutexGuard aGuard;
    2021           0 :     uno::Any aAny;
    2022             : 
    2023           0 :     if ( pDocShell )
    2024             :     {
    2025           0 :         ScDocument& rDoc = pDocShell->GetDocument();
    2026           0 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2027           0 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
    2028           0 :         if ( pEntry )
    2029             :         {
    2030           0 :             if ( IsScItemWid( pEntry->nWID ) )
    2031             :             {
    2032           0 :                 const ScPatternAttr* pPattern = rDoc.GetDefPattern();
    2033           0 :                 if ( pPattern )
    2034             :                 {
    2035           0 :                     const SfxItemSet& rSet = pPattern->GetItemSet();
    2036             : 
    2037           0 :                     switch ( pEntry->nWID )     // fuer Item-Spezial-Behandlungen
    2038             :                     {
    2039             :                         case ATTR_VALUE_FORMAT:
    2040             :                             //  default has no language set
    2041           0 :                             aAny <<= (sal_Int32)( static_cast<const SfxUInt32Item&>(rSet.Get(pEntry->nWID)).GetValue() );
    2042           0 :                             break;
    2043             :                         case ATTR_INDENT:
    2044           0 :                             aAny <<= (sal_Int16)( TwipsToHMM(static_cast<const SfxUInt16Item&>(
    2045           0 :                                             rSet.Get(pEntry->nWID)).GetValue()) );
    2046           0 :                             break;
    2047             :                         default:
    2048           0 :                             pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
    2049             :                     }
    2050             :                 }
    2051             :             }
    2052             :             else
    2053           0 :                 switch ( pEntry->nWID )
    2054             :                 {
    2055             :                     case SC_WID_UNO_CHCOLHDR:
    2056             :                     case SC_WID_UNO_CHROWHDR:
    2057           0 :                         ScUnoHelpFunctions::SetBoolInAny( aAny, false );
    2058           0 :                         break;
    2059             :                     case SC_WID_UNO_CELLSTYL:
    2060           0 :                         aAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
    2061           0 :                                     ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
    2062           0 :                         break;
    2063             :                     case SC_WID_UNO_TBLBORD:
    2064             :                     case SC_WID_UNO_TBLBORD2:
    2065             :                         {
    2066           0 :                             const ScPatternAttr* pPattern = rDoc.GetDefPattern();
    2067           0 :                             if ( pPattern )
    2068             :                             {
    2069           0 :                                 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
    2070             :                                     ScHelperFunctions::AssignTableBorder2ToAny( aAny,
    2071           0 :                                             static_cast<const SvxBoxItem&>(pPattern->GetItem(ATTR_BORDER)),
    2072           0 :                                             static_cast<const SvxBoxInfoItem&>(pPattern->GetItem(ATTR_BORDER_INNER)) );
    2073             :                                 else
    2074             :                                     ScHelperFunctions::AssignTableBorderToAny( aAny,
    2075           0 :                                             static_cast<const SvxBoxItem&>(pPattern->GetItem(ATTR_BORDER)),
    2076           0 :                                             static_cast<const SvxBoxInfoItem&>(pPattern->GetItem(ATTR_BORDER_INNER)) );
    2077             :                             }
    2078             :                         }
    2079           0 :                         break;
    2080             :                     case SC_WID_UNO_CONDFMT:
    2081             :                     case SC_WID_UNO_CONDLOC:
    2082             :                     case SC_WID_UNO_CONDXML:
    2083             :                         {
    2084           0 :                             bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
    2085           0 :                             bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
    2086             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2087             :                                     rDoc.GetStorageGrammar() :
    2088           0 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2089             : 
    2090           0 :                             aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
    2091           0 :                                     new ScTableConditionalFormat( &rDoc, 0, aRanges[0]->aStart.Tab(), eGrammar ));
    2092             :                         }
    2093           0 :                         break;
    2094             :                     case SC_WID_UNO_VALIDAT:
    2095             :                     case SC_WID_UNO_VALILOC:
    2096             :                     case SC_WID_UNO_VALIXML:
    2097             :                         {
    2098           0 :                             bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
    2099           0 :                             bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
    2100             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2101             :                                     rDoc.GetStorageGrammar() :
    2102           0 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2103             : 
    2104           0 :                             aAny <<= uno::Reference<beans::XPropertySet>(
    2105           0 :                                     new ScTableValidationObj( &rDoc, 0, eGrammar ));
    2106             :                         }
    2107           0 :                         break;
    2108             :                     case SC_WID_UNO_NUMRULES:
    2109             :                         {
    2110           0 :                             aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
    2111             :                         }
    2112           0 :                         break;
    2113             :                 }
    2114             :         }
    2115             :     }
    2116             : 
    2117           0 :     return aAny;
    2118             : }
    2119             : 
    2120             : // XPropertySet
    2121             : 
    2122         494 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
    2123             :                                                         throw(uno::RuntimeException, std::exception)
    2124             : {
    2125         494 :     SolarMutexGuard aGuard;
    2126             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    2127         494 :         new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
    2128         494 :     return aRef;
    2129             : }
    2130             : 
    2131       28086 : static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
    2132             :                             ScPatternAttr& rPattern, ScDocument &rDoc,
    2133             :                             sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId )
    2134             : {
    2135       28086 :     rFirstItemId = rEntry.nWID;
    2136       28086 :     rSecondItemId = 0;
    2137             : 
    2138       28086 :     SfxItemSet& rSet = rPattern.GetItemSet();
    2139       28086 :     switch ( rEntry.nWID )
    2140             :     {
    2141             :         case ATTR_VALUE_FORMAT:
    2142             :             {
    2143             :                 // language for number formats
    2144         740 :                 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
    2145         740 :                 sal_uLong nOldFormat = static_cast<const SfxUInt32Item&>(rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
    2146         740 :                 LanguageType eOldLang = static_cast<const SvxLanguageItem&>(rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
    2147         740 :                 nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
    2148             : 
    2149         740 :                 sal_Int32 nIntVal = 0;
    2150         740 :                 if ( rValue >>= nIntVal )
    2151             :                 {
    2152         740 :                     sal_uLong nNewFormat = (sal_uLong)nIntVal;
    2153         740 :                     rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
    2154             : 
    2155         740 :                     const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
    2156             :                     LanguageType eNewLang =
    2157         740 :                         pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
    2158         740 :                     if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
    2159             :                     {
    2160          28 :                         rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
    2161             : 
    2162             :                         // if only language is changed,
    2163             :                         // don't touch number format attribute
    2164          28 :                         sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
    2165          28 :                         if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
    2166             :                              nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
    2167             :                         {
    2168           0 :                             rFirstItemId = 0;       // don't use ATTR_VALUE_FORMAT value
    2169             :                         }
    2170             : 
    2171          28 :                         rSecondItemId = ATTR_LANGUAGE_FORMAT;
    2172             :                     }
    2173             :                 }
    2174             :                 else
    2175           0 :                     throw lang::IllegalArgumentException();
    2176             :             }
    2177         740 :             break;
    2178             :         case ATTR_INDENT:
    2179             :             {
    2180         252 :                 sal_Int16 nIntVal = 0;
    2181         252 :                 if ( rValue >>= nIntVal )
    2182         252 :                     rSet.Put( SfxUInt16Item( rEntry.nWID, (sal_uInt16)HMMToTwips(nIntVal) ) );
    2183             :                 else
    2184           0 :                     throw lang::IllegalArgumentException();
    2185             :             }
    2186         252 :             break;
    2187             :         case ATTR_ROTATE_VALUE:
    2188             :             {
    2189          52 :                 sal_Int32 nRotVal = 0;
    2190          52 :                 if ( rValue >>= nRotVal )
    2191             :                 {
    2192             :                     //  stored value is always between 0 and 360 deg.
    2193          52 :                     nRotVal %= 36000;
    2194          52 :                     if ( nRotVal < 0 )
    2195           0 :                         nRotVal += 36000;
    2196             : 
    2197          52 :                     rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
    2198             :                 }
    2199             :                 else
    2200           0 :                     throw lang::IllegalArgumentException();
    2201             :             }
    2202          52 :             break;
    2203             :         case ATTR_STACKED:
    2204             :             {
    2205             :                 table::CellOrientation eOrient;
    2206          60 :                 if( rValue >>= eOrient )
    2207             :                 {
    2208          60 :                     switch( eOrient )
    2209             :                     {
    2210             :                         case table::CellOrientation_STANDARD:
    2211          46 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
    2212          46 :                         break;
    2213             :                         case table::CellOrientation_TOPBOTTOM:
    2214          10 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
    2215          10 :                             rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
    2216          10 :                             rSecondItemId = ATTR_ROTATE_VALUE;
    2217          10 :                         break;
    2218             :                         case table::CellOrientation_BOTTOMTOP:
    2219           2 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
    2220           2 :                             rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
    2221           2 :                             rSecondItemId = ATTR_ROTATE_VALUE;
    2222           2 :                         break;
    2223             :                         case table::CellOrientation_STACKED:
    2224           2 :                             rSet.Put( SfxBoolItem( ATTR_STACKED, true ) );
    2225           2 :                         break;
    2226             :                         default:
    2227             :                         {
    2228             :                             // added to avoid warnings
    2229             :                         }
    2230             :                     }
    2231             :                 }
    2232             :             }
    2233          60 :             break;
    2234             :         default:
    2235             :             {
    2236       26982 :                 lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
    2237             :             }
    2238             :     }
    2239       27960 : }
    2240             : 
    2241        3482 : void SAL_CALL ScCellRangesBase::setPropertyValue(
    2242             :                         const OUString& aPropertyName, const uno::Any& aValue )
    2243             :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
    2244             :                         lang::IllegalArgumentException, lang::WrappedTargetException,
    2245             :                         uno::RuntimeException, std::exception)
    2246             : {
    2247        3482 :     SolarMutexGuard aGuard;
    2248             : 
    2249        3482 :     if ( !pDocShell || aRanges.empty() )
    2250           0 :         throw uno::RuntimeException();
    2251             : 
    2252        3482 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2253        3482 :     const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
    2254        3482 :     if ( !pEntry )
    2255           0 :         throw beans::UnknownPropertyException();
    2256             : 
    2257        3524 :     SetOnePropertyValue( pEntry, aValue );
    2258        3440 : }
    2259             : 
    2260        4410 : void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    2261             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    2262             : {
    2263        4410 :     if ( pEntry )
    2264             :     {
    2265        4410 :         if ( IsScItemWid( pEntry->nWID ) )
    2266             :         {
    2267        1684 :             if ( !aRanges.empty() )     // leer = nichts zu tun
    2268             :             {
    2269        1684 :                 ScDocument& rDoc = pDocShell->GetDocument();
    2270             : 
    2271             :                 //  Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
    2272             :                 //  muss vorher das alte Item aus dem Dokument geholt werden
    2273             :                 //! Das kann hier aber nicht erkannt werden
    2274             :                 //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
    2275             :                 //! Item direkt von einzelner Position im Bereich holen?
    2276             :                 //  ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
    2277             : 
    2278        1684 :                 ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
    2279        1684 :                 SfxItemSet& rSet = aPattern.GetItemSet();
    2280        1684 :                 rSet.ClearInvalidItems();
    2281             : 
    2282             :                 sal_uInt16 nFirstItem, nSecondItem;
    2283        1684 :                 lcl_SetCellProperty( *pEntry, aValue, aPattern, rDoc, nFirstItem, nSecondItem );
    2284             : 
    2285       93594 :                 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
    2286       91952 :                     if ( nWhich != nFirstItem && nWhich != nSecondItem )
    2287       90288 :                         rSet.ClearItem(nWhich);
    2288             : 
    2289        1684 :                 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
    2290             :             }
    2291             :         }
    2292             :         else        // implemented here
    2293        2726 :             switch ( pEntry->nWID )
    2294             :             {
    2295             :                 case EE_CHAR_ESCAPEMENT:    // Specifically for xlsx import
    2296             :                 {
    2297           2 :                     sal_Int32 nValue = 0;
    2298           2 :                     aValue >>= nValue;
    2299           2 :                     if (nValue)
    2300             :                     {
    2301           0 :                         for (size_t i = 0, n = aRanges.size(); i < n; ++i)
    2302             :                         {
    2303           0 :                             ScRange aRange = *aRanges[i];
    2304             : 
    2305             :                             /* TODO: Iterate through the range */
    2306           0 :                             ScAddress aAddr = aRange.aStart;
    2307           0 :                             ScDocument& rDoc = pDocShell->GetDocument();
    2308           0 :                             ScRefCellValue aCell;
    2309           0 :                             aCell.assign(rDoc, aAddr);
    2310             : 
    2311           0 :                             OUString aStr = aCell.getString(&rDoc);
    2312           0 :                             EditEngine aEngine( rDoc.GetEnginePool() );
    2313           0 :                             aEngine.SetEditTextObjectPool(rDoc.GetEditPool());
    2314             : 
    2315             :                             /* EE_CHAR_ESCAPEMENT seems to be set on the cell _only_ when
    2316             :                              * there are no other attribs for the cell.
    2317             :                              * So, it is safe to overwrite the complete attribute set.
    2318             :                              * If there is a need - getting CellType and processing
    2319             :                              * the attributes could be considered.
    2320             :                              */
    2321           0 :                             SfxItemSet aAttr = aEngine.GetEmptyItemSet();
    2322           0 :                             aEngine.SetText(aStr);
    2323           0 :                             if( nValue < 0 )    // Subscript
    2324           0 :                                 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT ) );
    2325             :                             else                // Superscript
    2326           0 :                                 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT ) );
    2327           0 :                             aEngine.QuickSetAttribs(aAttr, ESelection(0, 0, 0, aStr.getLength()));
    2328             : 
    2329             :                             // The cell will own the text object instance.
    2330           0 :                             rDoc.SetEditText(aRanges[0]->aStart, aEngine.CreateTextObject());
    2331           0 :                         }
    2332             :                     }
    2333             :                 }
    2334           2 :                 break;
    2335             :                 case SC_WID_UNO_CHCOLHDR:
    2336             :                     // chart header flags are set for this object, not stored with document
    2337          12 :                     bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    2338          12 :                     break;
    2339             :                 case SC_WID_UNO_CHROWHDR:
    2340          12 :                     bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    2341          12 :                     break;
    2342             :                 case SC_WID_UNO_CELLSTYL:
    2343             :                     {
    2344        2604 :                         OUString aStrVal;
    2345        2604 :                         aValue >>= aStrVal;
    2346             :                         OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName(
    2347        5208 :                                                             aStrVal, SFX_STYLE_FAMILY_PARA ));
    2348        5208 :                         pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aString, true, true );
    2349             :                     }
    2350        2604 :                     break;
    2351             :                 case SC_WID_UNO_TBLBORD:
    2352             :                     {
    2353           8 :                         table::TableBorder aBorder;
    2354           8 :                         if ( !aRanges.empty() && ( aValue >>= aBorder ) )   // empty = nothing to do
    2355             :                         {
    2356           8 :                             SvxBoxItem aOuter(ATTR_BORDER);
    2357          16 :                             SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
    2358           8 :                             ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
    2359             : 
    2360          16 :                             ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner );   //! docfunc
    2361             :                         }
    2362             :                     }
    2363           8 :                     break;
    2364             :                 case SC_WID_UNO_TBLBORD2:
    2365             :                     {
    2366           4 :                         table::TableBorder2 aBorder2;
    2367           4 :                         if ( !aRanges.empty() && ( aValue >>= aBorder2 ) )   // empty = nothing to do
    2368             :                         {
    2369           0 :                             SvxBoxItem aOuter(ATTR_BORDER);
    2370           0 :                             SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
    2371           0 :                             ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 );
    2372             : 
    2373           0 :                             ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner );   //! docfunc
    2374             :                         }
    2375             :                     }
    2376           4 :                     break;
    2377             :                 case SC_WID_UNO_CONDFMT:
    2378             :                 case SC_WID_UNO_CONDLOC:
    2379             :                 case SC_WID_UNO_CONDXML:
    2380             :                     {
    2381          28 :                         uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
    2382          28 :                         if ( !aRanges.empty() && xInterface.is() )  // leer = nichts zu tun
    2383             :                         {
    2384             :                             ScTableConditionalFormat* pFormat =
    2385          16 :                                     ScTableConditionalFormat::getImplementation( xInterface );
    2386          16 :                             if (pFormat)
    2387             :                             {
    2388          16 :                                 ScDocument& rDoc = pDocShell->GetDocument();
    2389          16 :                                 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
    2390          16 :                                 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
    2391             :                                 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2392             :                                        formula::FormulaGrammar::GRAM_UNSPECIFIED :
    2393          16 :                                        formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2394             : 
    2395          16 :                                 ScConditionalFormat* pNew = new ScConditionalFormat( 0, &rDoc );    // Index wird beim Einfuegen gesetzt
    2396          16 :                                 pFormat->FillFormat( *pNew, &rDoc, eGrammar );
    2397          16 :                                 pNew->AddRange( aRanges );
    2398          16 :                                 SCTAB nTab = aRanges.front()->aStart.Tab();
    2399          16 :                                 pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
    2400             :                             }
    2401          28 :                         }
    2402             :                     }
    2403          28 :                     break;
    2404             :                 case SC_WID_UNO_VALIDAT:
    2405             :                 case SC_WID_UNO_VALILOC:
    2406             :                 case SC_WID_UNO_VALIXML:
    2407             :                     {
    2408          44 :                         uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
    2409          44 :                         if ( !aRanges.empty() && xInterface.is() )  // leer = nichts zu tun
    2410             :                         {
    2411             :                             ScTableValidationObj* pValidObj =
    2412          32 :                                     ScTableValidationObj::getImplementation( xInterface );
    2413          32 :                             if (pValidObj)
    2414             :                             {
    2415          32 :                                 ScDocument& rDoc = pDocShell->GetDocument();
    2416          32 :                                 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
    2417          32 :                                 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
    2418             :                                 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2419             :                                        formula::FormulaGrammar::GRAM_UNSPECIFIED :
    2420          32 :                                        formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2421             : 
    2422             :                                 boost::scoped_ptr<ScValidationData> pNewData(
    2423          32 :                                         pValidObj->CreateValidationData( &rDoc, eGrammar ));
    2424          32 :                                 sal_uLong nIndex = rDoc.AddValidationEntry( *pNewData );
    2425          32 :                                 pNewData.reset();
    2426             : 
    2427          64 :                                 ScPatternAttr aPattern( rDoc.GetPool() );
    2428          32 :                                 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
    2429          64 :                                 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
    2430             :                             }
    2431          44 :                         }
    2432             :                     }
    2433          44 :                     break;
    2434             :                 // SC_WID_UNO_NUMRULES is ignored...
    2435             :             }
    2436             :     }
    2437        4368 : }
    2438             : 
    2439       21598 : uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const OUString& aPropertyName )
    2440             :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
    2441             :                         uno::RuntimeException, std::exception)
    2442             : {
    2443       21598 :     SolarMutexGuard aGuard;
    2444             : 
    2445       21598 :     if ( !pDocShell || aRanges.empty() )
    2446           0 :         throw uno::RuntimeException();
    2447             : 
    2448       21598 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2449       21598 :     const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
    2450       21598 :     if ( !pEntry )
    2451           8 :         throw beans::UnknownPropertyException();
    2452             : 
    2453       21590 :     uno::Any aAny;
    2454       21590 :     GetOnePropertyValue( pEntry, aAny );
    2455       21598 :     return aAny;
    2456             : }
    2457             : 
    2458       19360 : void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    2459             :     throw(uno::RuntimeException, std::exception)
    2460             : {
    2461       19360 :     if ( pEntry )
    2462             :     {
    2463       19360 :         if ( IsScItemWid( pEntry->nWID ) )
    2464             :         {
    2465       18614 :             SfxItemSet* pDataSet = GetCurrentDataSet();
    2466       18614 :             if ( pDataSet )
    2467             :             {
    2468       18614 :                 switch ( pEntry->nWID )     // fuer Item-Spezial-Behandlungen
    2469             :                 {
    2470             :                     case ATTR_VALUE_FORMAT:
    2471             :                         {
    2472       14712 :                             ScDocument& rDoc = pDocShell->GetDocument();
    2473             : 
    2474             :                             sal_uLong nOldFormat = static_cast<const SfxUInt32Item&>(
    2475       14712 :                                     pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
    2476             :                             LanguageType eOldLang = static_cast<const SvxLanguageItem&>(
    2477       14712 :                                     pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
    2478             :                             nOldFormat = rDoc.GetFormatTable()->
    2479       14712 :                                     GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
    2480       14712 :                             rAny <<= (sal_Int32)( nOldFormat );
    2481             :                         }
    2482       14712 :                         break;
    2483             :                     case ATTR_INDENT:
    2484         196 :                         rAny <<= (sal_Int16)( TwipsToHMM(static_cast<const SfxUInt16Item&>(
    2485         196 :                                         pDataSet->Get(pEntry->nWID)).GetValue()) );
    2486          98 :                         break;
    2487             :                     case ATTR_STACKED:
    2488             :                         {
    2489         116 :                             sal_Int32 nRot = static_cast<const SfxInt32Item&>(pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
    2490         116 :                             bool bStacked = static_cast<const SfxBoolItem&>(pDataSet->Get(pEntry->nWID)).GetValue();
    2491         116 :                             SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
    2492             :                         }
    2493         116 :                         break;
    2494             :                     default:
    2495        3688 :                         pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
    2496             :                 }
    2497             :             }
    2498             :         }
    2499             :         else        // implemented here
    2500         746 :             switch ( pEntry->nWID )
    2501             :             {
    2502             :                 case SC_WID_UNO_CHCOLHDR:
    2503          44 :                     ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
    2504          44 :                     break;
    2505             :                 case SC_WID_UNO_CHROWHDR:
    2506          44 :                     ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
    2507          44 :                     break;
    2508             :                 case SC_WID_UNO_CELLSTYL:
    2509             :                     {
    2510         194 :                         OUString aStyleName;
    2511         194 :                         const ScStyleSheet* pStyle = pDocShell->GetDocument().GetSelectionStyle(*GetMarkData());
    2512         194 :                         if (pStyle)
    2513         194 :                             aStyleName = pStyle->GetName();
    2514         388 :                         rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
    2515         388 :                                                                 aStyleName, SFX_STYLE_FAMILY_PARA ) );
    2516             :                     }
    2517         194 :                     break;
    2518             :                 case SC_WID_UNO_TBLBORD:
    2519             :                 case SC_WID_UNO_TBLBORD2:
    2520             :                     {
    2521             :                         //! loop throgh all ranges
    2522          80 :                         if ( !aRanges.empty() )
    2523             :                         {
    2524          80 :                             const ScRange* pFirst = aRanges[ 0 ];
    2525          80 :                             SvxBoxItem aOuter(ATTR_BORDER);
    2526         160 :                             SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
    2527             : 
    2528          80 :                             ScDocument& rDoc = pDocShell->GetDocument();
    2529         160 :                             ScMarkData aMark;
    2530          80 :                             aMark.SetMarkArea( *pFirst );
    2531          80 :                             aMark.SelectTable( pFirst->aStart.Tab(), true );
    2532          80 :                             rDoc.GetSelectionFrame( aMark, aOuter, aInner );
    2533             : 
    2534          80 :                             if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
    2535          28 :                                 ScHelperFunctions::AssignTableBorder2ToAny( rAny, aOuter, aInner);
    2536             :                             else
    2537         132 :                                 ScHelperFunctions::AssignTableBorderToAny( rAny, aOuter, aInner);
    2538             :                         }
    2539             :                     }
    2540          80 :                     break;
    2541             :                 case SC_WID_UNO_CONDFMT:
    2542             :                 case SC_WID_UNO_CONDLOC:
    2543             :                 case SC_WID_UNO_CONDXML:
    2544             :                     {
    2545         160 :                         const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
    2546         160 :                         if ( pPattern )
    2547             :                         {
    2548         160 :                             ScDocument& rDoc = pDocShell->GetDocument();
    2549         160 :                             bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
    2550         160 :                             bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
    2551             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2552             :                                     rDoc.GetStorageGrammar() :
    2553         160 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2554             :                             const std::vector<sal_uInt32>& rIndex = static_cast<const ScCondFormatItem&>(
    2555         160 :                                     pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
    2556         160 :                             sal_uLong nIndex = 0;
    2557         160 :                             if(!rIndex.empty())
    2558         104 :                                 nIndex = rIndex[0];
    2559         320 :                             rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
    2560         320 :                                     new ScTableConditionalFormat( &rDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar ));
    2561             :                         }
    2562             :                     }
    2563         160 :                     break;
    2564             :                 case SC_WID_UNO_VALIDAT:
    2565             :                 case SC_WID_UNO_VALILOC:
    2566             :                 case SC_WID_UNO_VALIXML:
    2567             :                     {
    2568         150 :                         const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
    2569         150 :                         if ( pPattern )
    2570             :                         {
    2571         150 :                             ScDocument& rDoc = pDocShell->GetDocument();
    2572         150 :                             bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
    2573         150 :                             bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
    2574             :                             formula::FormulaGrammar::Grammar eGrammar = (bXML ?
    2575             :                                     rDoc.GetStorageGrammar() :
    2576         150 :                                    formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
    2577             :                             sal_uLong nIndex = static_cast<const SfxUInt32Item&>(
    2578         150 :                                     pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
    2579         300 :                             rAny <<= uno::Reference<beans::XPropertySet>(
    2580         300 :                                     new ScTableValidationObj( &rDoc, nIndex, eGrammar ));
    2581             :                         }
    2582             :                     }
    2583         150 :                     break;
    2584             :                 case SC_WID_UNO_NUMRULES:
    2585             :                     {
    2586             :                         // always return empty numbering rules object
    2587          28 :                         rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
    2588             :                     }
    2589          28 :                     break;
    2590             :                 case SC_WID_UNO_ABSNAME:
    2591             :                     {
    2592          30 :                         OUString sRet;
    2593          30 :                         aRanges.Format(sRet, SCR_ABS_3D, &pDocShell->GetDocument());
    2594          30 :                         rAny <<= sRet;
    2595             :                     }
    2596             :             }
    2597             :     }
    2598       19360 : }
    2599             : 
    2600           0 : void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const OUString& /* aPropertyName */,
    2601             :                             const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
    2602             :                             throw(beans::UnknownPropertyException,
    2603             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2604             : {
    2605           0 :     SolarMutexGuard aGuard;
    2606           0 :     if ( aRanges.empty() )
    2607           0 :         throw uno::RuntimeException();
    2608             : 
    2609           0 :     OSL_FAIL("not implemented");
    2610           0 : }
    2611             : 
    2612           0 : void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const OUString& /* aPropertyName */,
    2613             :                             const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
    2614             :                             throw(beans::UnknownPropertyException,
    2615             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2616             : {
    2617           0 :     SolarMutexGuard aGuard;
    2618           0 :     if ( aRanges.empty() )
    2619           0 :         throw uno::RuntimeException();
    2620             : 
    2621           0 :     OSL_FAIL("not implemented");
    2622           0 : }
    2623             : 
    2624           0 : void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const OUString&,
    2625             :                             const uno::Reference<beans::XVetoableChangeListener>&)
    2626             :                             throw(beans::UnknownPropertyException,
    2627             :                                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2628             : {
    2629             :     OSL_FAIL("not implemented");
    2630           0 : }
    2631             : 
    2632           0 : void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const OUString&,
    2633             :                             const uno::Reference<beans::XVetoableChangeListener>&)
    2634             :                             throw(beans::UnknownPropertyException,
    2635             :                                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2636             : {
    2637             :     OSL_FAIL("not implemented");
    2638           0 : }
    2639             : 
    2640             : // XMultiPropertySet
    2641             : 
    2642         102 : void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames,
    2643             :                                     const uno::Sequence< uno::Any >& aValues )
    2644             :                                 throw (beans::PropertyVetoException,
    2645             :                                     lang::IllegalArgumentException,
    2646             :                                     lang::WrappedTargetException,
    2647             :                                     uno::RuntimeException, std::exception)
    2648             : {
    2649         102 :     SolarMutexGuard aGuard;
    2650             : 
    2651         102 :     sal_Int32 nCount(aPropertyNames.getLength());
    2652         102 :     sal_Int32 nValues(aValues.getLength());
    2653         102 :     if (nCount != nValues)
    2654           0 :         throw lang::IllegalArgumentException();
    2655             : 
    2656         102 :     if ( pDocShell && nCount )
    2657             :     {
    2658         102 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();      // from derived class
    2659         102 :         const OUString* pNames = aPropertyNames.getConstArray();
    2660         102 :         const uno::Any* pValues = aValues.getConstArray();
    2661             : 
    2662         102 :         boost::scoped_array<const SfxItemPropertySimpleEntry*> pEntryArray(new const SfxItemPropertySimpleEntry*[nCount]);
    2663             : 
    2664             :         sal_Int32 i;
    2665        1328 :         for(i = 0; i < nCount; i++)
    2666             :         {
    2667             :             // first loop: find all properties in map, but handle only CellStyle
    2668             :             // (CellStyle must be set before any other cell properties)
    2669             : 
    2670        1226 :             const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
    2671        1226 :             pEntryArray[i] = pEntry;
    2672        1226 :             if (pEntry)
    2673             :             {
    2674        1226 :                 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    2675             :                 {
    2676             :                     try
    2677             :                     {
    2678         100 :                         SetOnePropertyValue( pEntry, pValues[i] );
    2679             :                     }
    2680           0 :                     catch ( lang::IllegalArgumentException& )
    2681             :                     {
    2682             :                         OSL_FAIL("exception when setting cell style");     // not supposed to happen
    2683             :                     }
    2684             :                 }
    2685             :             }
    2686             :         }
    2687             : 
    2688         102 :         ScDocument& rDoc = pDocShell->GetDocument();
    2689         204 :         boost::scoped_ptr<ScPatternAttr> pOldPattern;
    2690         204 :         boost::scoped_ptr<ScPatternAttr> pNewPattern;
    2691             : 
    2692        1068 :         for(i = 0; i < nCount; i++)
    2693             :         {
    2694             :             // second loop: handle other properties
    2695             : 
    2696        1006 :             const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
    2697        1006 :             if ( pEntry )
    2698             :             {
    2699        1006 :                 if ( IsScItemWid( pEntry->nWID ) )  // can be handled by SfxItemPropertySet
    2700             :                 {
    2701         906 :                     if ( !pOldPattern )
    2702             :                     {
    2703         102 :                         pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
    2704         102 :                         pOldPattern->GetItemSet().ClearInvalidItems();
    2705         102 :                         pNewPattern.reset(new ScPatternAttr( rDoc.GetPool() ));
    2706             :                     }
    2707             : 
    2708             :                     //  collect items in pNewPattern, apply with one call after the loop
    2709             : 
    2710             :                     sal_uInt16 nFirstItem, nSecondItem;
    2711         906 :                     lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, rDoc, nFirstItem, nSecondItem );
    2712             : 
    2713             :                     //  put only affected items into new set
    2714         866 :                     if ( nFirstItem )
    2715         866 :                         pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
    2716         866 :                     if ( nSecondItem )
    2717           0 :                         pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
    2718             :                 }
    2719         100 :                 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL )   // CellStyle is handled above
    2720             :                 {
    2721             :                     //  call virtual method to set a single property
    2722           0 :                     SetOnePropertyValue( pEntry, pValues[i] );
    2723             :                 }
    2724             :             }
    2725             :         }
    2726             : 
    2727          62 :         if ( pNewPattern && !aRanges.empty() )
    2728         164 :             pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
    2729         102 :     }
    2730          62 : }
    2731             : 
    2732           0 : uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
    2733             :                                 const uno::Sequence< OUString >& aPropertyNames )
    2734             :                                     throw (uno::RuntimeException, std::exception)
    2735             : {
    2736           0 :     SolarMutexGuard aGuard;
    2737             : 
    2738           0 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2739             : 
    2740           0 :     uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
    2741           0 :     uno::Any* pProperties = aRet.getArray();
    2742           0 :     for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
    2743             :     {
    2744           0 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
    2745           0 :         GetOnePropertyValue( pEntry, pProperties[i] );
    2746             :     }
    2747           0 :     return aRet;
    2748             : }
    2749             : 
    2750           0 : void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */,
    2751             :                                     const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
    2752             :                                 throw (uno::RuntimeException, std::exception)
    2753             : {
    2754             :     OSL_FAIL("not implemented");
    2755           0 : }
    2756             : 
    2757           0 : void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
    2758             :                                 throw (uno::RuntimeException, std::exception)
    2759             : {
    2760             :     OSL_FAIL("not implemented");
    2761           0 : }
    2762             : 
    2763           0 : void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */,
    2764             :                                     const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
    2765             :                                 throw (uno::RuntimeException, std::exception)
    2766             : {
    2767             :     OSL_FAIL("not implemented");
    2768           0 : }
    2769             : 
    2770          16 : IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
    2771             : {
    2772          16 :     if ( pDocShell && pHint && dynamic_cast<const SfxSimpleHint*>(pHint) &&
    2773           8 :             (static_cast<const SfxSimpleHint*>(pHint)->GetId() & SC_HINT_DATACHANGED))
    2774             :     {
    2775             :         //  This may be called several times for a single change, if several formulas
    2776             :         //  in the range are notified. So only a flag is set that is checked when
    2777             :         //  SFX_HINT_DATACHANGED is received.
    2778             : 
    2779           0 :         bGotDataChangedHint = true;
    2780             :     }
    2781           8 :     return 0;
    2782             : }
    2783             : 
    2784             : // XTolerantMultiPropertySet
    2785        2304 : uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames,
    2786             :                                     const uno::Sequence< uno::Any >& aValues )
    2787             :                                     throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    2788             : {
    2789        2304 :     SolarMutexGuard aGuard;
    2790             : 
    2791        2304 :     sal_Int32 nCount(aPropertyNames.getLength());
    2792        2304 :     sal_Int32 nValues(aValues.getLength());
    2793        2304 :     if (nCount != nValues)
    2794           0 :         throw lang::IllegalArgumentException();
    2795             : 
    2796        2304 :     if ( pDocShell && nCount )
    2797             :     {
    2798        2304 :         uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
    2799        2304 :         beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
    2800             : 
    2801        2304 :         const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2802        2304 :         const OUString* pNames = aPropertyNames.getConstArray();
    2803        2304 :         const uno::Any* pValues = aValues.getConstArray();
    2804             : 
    2805        4608 :         boost::scoped_array<const SfxItemPropertySimpleEntry*> pMapArray(new const SfxItemPropertySimpleEntry*[nCount]);
    2806             : 
    2807             :         sal_Int32 i;
    2808       31352 :         for(i = 0; i < nCount; i++)
    2809             :         {
    2810             :             // first loop: find all properties in map, but handle only CellStyle
    2811             :             // (CellStyle must be set before any other cell properties)
    2812             : 
    2813       29048 :             const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
    2814       29048 :             pMapArray[i] = pEntry;
    2815       29048 :             if (pEntry)
    2816             :             {
    2817       28928 :                 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
    2818             :                 {
    2819             :                     try
    2820             :                     {
    2821        1726 :                         SetOnePropertyValue( pEntry, pValues[i] );
    2822             :                     }
    2823           0 :                     catch ( lang::IllegalArgumentException& )
    2824             :                     {
    2825             :                         OSL_FAIL("exception when setting cell style");     // not supposed to happen
    2826             :                     }
    2827             :                 }
    2828             :             }
    2829             :         }
    2830             : 
    2831        2304 :         ScDocument& rDoc = pDocShell->GetDocument();
    2832        4608 :         boost::scoped_ptr<ScPatternAttr> pOldPattern;
    2833        4608 :         boost::scoped_ptr<ScPatternAttr> pNewPattern;
    2834             : 
    2835        2304 :         sal_Int32 nFailed(0);
    2836       31352 :         for(i = 0; i < nCount; i++)
    2837             :         {
    2838             :             // second loop: handle other properties
    2839             : 
    2840       29048 :             const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
    2841       29048 :             if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
    2842             :             {
    2843       28914 :                 if ( IsScItemWid( pEntry->nWID ) )  // can be handled by SfxItemPropertySet
    2844             :                 {
    2845       25496 :                     if ( !pOldPattern )
    2846             :                     {
    2847        1600 :                         pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
    2848        1600 :                         pOldPattern->GetItemSet().ClearInvalidItems();
    2849        1600 :                         pNewPattern.reset(new ScPatternAttr( rDoc.GetPool() ));
    2850             :                     }
    2851             : 
    2852             :                     //  collect items in pNewPattern, apply with one call after the loop
    2853             : 
    2854             :                     sal_uInt16 nFirstItem, nSecondItem;
    2855             :                     try
    2856             :                     {
    2857       25496 :                         lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, rDoc, nFirstItem, nSecondItem );
    2858             : 
    2859             :                         //  put only affected items into new set
    2860       25452 :                         if ( nFirstItem )
    2861       25452 :                             pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
    2862       25452 :                         if ( nSecondItem )
    2863          18 :                             pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
    2864             :                     }
    2865          88 :                     catch ( lang::IllegalArgumentException& )
    2866             :                     {
    2867          44 :                         pReturns[nFailed].Name = pNames[i];
    2868          44 :                         pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
    2869             :                     }
    2870             :                 }
    2871        3418 :                 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL )   // CellStyle is handled above
    2872             :                 {
    2873             :                     //  call virtual method to set a single property
    2874             :                     try
    2875             :                     {
    2876        1692 :                         SetOnePropertyValue( pEntry, pValues[i] );
    2877             :                     }
    2878           0 :                     catch ( lang::IllegalArgumentException& )
    2879             :                     {
    2880           0 :                         pReturns[nFailed].Name = pNames[i];
    2881           0 :                         pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
    2882             :                     }
    2883       28914 :                 }
    2884             :             }
    2885             :             else
    2886             :             {
    2887         134 :                 pReturns[nFailed].Name = pNames[i];
    2888         134 :                 if (pEntry)
    2889          14 :                     pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
    2890             :                 else
    2891         120 :                     pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
    2892             :             }
    2893             :         }
    2894             : 
    2895        2304 :         if ( pNewPattern && !aRanges.empty() )
    2896        1600 :             pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
    2897             : 
    2898        2304 :         aReturns.realloc(nFailed);
    2899             : 
    2900        4608 :         return aReturns;
    2901             :     }
    2902           0 :     return uno::Sequence < beans::SetPropertyTolerantFailed >();
    2903             : }
    2904             : 
    2905          22 : uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
    2906             :                                     throw (uno::RuntimeException, std::exception)
    2907             : {
    2908          22 :     SolarMutexGuard aGuard;
    2909             : 
    2910          22 :     sal_Int32 nCount(aPropertyNames.getLength());
    2911          22 :     uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
    2912          22 :     beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
    2913             : 
    2914          22 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2915             : 
    2916        2204 :     for(sal_Int32 i = 0; i < nCount; i++)
    2917             :     {
    2918        2182 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
    2919        2182 :         if (!pEntry)
    2920             :         {
    2921           0 :             pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
    2922             :         }
    2923             :         else
    2924             :         {
    2925        2182 :             sal_uInt16 nItemWhich = 0;
    2926        2182 :             lcl_GetPropertyWhich( pEntry, nItemWhich );
    2927        2182 :             pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
    2928        2182 :             GetOnePropertyValue( pEntry, pReturns[i].Value );
    2929        2182 :             pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
    2930             :         }
    2931             :     }
    2932          22 :     return aReturns;
    2933             : }
    2934             : 
    2935         400 : uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
    2936             :                                     throw (uno::RuntimeException, std::exception)
    2937             : {
    2938         400 :     SolarMutexGuard aGuard;
    2939             : 
    2940         400 :     sal_Int32 nCount(aPropertyNames.getLength());
    2941         400 :     uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
    2942         400 :     beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
    2943             : 
    2944         400 :     const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap();     // from derived class
    2945             : 
    2946         400 :     sal_Int32 j = 0;
    2947       13740 :     for(sal_Int32 i = 0; i < nCount; i++)
    2948             :     {
    2949       13340 :         const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
    2950       13340 :         if (!pEntry)
    2951             :         {
    2952           0 :             pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
    2953             :         }
    2954             :         else
    2955             :         {
    2956       13340 :             sal_uInt16 nItemWhich = 0;
    2957       13340 :             lcl_GetPropertyWhich( pEntry, nItemWhich );
    2958       13340 :             pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
    2959       13340 :             if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
    2960             :             {
    2961        1130 :                 GetOnePropertyValue( pEntry, pReturns[j].Value );
    2962        1130 :                 pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
    2963        1130 :                 pReturns[j].Name = aPropertyNames[i];
    2964        1130 :                 ++j;
    2965             :             }
    2966             :         }
    2967             :     }
    2968         400 :     if (j < nCount)
    2969         160 :         aReturns.realloc(j);
    2970         400 :     return aReturns;
    2971             : }
    2972             : 
    2973             : // XIndent
    2974             : 
    2975           6 : void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
    2976             : {
    2977           6 :     SolarMutexGuard aGuard;
    2978           6 :     if ( pDocShell && !aRanges.empty() )        // leer = nichts zu tun
    2979             :     {
    2980             :         //#97041#; put only MultiMarked ScMarkData in ChangeIndent
    2981           6 :         ScMarkData aMarkData(*GetMarkData());
    2982           6 :         aMarkData.MarkToMulti();
    2983           6 :         pDocShell->GetDocFunc().ChangeIndent( aMarkData, false, true );
    2984           6 :     }
    2985           6 : }
    2986             : 
    2987           6 : void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
    2988             : {
    2989           6 :     SolarMutexGuard aGuard;
    2990           6 :     if ( pDocShell && !aRanges.empty() )        // leer = nichts zu tun
    2991             :     {
    2992             :         //#97041#; put only MultiMarked ScMarkData in ChangeIndent
    2993           6 :         ScMarkData aMarkData(*GetMarkData());
    2994           6 :         aMarkData.MarkToMulti();
    2995           6 :         pDocShell->GetDocFunc().ChangeIndent( aMarkData, true, true );
    2996           6 :     }
    2997           6 : }
    2998             : 
    2999             : // XChartData
    3000             : 
    3001          36 : ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
    3002             : {
    3003          36 :     if ( pDocShell && !aRanges.empty() )
    3004             :     {
    3005          36 :         ScRangeListRef xChartRanges;
    3006          36 :         if ( aRanges.size() == 1 )
    3007             :         {
    3008             :             //  ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
    3009             :             //  (nur hier, Listener werden auf den ganzen Bereich angemeldet)
    3010             :             //! direkt testen, ob es ein ScTableSheetObj ist?
    3011             : 
    3012          16 :             const ScRange* pRange = aRanges[0];
    3013          48 :             if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
    3014          16 :                  pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
    3015             :             {
    3016           0 :                 SCTAB nTab = pRange->aStart.Tab();
    3017             : 
    3018             :                 SCCOL nStartX;
    3019             :                 SCROW nStartY; // Anfang holen
    3020           0 :                 if (!pDocShell->GetDocument().GetDataStart( nTab, nStartX, nStartY ))
    3021             :                 {
    3022           0 :                     nStartX = 0;
    3023           0 :                     nStartY = 0;
    3024             :                 }
    3025             : 
    3026             :                 SCCOL nEndX;
    3027             :                 SCROW nEndY; // Ende holen
    3028           0 :                 if (!pDocShell->GetDocument().GetTableArea( nTab, nEndX, nEndY ))
    3029             :                 {
    3030           0 :                     nEndX = 0;
    3031           0 :                     nEndY = 0;
    3032             :                 }
    3033             : 
    3034           0 :                 xChartRanges = new ScRangeList;
    3035           0 :                 xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
    3036             :             }
    3037             :         }
    3038          36 :         if (!xChartRanges.Is())         //  sonst Ranges direkt uebernehmen
    3039          36 :             xChartRanges = new ScRangeList(aRanges);
    3040          72 :         ScChartArray aArr( &pDocShell->GetDocument(), xChartRanges, OUString() );
    3041             : 
    3042             :         // RowAsHdr = ColHeaders und umgekehrt
    3043          36 :         aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
    3044             : 
    3045          72 :         return aArr.CreateMemChart();
    3046             :     }
    3047           0 :     return NULL;
    3048             : }
    3049             : 
    3050          12 : uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
    3051             :     throw(uno::RuntimeException, std::exception)
    3052             : {
    3053          12 :     SolarMutexGuard aGuard;
    3054          24 :     boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
    3055          12 :     if ( pMemChart )
    3056             :     {
    3057          12 :         sal_Int32 nColCount = pMemChart->GetColCount();
    3058          12 :         sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
    3059             : 
    3060          12 :         uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
    3061          12 :         uno::Sequence<double>* pRowAry = aRowSeq.getArray();
    3062         120 :         for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
    3063             :         {
    3064         108 :             uno::Sequence<double> aColSeq( nColCount );
    3065         108 :             double* pColAry = aColSeq.getArray();
    3066         296 :             for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
    3067         188 :                 pColAry[nCol] = pMemChart->GetData( nCol, nRow );
    3068             : 
    3069         108 :             pRowAry[nRow] = aColSeq;
    3070         108 :         }
    3071             : 
    3072          12 :         return aRowSeq;
    3073             :     }
    3074             : 
    3075          12 :     return uno::Sequence< uno::Sequence<double> >(0);
    3076             : }
    3077             : 
    3078          16 : ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
    3079             : {
    3080          16 :     if ( aRanges.size() == 1 )
    3081             :     {
    3082           6 :         const ScRange* pRange = aRanges[0];
    3083          18 :         if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
    3084           6 :              pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
    3085             :         {
    3086             :             //  if aRanges is a complete sheet, limit to given size
    3087             : 
    3088           0 :             SCTAB nTab = pRange->aStart.Tab();
    3089             : 
    3090           0 :             long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
    3091           0 :             if ( nEndColumn < 0 )
    3092           0 :                 nEndColumn = 0;
    3093           0 :             if ( nEndColumn > MAXCOL )
    3094           0 :                 nEndColumn = MAXCOL;
    3095             : 
    3096           0 :             long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
    3097           0 :             if ( nEndRow < 0 )
    3098           0 :                 nEndRow = 0;
    3099           0 :             if ( nEndRow > MAXROW )
    3100           0 :                 nEndRow = MAXROW;
    3101             : 
    3102           0 :             ScRangeListRef xChartRanges = new ScRangeList;
    3103           0 :             xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
    3104           0 :             return xChartRanges;
    3105             :         }
    3106             :     }
    3107             : 
    3108          16 :     return new ScRangeList(aRanges);        // as-is
    3109             : }
    3110             : 
    3111           8 : void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
    3112             :                                                 throw(uno::RuntimeException, std::exception)
    3113             : {
    3114           8 :     SolarMutexGuard aGuard;
    3115           8 :     bool bDone = false;
    3116           8 :     long nRowCount = aData.getLength();
    3117           8 :     long nColCount = nRowCount ? aData[0].getLength() : 0;
    3118          16 :     ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
    3119           8 :     if ( pDocShell && xChartRanges.Is() )
    3120             :     {
    3121           8 :         ScDocument& rDoc = pDocShell->GetDocument();
    3122           8 :         ScChartArray aArr( &rDoc, xChartRanges, OUString() );
    3123           8 :         aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );      // RowAsHdr = ColHeaders
    3124           8 :         const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
    3125           8 :         if (pPosMap)
    3126             :         {
    3127          16 :             if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
    3128           8 :                  pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
    3129             :             {
    3130          86 :                 for (long nRow=0; nRow<nRowCount; nRow++)
    3131             :                 {
    3132          78 :                     const uno::Sequence<double>& rRowSeq = aData[nRow];
    3133          78 :                     const double* pArray = rRowSeq.getConstArray();
    3134          78 :                     nColCount = rRowSeq.getLength();
    3135         220 :                     for (long nCol=0; nCol<nColCount; nCol++)
    3136             :                     {
    3137             :                         const ScAddress* pPos = pPosMap->GetPosition(
    3138         142 :                                 sal::static_int_cast<SCCOL>(nCol),
    3139         284 :                                 sal::static_int_cast<SCROW>(nRow) );
    3140         142 :                         if (pPos)
    3141             :                         {
    3142         142 :                             double fVal = pArray[nCol];
    3143         142 :                             if ( fVal == DBL_MIN )
    3144          76 :                                 rDoc.SetEmptyCell(*pPos);
    3145             :                             else
    3146          66 :                                 rDoc.SetValue(*pPos, pArray[nCol]);
    3147             :                         }
    3148             :                     }
    3149             :                 }
    3150             : 
    3151             :                 //! undo
    3152           8 :                 PaintRanges_Impl( PAINT_GRID );
    3153           8 :                 pDocShell->SetDocumentModified();
    3154           8 :                 ForceChartListener_Impl();          // call listeners for this object synchronously
    3155           8 :                 bDone = true;
    3156             :             }
    3157           8 :         }
    3158             :     }
    3159             : 
    3160           8 :     if (!bDone)
    3161           8 :         throw uno::RuntimeException();
    3162           8 : }
    3163             : 
    3164          12 : uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
    3165             :     throw(uno::RuntimeException, std::exception)
    3166             : {
    3167          12 :     SolarMutexGuard aGuard;
    3168          24 :     boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
    3169          12 :     if ( pMemChart )
    3170             :     {
    3171          12 :         sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
    3172          12 :         uno::Sequence<OUString> aSeq( nRowCount );
    3173          12 :         OUString* pAry = aSeq.getArray();
    3174         102 :         for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
    3175          90 :             pAry[nRow] = pMemChart->GetRowText(nRow);
    3176             : 
    3177          12 :         return aSeq;
    3178             :     }
    3179          12 :     return uno::Sequence<OUString>(0);
    3180             : }
    3181             : 
    3182           4 : void SAL_CALL ScCellRangesBase::setRowDescriptions(
    3183             :                         const uno::Sequence<OUString>& aRowDescriptions )
    3184             :                                                 throw(uno::RuntimeException, std::exception)
    3185             : {
    3186           4 :     SolarMutexGuard aGuard;
    3187           4 :     bool bDone = false;
    3188           4 :     if ( bChartColAsHdr )
    3189             :     {
    3190           4 :         long nRowCount = aRowDescriptions.getLength();
    3191           4 :         ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
    3192           4 :         if ( pDocShell && xChartRanges.Is() )
    3193             :         {
    3194           4 :             ScDocument& rDoc = pDocShell->GetDocument();
    3195           4 :             ScChartArray aArr( &rDoc, xChartRanges, OUString() );
    3196           4 :             aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );      // RowAsHdr = ColHeaders
    3197           4 :             const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
    3198           4 :             if (pPosMap)
    3199             :             {
    3200           4 :                 if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
    3201             :                 {
    3202           4 :                     const OUString* pArray = aRowDescriptions.getConstArray();
    3203          34 :                     for (long nRow=0; nRow<nRowCount; nRow++)
    3204             :                     {
    3205             :                         const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
    3206          30 :                                 static_cast<SCSIZE>(nRow) );
    3207          30 :                         if (pPos)
    3208             :                         {
    3209          30 :                             const OUString& aStr = pArray[nRow];
    3210          30 :                             if (aStr.isEmpty())
    3211           0 :                                 rDoc.SetEmptyCell(*pPos);
    3212             :                             else
    3213             :                             {
    3214          30 :                                 ScSetStringParam aParam;
    3215          30 :                                 aParam.setTextInput();
    3216          30 :                                 rDoc.SetString(*pPos, aStr, &aParam);
    3217             :                             }
    3218             :                         }
    3219             :                     }
    3220             : 
    3221             :                     //! undo
    3222           4 :                     PaintRanges_Impl( PAINT_GRID );
    3223           4 :                     pDocShell->SetDocumentModified();
    3224           4 :                     ForceChartListener_Impl();          // call listeners for this object synchronously
    3225           4 :                     bDone = true;
    3226             :                 }
    3227           4 :             }
    3228           4 :         }
    3229             :     }
    3230             : 
    3231           4 :     if (!bDone)
    3232           0 :         throw uno::RuntimeException();
    3233           4 : }
    3234             : 
    3235          12 : uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
    3236             :     throw(uno::RuntimeException, std::exception)
    3237             : {
    3238          12 :     SolarMutexGuard aGuard;
    3239          24 :     boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
    3240          12 :     if ( pMemChart )
    3241             :     {
    3242          12 :         sal_Int32 nColCount = pMemChart->GetColCount();
    3243          12 :         uno::Sequence<OUString> aSeq( nColCount );
    3244          12 :         OUString* pAry = aSeq.getArray();
    3245          36 :         for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
    3246          24 :             pAry[nCol] = pMemChart->GetColText(nCol);
    3247             : 
    3248          12 :         return aSeq;
    3249             :     }
    3250          12 :     return uno::Sequence<OUString>(0);
    3251             : }
    3252             : 
    3253           4 : void SAL_CALL ScCellRangesBase::setColumnDescriptions(
    3254             :     const uno::Sequence<OUString>& aColumnDescriptions )
    3255             :         throw(uno::RuntimeException, std::exception)
    3256             : {
    3257           4 :     SolarMutexGuard aGuard;
    3258           4 :     bool bDone = false;
    3259           4 :     if ( bChartRowAsHdr )
    3260             :     {
    3261           4 :         long nColCount = aColumnDescriptions.getLength();
    3262           4 :         ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
    3263           4 :         if ( pDocShell && xChartRanges.Is() )
    3264             :         {
    3265           4 :             ScDocument& rDoc = pDocShell->GetDocument();
    3266           4 :             ScChartArray aArr( &rDoc, xChartRanges, OUString() );
    3267           4 :             aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );      // RowAsHdr = ColHeaders
    3268           4 :             const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
    3269           4 :             if (pPosMap)
    3270             :             {
    3271           4 :                 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
    3272             :                 {
    3273           4 :                     const OUString* pArray = aColumnDescriptions.getConstArray();
    3274          12 :                     for (long nCol=0; nCol<nColCount; nCol++)
    3275             :                     {
    3276             :                         const ScAddress* pPos = pPosMap->GetColHeaderPosition(
    3277           8 :                             sal::static_int_cast<SCCOL>(nCol) );
    3278           8 :                         if (pPos)
    3279             :                         {
    3280           8 :                             const OUString& aStr = pArray[nCol];
    3281           8 :                             if (aStr.isEmpty())
    3282           0 :                                 rDoc.SetEmptyCell(*pPos);
    3283             :                             else
    3284             :                             {
    3285           8 :                                 ScSetStringParam aParam;
    3286           8 :                                 aParam.setTextInput();
    3287           8 :                                 rDoc.SetString(*pPos, aStr, &aParam);
    3288             :                             }
    3289             :                         }
    3290             :                     }
    3291             : 
    3292             :                     //! undo
    3293           4 :                     PaintRanges_Impl( PAINT_GRID );
    3294           4 :                     pDocShell->SetDocumentModified();
    3295           4 :                     ForceChartListener_Impl();          // call listeners for this object synchronously
    3296           4 :                     bDone = true;
    3297             :                 }
    3298           4 :             }
    3299           4 :         }
    3300             :     }
    3301             : 
    3302           4 :     if (!bDone)
    3303           0 :         throw uno::RuntimeException();
    3304           4 : }
    3305             : 
    3306          16 : void ScCellRangesBase::ForceChartListener_Impl()
    3307             : {
    3308             :     //  call Update immediately so the caller to setData etc. can
    3309             :     //  regognize the listener call
    3310             : 
    3311          16 :     if (!pDocShell)
    3312           0 :         return;
    3313             : 
    3314          16 :     ScChartListenerCollection* pColl = pDocShell->GetDocument().GetChartListenerCollection();
    3315          16 :     if (!pColl)
    3316           0 :         return;
    3317             : 
    3318          16 :     ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
    3319          16 :     ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
    3320          22 :     for (; it != itEnd; ++it)
    3321             :     {
    3322           6 :         ScChartListener* p = it->second;
    3323             :         OSL_ASSERT(p);
    3324           6 :         if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty())
    3325           6 :             p->Update();
    3326             :     }
    3327             : }
    3328             : 
    3329           4 : void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
    3330             :                                     chart::XChartDataChangeEventListener >& aListener )
    3331             :                                 throw(uno::RuntimeException, std::exception)
    3332             : {
    3333           4 :     SolarMutexGuard aGuard;
    3334           4 :     if ( pDocShell && !aRanges.empty() )
    3335             :     {
    3336             :         //! auf doppelte testen?
    3337             : 
    3338           4 :         ScDocument& rDoc = pDocShell->GetDocument();
    3339           4 :         ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
    3340           4 :         ScChartListenerCollection* pColl = rDoc.GetChartListenerCollection();
    3341           8 :         OUString aName = pColl->getUniqueName(OUString("__Uno"));
    3342           4 :         if (aName.isEmpty())
    3343             :             // failed to create unique name.
    3344           4 :             return;
    3345             : 
    3346           4 :         ScChartListener* pListener = new ScChartListener( aName, &rDoc, aRangesRef );
    3347           4 :         pListener->SetUno( aListener, this );
    3348           4 :         pColl->insert( pListener );
    3349           8 :         pListener->StartListeningTo();
    3350           4 :     }
    3351             : }
    3352             : 
    3353           4 : void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
    3354             :                                     chart::XChartDataChangeEventListener >& aListener )
    3355             :     throw (uno::RuntimeException, std::exception)
    3356             : {
    3357           4 :     SolarMutexGuard aGuard;
    3358           4 :     if ( pDocShell && !aRanges.empty() )
    3359             :     {
    3360           4 :         ScDocument& rDoc = pDocShell->GetDocument();
    3361           4 :         ScChartListenerCollection* pColl = rDoc.GetChartListenerCollection();
    3362           4 :         pColl->FreeUno( aListener, this );
    3363           4 :     }
    3364           4 : }
    3365             : 
    3366           2 : double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException, std::exception)
    3367             : {
    3368             :     //  im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
    3369           2 :     return DBL_MIN;
    3370             : }
    3371             : 
    3372           4 : sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException, std::exception)
    3373             : {
    3374             :     //  im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
    3375           4 :     return (nNumber == DBL_MIN);
    3376             : }
    3377             : 
    3378             : // XModifyBroadcaster
    3379             : 
    3380          12 : void SAL_CALL ScCellRangesBase::addModifyListener(const uno::Reference<util::XModifyListener>& aListener)
    3381             :     throw (uno::RuntimeException, std::exception)
    3382             : {
    3383          12 :     SolarMutexGuard aGuard;
    3384          12 :     if ( aRanges.empty() )
    3385           0 :         throw uno::RuntimeException();
    3386             : 
    3387             :     uno::Reference<util::XModifyListener> *pObj =
    3388          12 :             new uno::Reference<util::XModifyListener>( aListener );
    3389          12 :     aValueListeners.push_back( pObj );
    3390             : 
    3391          12 :     if ( aValueListeners.size() == 1 )
    3392             :     {
    3393          12 :         if (!pValueListener)
    3394          12 :             pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
    3395             : 
    3396          12 :         ScDocument& rDoc = pDocShell->GetDocument();
    3397          24 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; i++)
    3398          12 :             rDoc.StartListeningArea( *aRanges[ i ], pValueListener );
    3399             : 
    3400          12 :         acquire();  // don't lose this object (one ref for all listeners)
    3401          12 :     }
    3402          12 : }
    3403             : 
    3404           4 : void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
    3405             :                                 throw(uno::RuntimeException, std::exception)
    3406             : {
    3407             : 
    3408           4 :     SolarMutexGuard aGuard;
    3409           4 :     if ( aRanges.empty() )
    3410           0 :         throw uno::RuntimeException();
    3411             : 
    3412           4 :     acquire();      // in case the listeners have the last ref - released below
    3413             : 
    3414           4 :     sal_uInt16 nCount = aValueListeners.size();
    3415           8 :     for ( sal_uInt16 n=nCount; n--; )
    3416             :     {
    3417           4 :         uno::Reference<util::XModifyListener>& rObj = aValueListeners[n];
    3418           4 :         if ( rObj == aListener )
    3419             :         {
    3420           4 :             aValueListeners.erase( aValueListeners.begin() + n );
    3421             : 
    3422           4 :             if ( aValueListeners.empty() )
    3423             :             {
    3424           4 :                 if (pValueListener)
    3425           4 :                     pValueListener->EndListeningAll();
    3426             : 
    3427           4 :                 release();      // release the ref for the listeners
    3428             :             }
    3429             : 
    3430           4 :             break;
    3431             :         }
    3432             :     }
    3433             : 
    3434           4 :     release();      // might delete this object
    3435           4 : }
    3436             : 
    3437             : // XCellRangesQuery
    3438             : 
    3439          50 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
    3440             :     throw(uno::RuntimeException, std::exception)
    3441             : {
    3442          50 :     SolarMutexGuard aGuard;
    3443          50 :     if (pDocShell)
    3444             :     {
    3445             :         //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
    3446          50 :         SCTAB nTab = lcl_FirstTab(aRanges);
    3447             : 
    3448          50 :         ScMarkData aMarkData(*GetMarkData());
    3449             : 
    3450          50 :         ScDocument& rDoc = pDocShell->GetDocument();
    3451          50 :         SCCOL nCol = 0, nLastCol;
    3452         214 :         while (nCol <= MAXCOL)
    3453             :         {
    3454         114 :             if (rDoc.ColHidden(nCol, nTab, NULL, &nLastCol))
    3455             :                 // hidden columns.  Unselect them.
    3456          36 :                 aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
    3457             : 
    3458         114 :             nCol = nLastCol + 1;
    3459             :         }
    3460             : 
    3461          50 :         SCROW nRow = 0, nLastRow;
    3462         208 :         while (nRow <= MAXROW)
    3463             :         {
    3464         108 :             if (rDoc.RowHidden(nRow, nTab, NULL, &nLastRow))
    3465             :                 // These rows are hidden.  Unselect them.
    3466          30 :                 aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
    3467             : 
    3468         108 :             nRow = nLastRow + 1;
    3469             :         }
    3470             : 
    3471         100 :         ScRangeList aNewRanges;
    3472          50 :         aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3473         100 :         return new ScCellRangesObj( pDocShell, aNewRanges );
    3474             :     }
    3475             : 
    3476           0 :     return NULL;
    3477             : }
    3478             : 
    3479           6 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
    3480             :     throw(uno::RuntimeException, std::exception)
    3481             : {
    3482           6 :     SolarMutexGuard aGuard;
    3483           6 :     if (pDocShell)
    3484             :     {
    3485           6 :         ScDocument& rDoc = pDocShell->GetDocument();
    3486             : 
    3487           6 :         ScMarkData aMarkData(*GetMarkData());
    3488             : 
    3489             :         //  belegte Zellen wegmarkieren
    3490          18 :         for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
    3491             :         {
    3492          12 :             ScRange aRange = *aRanges[ i ];
    3493             : 
    3494          12 :             ScCellIterator aIter( &rDoc, aRange );
    3495          70 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3496             :             {
    3497             :                 //  Notizen zaehlen als nicht-leer
    3498          58 :                 if (!aIter.isEmpty())
    3499          58 :                     aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
    3500             :             }
    3501          12 :         }
    3502             : 
    3503          12 :         ScRangeList aNewRanges;
    3504             :         //  IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
    3505             :         //if (aMarkData.HasAnyMultiMarks()) // #i20044# should be set for all empty range
    3506           6 :         aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3507             : 
    3508          12 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3509             :     }
    3510             : 
    3511           0 :     return NULL;
    3512             : }
    3513             : 
    3514          54 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
    3515             :     sal_Int16 nContentFlags )
    3516             :         throw(uno::RuntimeException, std::exception)
    3517             : {
    3518          54 :     SolarMutexGuard aGuard;
    3519          54 :     if (pDocShell)
    3520             :     {
    3521          54 :         ScDocument& rDoc = pDocShell->GetDocument();
    3522             : 
    3523          54 :         ScMarkData aMarkData;
    3524             : 
    3525             :         //  passende Zellen selektieren
    3526         114 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    3527             :         {
    3528          60 :             ScRange aRange = *aRanges[ i ];
    3529             : 
    3530          60 :             ScCellIterator aIter( &rDoc, aRange );
    3531         128 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3532             :             {
    3533          68 :                 bool bAdd = false;
    3534          68 :                 switch (aIter.getType())
    3535             :                 {
    3536             :                     case CELLTYPE_STRING:
    3537          44 :                         if ( nContentFlags & sheet::CellFlags::STRING )
    3538           4 :                             bAdd = true;
    3539          44 :                         break;
    3540             :                     case CELLTYPE_EDIT:
    3541           0 :                         if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
    3542           0 :                             bAdd = true;
    3543           0 :                         break;
    3544             :                     case CELLTYPE_FORMULA:
    3545           4 :                         if ( nContentFlags & sheet::CellFlags::FORMULA )
    3546           0 :                             bAdd = true;
    3547           4 :                         break;
    3548             :                     case CELLTYPE_VALUE:
    3549          20 :                         if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
    3550             :                                 == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
    3551           0 :                             bAdd = true;
    3552             :                         else
    3553             :                         {
    3554             :                             //  Date/Time Erkennung
    3555             : 
    3556             :                             sal_uLong nIndex = (sal_uLong)static_cast<const SfxUInt32Item*>(rDoc.GetAttr(
    3557          20 :                                         aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue();
    3558          20 :                             short nTyp = rDoc.GetFormatTable()->GetType(nIndex);
    3559          20 :                             if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
    3560             :                                     (nTyp == NUMBERFORMAT_DATETIME))
    3561             :                             {
    3562           0 :                                 if ( nContentFlags & sheet::CellFlags::DATETIME )
    3563           0 :                                     bAdd = true;
    3564             :                             }
    3565             :                             else
    3566             :                             {
    3567          20 :                                 if ( nContentFlags & sheet::CellFlags::VALUE )
    3568          12 :                                     bAdd = true;
    3569             :                             }
    3570             :                         }
    3571          20 :                         break;
    3572             :                     default:
    3573             :                         {
    3574             :                             // added to avoid warnings
    3575             :                         }
    3576             :                 }
    3577             : 
    3578          68 :                 if (bAdd)
    3579          16 :                     aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
    3580             :             }
    3581             : 
    3582          60 :         }
    3583             : 
    3584          54 :         ScRangeList aNewRanges;
    3585          54 :         if (aMarkData.IsMultiMarked())
    3586           6 :             aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3587             : 
    3588          54 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3589             :     }
    3590             : 
    3591           0 :     return NULL;
    3592             : }
    3593             : 
    3594          98 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
    3595             :     sal_Int32 nResultFlags )
    3596             :         throw(uno::RuntimeException, std::exception)
    3597             : {
    3598          98 :     SolarMutexGuard aGuard;
    3599          98 :     if (pDocShell)
    3600             :     {
    3601          98 :         ScDocument& rDoc = pDocShell->GetDocument();
    3602             : 
    3603          98 :         ScMarkData aMarkData;
    3604             : 
    3605             :         //  passende Zellen selektieren
    3606         202 :         for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    3607             :         {
    3608         104 :             ScRange aRange = *aRanges[ i ];
    3609             : 
    3610         104 :             ScCellIterator aIter( &rDoc, aRange );
    3611         944 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3612             :             {
    3613         840 :                 if (aIter.getType() == CELLTYPE_FORMULA)
    3614             :                 {
    3615         360 :                     ScFormulaCell* pFCell = aIter.getFormulaCell();
    3616         360 :                     bool bAdd = false;
    3617         360 :                     if (pFCell->GetErrCode())
    3618             :                     {
    3619           0 :                         if ( nResultFlags & sheet::FormulaResult::ERROR )
    3620           0 :                             bAdd = true;
    3621             :                     }
    3622         360 :                     else if (pFCell->IsValue())
    3623             :                     {
    3624         360 :                         if ( nResultFlags & sheet::FormulaResult::VALUE )
    3625         360 :                             bAdd = true;
    3626             :                     }
    3627             :                     else    // String
    3628             :                     {
    3629           0 :                         if ( nResultFlags & sheet::FormulaResult::STRING )
    3630           0 :                             bAdd = true;
    3631             :                     }
    3632             : 
    3633         360 :                     if (bAdd)
    3634         360 :                         aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
    3635             :                 }
    3636             :             }
    3637         104 :         }
    3638             : 
    3639         196 :         ScRangeList aNewRanges;
    3640          98 :         if (aMarkData.IsMultiMarked())
    3641          20 :             aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3642             : 
    3643         196 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3644             :     }
    3645             : 
    3646           0 :     return NULL;
    3647             : }
    3648             : 
    3649          16 : uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
    3650             :                         const table::CellAddress& aCompare, bool bColumnDiff)
    3651             : {
    3652          16 :     if (pDocShell)
    3653             :     {
    3654          16 :         size_t nRangeCount = aRanges.size();
    3655             :         size_t i;
    3656          16 :         ScDocument& rDoc = pDocShell->GetDocument();
    3657          16 :         ScMarkData aMarkData;
    3658             : 
    3659          16 :         SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
    3660             : 
    3661             :         //  zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
    3662             :         //  (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
    3663             : 
    3664          16 :         SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
    3665          16 :         ScRange aCmpRange, aCellRange;
    3666          16 :         if (bColumnDiff)
    3667           8 :             aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
    3668             :         else
    3669           8 :             aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
    3670          32 :         ScCellIterator aCmpIter( &rDoc, aCmpRange );
    3671          82 :         for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
    3672             :         {
    3673          66 :             SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
    3674          66 :             if (bColumnDiff)
    3675          64 :                 aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
    3676          32 :                         static_cast<SCCOL>(nCellPos),MAXROW,nTab );
    3677             :             else
    3678          34 :                 aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
    3679             : 
    3680         252 :             for (i=0; i<nRangeCount; i++)
    3681             :             {
    3682         186 :                 ScRange aRange( *aRanges[ i ] );
    3683         186 :                 if ( aRange.Intersects( aCellRange ) )
    3684             :                 {
    3685          58 :                     if (bColumnDiff)
    3686             :                     {
    3687          24 :                         aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
    3688          24 :                         aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
    3689             :                     }
    3690             :                     else
    3691             :                     {
    3692          34 :                         aRange.aStart.SetRow(nCellPos);
    3693          34 :                         aRange.aEnd.SetRow(nCellPos);
    3694             :                     }
    3695          58 :                     aMarkData.SetMultiMarkArea( aRange );
    3696             :                 }
    3697             :             }
    3698             :         }
    3699             : 
    3700             :         //  alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
    3701             :         //  selektieren oder aufheben
    3702             : 
    3703          16 :         ScAddress aCmpAddr;
    3704          44 :         for (i=0; i<nRangeCount; i++)
    3705             :         {
    3706          28 :             ScRange aRange( *aRanges[ i ] );
    3707             : 
    3708          28 :             ScCellIterator aIter( &rDoc, aRange );
    3709         144 :             for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3710             :             {
    3711         116 :                 if (bColumnDiff)
    3712          58 :                     aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
    3713             :                 else
    3714          58 :                     aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
    3715             : 
    3716         116 :                 ScRange aOneRange(aIter.GetPos());
    3717         116 :                 if (!aIter.equalsWithoutFormat(aCmpAddr))
    3718          26 :                     aMarkData.SetMultiMarkArea( aOneRange );
    3719             :                 else
    3720          90 :                     aMarkData.SetMultiMarkArea( aOneRange, false );     // deselect
    3721             :             }
    3722          28 :         }
    3723             : 
    3724          32 :         ScRangeList aNewRanges;
    3725          16 :         if (aMarkData.IsMultiMarked())
    3726          16 :             aMarkData.FillRangeListWithMarks( &aNewRanges, false );
    3727             : 
    3728          32 :         return new ScCellRangesObj( pDocShell, aNewRanges );    // aNewRanges kann leer sein
    3729             :     }
    3730           0 :     return NULL;
    3731             : }
    3732             : 
    3733           8 : uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
    3734             :     const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
    3735             : {
    3736           8 :     SolarMutexGuard aGuard;
    3737           8 :     return QueryDifferences_Impl( aCompare, true );
    3738             : }
    3739             : 
    3740           8 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
    3741             :     const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
    3742             : {
    3743           8 :     SolarMutexGuard aGuard;
    3744           8 :     return QueryDifferences_Impl( aCompare, false );
    3745             : }
    3746             : 
    3747          50 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
    3748             :                             const table::CellRangeAddress& aRange ) throw(uno::RuntimeException, std::exception)
    3749             : {
    3750          50 :     SolarMutexGuard aGuard;
    3751             :     ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
    3752          50 :                    (SCCOL)aRange.EndColumn,   (SCROW)aRange.EndRow,   aRange.Sheet );
    3753             : 
    3754         100 :     ScRangeList aNew;
    3755         106 :     for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
    3756             :     {
    3757          56 :         ScRange aTemp( *aRanges[ i ] );
    3758          56 :         if ( aTemp.Intersects( aMask ) )
    3759         104 :             aNew.Join( ScRange( std::max( aTemp.aStart.Col(), aMask.aStart.Col() ),
    3760         104 :                                 std::max( aTemp.aStart.Row(), aMask.aStart.Row() ),
    3761         104 :                                 std::max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
    3762         104 :                                 std::min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
    3763         104 :                                 std::min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
    3764         364 :                                 std::min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
    3765             :     }
    3766             : 
    3767         100 :     return new ScCellRangesObj( pDocShell, aNew );  // kann leer sein
    3768             : }
    3769             : 
    3770             : // XFormulaQuery
    3771             : 
    3772           6 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
    3773             :     sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
    3774             : {
    3775           6 :     SolarMutexGuard aGuard;
    3776           6 :     if ( pDocShell )
    3777             :     {
    3778           6 :         ScDocument& rDoc = pDocShell->GetDocument();
    3779             : 
    3780           6 :         ScRangeList aNewRanges(aRanges);
    3781             :         bool bFound;
    3782           6 :         do
    3783             :         {
    3784           6 :             bFound = false;
    3785             : 
    3786             :             //  aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
    3787           6 :             ScMarkData aMarkData;
    3788           6 :             aMarkData.MarkFromRangeList( aNewRanges, false );
    3789           6 :             aMarkData.MarkToMulti();        // needed for IsAllMarked
    3790             : 
    3791          18 :             for (size_t nR = 0, nCount = aNewRanges.size(); nR<nCount; ++nR)
    3792             :             {
    3793          12 :                 ScRange aRange( *aNewRanges[ nR] );
    3794          12 :                 ScCellIterator aIter( &rDoc, aRange );
    3795          72 :                 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
    3796             :                 {
    3797          60 :                     if (aIter.getType() != CELLTYPE_FORMULA)
    3798          56 :                         continue;
    3799             : 
    3800           4 :                     ScDetectiveRefIter aRefIter(aIter.getFormulaCell());
    3801           4 :                     ScRange aRefRange;
    3802          12 :                     while ( aRefIter.GetNextRef( aRefRange) )
    3803             :                     {
    3804           4 :                         if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
    3805           0 :                             bFound = true;
    3806           4 :                         aMarkData.SetMultiMarkArea(aRefRange, true);
    3807             :                     }
    3808             :                 }
    3809          12 :             }
    3810             : 
    3811           6 :             aMarkData.FillRangeListWithMarks( &aNewRanges, true );
    3812             :         }
    3813           0 :         while ( bRecursive && bFound );
    3814             : 
    3815           6 :         return new ScCellRangesObj( pDocShell, aNewRanges );
    3816             :     }
    3817             : 
    3818           0 :     return NULL;
    3819             : }
    3820             : 
    3821           6 : uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
    3822             :     sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
    3823             : {
    3824           6 :     SolarMutexGuard aGuard;
    3825           6 :     if ( pDocShell )
    3826             :     {
    3827           6 :         ScDocument& rDoc = pDocShell->GetDocument();
    3828             : 
    3829           6 :         ScRangeList aNewRanges(aRanges);
    3830             :         bool bFound;
    3831           6 :         do
    3832             :         {
    3833           6 :             bFound = false;
    3834             : 
    3835             :             //  aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
    3836           6 :             ScMarkData aMarkData;
    3837           6 :             aMarkData.MarkFromRangeList( aNewRanges, false );
    3838           6 :             aMarkData.MarkToMulti();        // needed for IsAllMarked
    3839             : 
    3840           6 :             SCTAB nTab = lcl_FirstTab(aNewRanges);              //! alle Tabellen
    3841             : 
    3842          12 :             ScCellIterator aCellIter( &rDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab) );
    3843         228 :             for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
    3844             :             {
    3845         222 :                 if (aCellIter.getType() != CELLTYPE_FORMULA)
    3846         216 :                     continue;
    3847             : 
    3848           6 :                 bool bMark = false;
    3849           6 :                 ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
    3850           6 :                 ScRange aRefRange;
    3851          18 :                 while ( aIter.GetNextRef( aRefRange) )
    3852             :                 {
    3853           6 :                     size_t nRangesCount = aNewRanges.size();
    3854          18 :                     for (size_t nR = 0; nR < nRangesCount; ++nR)
    3855             :                     {
    3856          12 :                         ScRange aRange( *aNewRanges[ nR ] );
    3857          12 :                         if (aRange.Intersects(aRefRange))
    3858           4 :                             bMark = true;                   // von Teil des Ranges abhaengig
    3859             :                     }
    3860             :                 }
    3861           6 :                 if (bMark)
    3862             :                 {
    3863           4 :                     ScRange aCellRange(aCellIter.GetPos());
    3864           4 :                     if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
    3865           0 :                         bFound = true;
    3866           4 :                     aMarkData.SetMultiMarkArea(aCellRange, true);
    3867             :                 }
    3868             :             }
    3869             : 
    3870          12 :             aMarkData.FillRangeListWithMarks( &aNewRanges, true );
    3871             :         }
    3872           0 :         while ( bRecursive && bFound );
    3873             : 
    3874           6 :         return new ScCellRangesObj( pDocShell, aNewRanges );
    3875             :     }
    3876             : 
    3877           0 :     return NULL;
    3878             : }
    3879             : 
    3880             : // XSearchable
    3881             : 
    3882          24 : uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
    3883             :                                                             throw(uno::RuntimeException, std::exception)
    3884             : {
    3885          24 :     SolarMutexGuard aGuard;
    3886          24 :     return new ScCellSearchObj;
    3887             : }
    3888             : 
    3889          44 : uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
    3890             :                         const uno::Reference<util::XSearchDescriptor>& xDesc )
    3891             :                                                     throw(uno::RuntimeException,
    3892             :                                                           std::exception)
    3893             : {
    3894          44 :     SolarMutexGuard aGuard;
    3895             :     //  Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
    3896          44 :     uno::Reference<container::XIndexAccess> xRet;
    3897          44 :     if ( pDocShell && xDesc.is() )
    3898             :     {
    3899          44 :         ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
    3900          44 :         if (pSearch)
    3901             :         {
    3902          44 :             SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
    3903          44 :             if (pSearchItem)
    3904             :             {
    3905          44 :                 ScDocument& rDoc = pDocShell->GetDocument();
    3906          44 :                 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
    3907             :                 //  immer nur innerhalb dieses Objekts
    3908          44 :                 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
    3909             : 
    3910          44 :                 ScMarkData aMark(*GetMarkData());
    3911             : 
    3912          88 :                 OUString aDummyUndo;
    3913          88 :                 ScRangeList aMatchedRanges;
    3914          44 :                 SCCOL nCol = 0;
    3915          44 :                 SCROW nRow = 0;
    3916          44 :                 SCTAB nTab = 0;
    3917             :                 bool bFound = rDoc.SearchAndReplace(
    3918          44 :                     *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
    3919          44 :                 if (bFound)
    3920             :                 {
    3921             :                     //  bei findAll immer CellRanges, egal wieviel gefunden wurde
    3922          36 :                     xRet.set(new ScCellRangesObj( pDocShell, aMatchedRanges ));
    3923          44 :                 }
    3924             :             }
    3925             :         }
    3926             :     }
    3927          44 :     return xRet;
    3928             : }
    3929             : 
    3930          46 : uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
    3931             :                                     const uno::Reference<util::XSearchDescriptor>& xDesc,
    3932             :                                     const ScAddress* pLastPos )
    3933             : {
    3934          46 :     uno::Reference<uno::XInterface> xRet;
    3935          46 :     if ( pDocShell && xDesc.is() )
    3936             :     {
    3937          46 :         ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
    3938          46 :         if (pSearch)
    3939             :         {
    3940          46 :             SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
    3941          46 :             if (pSearchItem)
    3942             :             {
    3943          46 :                 ScDocument& rDoc = pDocShell->GetDocument();
    3944          46 :                 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
    3945             :                 //  immer nur innerhalb dieses Objekts
    3946          46 :                 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
    3947             : 
    3948          46 :                 ScMarkData aMark(*GetMarkData());
    3949             : 
    3950             :                 SCCOL nCol;
    3951             :                 SCROW nRow;
    3952             :                 SCTAB nTab;
    3953          46 :                 if (pLastPos)
    3954           4 :                     pLastPos->GetVars( nCol, nRow, nTab );
    3955             :                 else
    3956             :                 {
    3957          42 :                     nTab = lcl_FirstTab(aRanges);   //! mehrere Tabellen?
    3958          42 :                     ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
    3959             :                 }
    3960             : 
    3961          92 :                 OUString aDummyUndo;
    3962          92 :                 ScRangeList aMatchedRanges;
    3963             :                 bool bFound = rDoc.SearchAndReplace(
    3964          46 :                     *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
    3965          46 :                 if (bFound)
    3966             :                 {
    3967          30 :                     ScAddress aFoundPos( nCol, nRow, nTab );
    3968          30 :                     xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
    3969          46 :                 }
    3970             :             }
    3971             :         }
    3972             :     }
    3973          46 :     return xRet;
    3974             : }
    3975             : 
    3976          42 : uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
    3977             :                         const uno::Reference<util::XSearchDescriptor>& xDesc )
    3978             :                                                 throw(uno::RuntimeException, std::exception)
    3979             : {
    3980          42 :     SolarMutexGuard aGuard;
    3981          42 :     return Find_Impl( xDesc, NULL );
    3982             : }
    3983             : 
    3984           4 : uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
    3985             :                         const uno::Reference<uno::XInterface>& xStartAt,
    3986             :                         const uno::Reference<util::XSearchDescriptor >& xDesc )
    3987             :                                                 throw(uno::RuntimeException, std::exception)
    3988             : {
    3989           4 :     SolarMutexGuard aGuard;
    3990           4 :     if ( xStartAt.is() )
    3991             :     {
    3992           4 :         ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
    3993           4 :         if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
    3994             :         {
    3995           4 :             const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
    3996           4 :             if ( rStartRanges.size() == 1 )
    3997             :             {
    3998           4 :                 ScAddress aStartPos = rStartRanges[ 0 ]->aStart;
    3999           4 :                 return Find_Impl( xDesc, &aStartPos );
    4000             :             }
    4001             :         }
    4002             :     }
    4003           0 :     return NULL;
    4004             : }
    4005             : 
    4006             : // XReplaceable
    4007             : 
    4008          48 : uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
    4009             :                                                 throw(uno::RuntimeException, std::exception)
    4010             : {
    4011          48 :     SolarMutexGuard aGuard;
    4012          48 :     return new ScCellSearchObj;
    4013             : }
    4014             : 
    4015          52 : sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
    4016             :                                                 throw(uno::RuntimeException,
    4017             :                                                       std::exception)
    4018             : {
    4019          52 :     SolarMutexGuard aGuard;
    4020          52 :     sal_Int32 nReplaced = 0;
    4021          52 :     if ( pDocShell && xDesc.is() )
    4022             :     {
    4023          52 :         ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
    4024          52 :         if (pSearch)
    4025             :         {
    4026          52 :             SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
    4027          52 :             if (pSearchItem)
    4028             :             {
    4029          52 :                 ScDocument& rDoc = pDocShell->GetDocument();
    4030          52 :                 bool bUndo(rDoc.IsUndoEnabled());
    4031          52 :                 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
    4032             :                 //  immer nur innerhalb dieses Objekts
    4033          52 :                 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
    4034             : 
    4035          52 :                 ScMarkData aMark(*GetMarkData());
    4036             : 
    4037          52 :                 SCTAB nTabCount = rDoc.GetTableCount();
    4038          52 :                 bool bProtected = !pDocShell->IsEditable();
    4039          52 :                 ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
    4040         104 :                 for (; itr != itrEnd && *itr < nTabCount; ++itr)
    4041          52 :                     if ( rDoc.IsTabProtected(*itr) )
    4042           0 :                         bProtected = true;
    4043          52 :                 if (bProtected)
    4044             :                 {
    4045             :                     //! Exception, oder was?
    4046             :                 }
    4047             :                 else
    4048             :                 {
    4049          52 :                     SCTAB nTab = aMark.GetFirstSelected();      // bei SearchAndReplace nicht benutzt
    4050          52 :                     SCCOL nCol = 0;
    4051          52 :                     SCROW nRow = 0;
    4052             : 
    4053          52 :                     OUString aUndoStr;
    4054          52 :                     ScDocument* pUndoDoc = NULL;
    4055          52 :                     if (bUndo)
    4056             :                     {
    4057          52 :                         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    4058          52 :                         pUndoDoc->InitUndo( &rDoc, nTab, nTab );
    4059             :                     }
    4060          52 :                     itr = aMark.begin();
    4061         104 :                     for (; itr != itrEnd && *itr < nTabCount; ++itr)
    4062          52 :                         if ( *itr != nTab && bUndo)
    4063           0 :                             pUndoDoc->AddUndoTab( *itr, *itr );
    4064         104 :                     boost::scoped_ptr<ScMarkData> pUndoMark;
    4065          52 :                     if (bUndo)
    4066          52 :                         pUndoMark.reset(new ScMarkData(aMark));
    4067             : 
    4068          52 :                     bool bFound = false;
    4069          52 :                     if (bUndo)
    4070             :                     {
    4071          52 :                         ScRangeList aMatchedRanges;
    4072             :                         bFound = rDoc.SearchAndReplace(
    4073          52 :                             *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc );
    4074             :                     }
    4075          52 :                     if (bFound)
    4076             :                     {
    4077          44 :                         nReplaced = pUndoDoc->GetCellCount();
    4078             : 
    4079          44 :                         pDocShell->GetUndoManager()->AddUndoAction(
    4080             :                             new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
    4081          44 :                                                         aUndoStr, pUndoDoc, pSearchItem ) );
    4082             : 
    4083          44 :                         pDocShell->PostPaintGridAll();
    4084          44 :                         pDocShell->SetDocumentModified();
    4085             :                     }
    4086             :                     else
    4087             :                     {
    4088           8 :                         delete pUndoDoc;
    4089             :                         // nReplaced bleibt 0
    4090          52 :                     }
    4091          52 :                 }
    4092             :             }
    4093             :         }
    4094             :     }
    4095          52 :     return nReplaced;
    4096             : }
    4097             : 
    4098             : // XUnoTunnel
    4099             : 
    4100       29370 : sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
    4101             :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
    4102             : {
    4103       58740 :     if ( rId.getLength() == 16 &&
    4104       29370 :           0 == memcmp( getUnoTunnelId().getConstArray(),
    4105       58740 :                                     rId.getConstArray(), 16 ) )
    4106             :     {
    4107       24300 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
    4108             :     }
    4109        5070 :     return 0;
    4110             : }
    4111             : 
    4112             : namespace
    4113             : {
    4114             :     class theScCellRangesBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellRangesBaseUnoTunnelId> {};
    4115             : }
    4116             : 
    4117       53674 : const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
    4118             : {
    4119       53674 :     return theScCellRangesBaseUnoTunnelId::get().getSeq();
    4120             : }
    4121             : 
    4122       24336 : ScCellRangesBase* ScCellRangesBase::getImplementation( const uno::Reference<uno::XInterface> xObj )
    4123             : {
    4124       24336 :     ScCellRangesBase* pRet = NULL;
    4125       24336 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
    4126       24336 :     if (xUT.is())
    4127       24304 :         pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
    4128       24336 :     return pRet;
    4129             : }
    4130             : 
    4131             : typedef boost::ptr_vector<ScNamedEntry> ScNamedEntryArr_Impl;
    4132             : 
    4133        6882 : struct ScCellRangesObj::Impl
    4134             : {
    4135             :     ScNamedEntryArr_Impl m_aNamedEntries;
    4136             : };
    4137             : 
    4138        3442 : ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR)
    4139             :     : ScCellRangesBase(pDocSh, rR)
    4140        3442 :     , m_pImpl(new Impl)
    4141             : {
    4142        3442 : }
    4143             : 
    4144        6880 : ScCellRangesObj::~ScCellRangesObj()
    4145             : {
    4146        6880 : }
    4147             : 
    4148        6154 : void ScCellRangesObj::RefChanged()
    4149             : {
    4150        6154 :     ScCellRangesBase::RefChanged();
    4151             : 
    4152             :     //  nix weiter...
    4153        6154 : }
    4154             : 
    4155       23138 : uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
    4156             :                                                 throw(uno::RuntimeException, std::exception)
    4157             : {
    4158       23138 :     SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
    4159       20330 :     SC_QUERYINTERFACE( sheet::XSheetCellRanges )
    4160       20016 :     SC_QUERYINTERFACE( container::XIndexAccess )
    4161       19816 :     SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
    4162       19816 :     SC_QUERYINTERFACE( container::XEnumerationAccess )
    4163       19712 :     SC_QUERYINTERFACE( container::XNameContainer )
    4164       19696 :     SC_QUERYINTERFACE( container::XNameReplace )
    4165       19696 :     SC_QUERYINTERFACE( container::XNameAccess )
    4166             : 
    4167       19536 :     return ScCellRangesBase::queryInterface( rType );
    4168             : }
    4169             : 
    4170       72778 : void SAL_CALL ScCellRangesObj::acquire() throw()
    4171             : {
    4172       72778 :     ScCellRangesBase::acquire();
    4173       72778 : }
    4174             : 
    4175       72776 : void SAL_CALL ScCellRangesObj::release() throw()
    4176             : {
    4177       72776 :     ScCellRangesBase::release();
    4178       72776 : }
    4179             : 
    4180           0 : uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException, std::exception)
    4181             : {
    4182           0 :     static uno::Sequence<uno::Type> aTypes;
    4183           0 :     if ( aTypes.getLength() == 0 )
    4184             :     {
    4185           0 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
    4186           0 :         long nParentLen = aParentTypes.getLength();
    4187           0 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    4188             : 
    4189           0 :         aTypes.realloc( nParentLen + 3 );
    4190           0 :         uno::Type* pPtr = aTypes.getArray();
    4191           0 :         pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
    4192           0 :         pPtr[nParentLen + 1] = cppu::UnoType<container::XNameContainer>::get();
    4193           0 :         pPtr[nParentLen + 2] = cppu::UnoType<container::XEnumerationAccess>::get();
    4194             : 
    4195           0 :         for (long i=0; i<nParentLen; i++)
    4196           0 :             pPtr[i] = pParentPtr[i];                // parent types first
    4197             :     }
    4198           0 :     return aTypes;
    4199             : }
    4200             : 
    4201           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
    4202             :                                                     throw(uno::RuntimeException, std::exception)
    4203             : {
    4204           0 :     return css::uno::Sequence<sal_Int8>();
    4205             : }
    4206             : 
    4207             : // XCellRanges
    4208             : 
    4209         958 : ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
    4210             : {
    4211         958 :     ScDocShell* pDocSh = GetDocShell();
    4212         958 :     const ScRangeList& rRanges = GetRangeList();
    4213         958 :     if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.size()) )
    4214             :     {
    4215         954 :         ScRange aRange( *rRanges[ nIndex ] );
    4216         954 :         if ( aRange.aStart == aRange.aEnd )
    4217          20 :             return new ScCellObj( pDocSh, aRange.aStart );
    4218             :         else
    4219         934 :             return new ScCellRangeObj( pDocSh, aRange );
    4220             :     }
    4221             : 
    4222           4 :     return NULL;        // keine DocShell oder falscher Index
    4223             : }
    4224             : 
    4225        1928 : uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
    4226             :                                                     throw(uno::RuntimeException, std::exception)
    4227             : {
    4228        1928 :     SolarMutexGuard aGuard;
    4229        1928 :     ScDocShell* pDocSh = GetDocShell();
    4230        1928 :     const ScRangeList& rRanges = GetRangeList();
    4231        1928 :     size_t nCount = rRanges.size();
    4232        1928 :     if ( pDocSh && nCount )
    4233             :     {
    4234        1922 :         table::CellRangeAddress aRangeAddress;
    4235        1922 :         uno::Sequence<table::CellRangeAddress> aSeq(nCount);
    4236        1922 :         table::CellRangeAddress* pAry = aSeq.getArray();
    4237        5178 :         for ( size_t i=0; i < nCount; i++)
    4238             :         {
    4239        3256 :             ScUnoConversion::FillApiRange( aRangeAddress, *rRanges[ i ] );
    4240        3256 :             pAry[i] = aRangeAddress;
    4241             :         }
    4242        1922 :         return aSeq;
    4243             :     }
    4244             : 
    4245           6 :     return uno::Sequence<table::CellRangeAddress>(0);   // leer ist moeglich
    4246             : }
    4247             : 
    4248          54 : uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
    4249             :                                                     throw(uno::RuntimeException, std::exception)
    4250             : {
    4251          54 :     SolarMutexGuard aGuard;
    4252             : 
    4253             :     //  getCells with empty range list is possible (no exception),
    4254             :     //  the resulting enumeration just has no elements
    4255             :     //  (same behaviour as a valid range with no cells)
    4256             :     //  This is handled in ScCellsEnumeration ctor.
    4257             : 
    4258          54 :     const ScRangeList& rRanges = GetRangeList();
    4259          54 :     ScDocShell* pDocSh = GetDocShell();
    4260          54 :     if (pDocSh)
    4261          54 :         return new ScCellsObj( pDocSh, rRanges );
    4262           0 :     return NULL;
    4263             : }
    4264             : 
    4265          66 : OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
    4266             :                                                 throw(uno::RuntimeException, std::exception)
    4267             : {
    4268          66 :     SolarMutexGuard aGuard;
    4269          66 :     OUString aString;
    4270          66 :     ScDocShell* pDocSh = GetDocShell();
    4271          66 :     const ScRangeList& rRanges = GetRangeList();
    4272          66 :     if (pDocSh)
    4273          66 :         rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, &pDocSh->GetDocument() );
    4274          66 :     return aString;
    4275             : }
    4276             : 
    4277             : // XSheetCellRangeContainer
    4278             : 
    4279        6040 : void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
    4280             :                                     sal_Bool bMergeRanges )
    4281             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception)
    4282             : {
    4283        6040 :     SolarMutexGuard aGuard;
    4284             :     ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
    4285             :             static_cast<SCROW>(rRange.StartRow),
    4286             :             static_cast<SCTAB>(rRange.Sheet),
    4287             :             static_cast<SCCOL>(rRange.EndColumn),
    4288             :             static_cast<SCROW>(rRange.EndRow),
    4289        6040 :             static_cast<SCTAB>(rRange.Sheet));
    4290        6040 :     AddRange(aRange, bMergeRanges);
    4291        6040 : }
    4292             : 
    4293          16 : static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
    4294             : {
    4295          16 :     sal_uInt16 nCount = rNamedEntries.size();
    4296          52 :     for ( sal_uInt16 n=nCount; n--; )
    4297          20 :         if ( rNamedEntries[n].GetRange() == rRange )
    4298           8 :             rNamedEntries.erase( rNamedEntries.begin() + n );
    4299          16 : }
    4300             : 
    4301          16 : void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
    4302             :                                 throw(::com::sun::star::container::NoSuchElementException,
    4303             :                                     ::com::sun::star::uno::RuntimeException, std::exception)
    4304             : {
    4305          16 :     SolarMutexGuard aGuard;
    4306          16 :     const ScRangeList& rRanges = GetRangeList();
    4307             : 
    4308          32 :     ScRangeList aSheetRanges;
    4309          32 :     ScRangeList aNotSheetRanges;
    4310          50 :     for (size_t i = 0; i < rRanges.size(); ++i)
    4311             :     {
    4312          34 :         if (rRanges[ i]->aStart.Tab() == rRange.Sheet)
    4313             :         {
    4314          28 :             aSheetRanges.Append( *rRanges[ i ] );
    4315             :         }
    4316             :         else
    4317             :         {
    4318           6 :             aNotSheetRanges.Append( *rRanges[ i ] );
    4319             :         }
    4320             :     }
    4321          32 :     ScMarkData aMarkData;
    4322          16 :     aMarkData.MarkFromRangeList( aSheetRanges, false );
    4323             :     ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
    4324             :                 static_cast<SCROW>(rRange.StartRow),
    4325             :                 static_cast<SCTAB>(rRange.Sheet),
    4326             :                 static_cast<SCCOL>(rRange.EndColumn),
    4327             :                 static_cast<SCROW>(rRange.EndRow),
    4328          16 :                 static_cast<SCTAB>(rRange.Sheet));
    4329          16 :     if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
    4330             :     {
    4331          16 :         aMarkData.MarkToMulti();
    4332          16 :         if (aMarkData.IsAllMarked( aRange ) )
    4333             :         {
    4334          16 :             aMarkData.SetMultiMarkArea( aRange, false );
    4335          16 :             lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aRange);
    4336             :         }
    4337             :         else
    4338           0 :             throw container::NoSuchElementException();
    4339             :     }
    4340          16 :     SetNewRanges(aNotSheetRanges);
    4341          32 :     ScRangeList aNew;
    4342          16 :     aMarkData.FillRangeListWithMarks( &aNew, false );
    4343          28 :     for ( size_t j = 0; j < aNew.size(); ++j)
    4344             :     {
    4345          12 :         AddRange(*aNew[ j ], false);
    4346          16 :     }
    4347          16 : }
    4348             : 
    4349           2 : void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
    4350             :                                     sal_Bool bMergeRanges )
    4351             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception)
    4352             : {
    4353           2 :     SolarMutexGuard aGuard;
    4354           2 :     sal_Int32 nCount(rRanges.getLength());
    4355           2 :     if (nCount)
    4356             :     {
    4357           2 :         const table::CellRangeAddress* pRanges = rRanges.getConstArray();
    4358           8 :         for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
    4359             :         {
    4360             :             ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
    4361             :                     static_cast<SCROW>(pRanges->StartRow),
    4362             :                     static_cast<SCTAB>(pRanges->Sheet),
    4363             :                     static_cast<SCCOL>(pRanges->EndColumn),
    4364             :                     static_cast<SCROW>(pRanges->EndRow),
    4365           6 :                     static_cast<SCTAB>(pRanges->Sheet));
    4366           6 :             AddRange(aRange, bMergeRanges);
    4367             :         }
    4368           2 :     }
    4369           2 : }
    4370             : 
    4371           8 : void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
    4372             :                                 throw(::com::sun::star::container::NoSuchElementException,
    4373             :                                     ::com::sun::star::uno::RuntimeException, std::exception)
    4374             : {
    4375             :     // use sometimes a better/faster implementation
    4376           8 :     sal_uInt32 nCount(rRangeSeq.getLength());
    4377           8 :     if (nCount)
    4378             :     {
    4379           4 :         const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
    4380          18 :         for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
    4381             :         {
    4382          14 :             removeRangeAddress(*pRanges);
    4383             :         }
    4384             :     }
    4385           8 : }
    4386             : 
    4387             : // XNameContainer
    4388             : 
    4389           8 : static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const OUString& rName )
    4390             : {
    4391           8 :     sal_uInt16 nCount = rNamedEntries.size();
    4392          50 :     for ( sal_uInt16 n=nCount; n--; )
    4393          34 :         if ( rNamedEntries[n].GetName() == rName )
    4394           6 :             rNamedEntries.erase( rNamedEntries.begin() + n );
    4395           8 : }
    4396             : 
    4397          74 : void SAL_CALL ScCellRangesObj::insertByName( const OUString& aName, const uno::Any& aElement )
    4398             :                             throw (lang::IllegalArgumentException, container::ElementExistException,
    4399             :                                    lang::WrappedTargetException, uno::RuntimeException,
    4400             :                                    std::exception)
    4401             : {
    4402          74 :     SolarMutexGuard aGuard;
    4403          74 :     ScDocShell* pDocSh = GetDocShell();
    4404          74 :     bool bDone = false;
    4405             : 
    4406             :     //! Type of aElement can be some specific interface instead of XInterface
    4407             : 
    4408         148 :     uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
    4409          74 :     if ( pDocSh && xInterface.is() )
    4410             :     {
    4411          72 :         ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
    4412          72 :         if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
    4413             :         {
    4414             :             //  if explicit name is given and already existing, throw exception
    4415             : 
    4416          72 :             OUString aNamStr(aName);
    4417          72 :             if ( !aNamStr.isEmpty() )
    4418             :             {
    4419          72 :                 size_t nNamedCount = m_pImpl->m_aNamedEntries.size();
    4420         196 :                 for (size_t n = 0; n < nNamedCount; n++)
    4421             :                 {
    4422         126 :                     if (m_pImpl->m_aNamedEntries[n].GetName() == aNamStr)
    4423           2 :                         throw container::ElementExistException();
    4424             :                 }
    4425             :             }
    4426             : 
    4427         140 :             ScRangeList aNew(GetRangeList());
    4428          70 :             const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
    4429          70 :             size_t nAddCount = rAddRanges.size();
    4430         140 :             for ( size_t i = 0; i < nAddCount; i++ )
    4431          70 :                 aNew.Join( *rAddRanges[ i ] );
    4432          70 :             SetNewRanges(aNew);
    4433          70 :             bDone = true;
    4434             : 
    4435          70 :             if ( !aName.isEmpty() && nAddCount == 1 )
    4436             :             {
    4437             :                 //  if a name is given, also insert into list of named entries
    4438             :                 //  (only possible for a single range)
    4439             :                 //  name is not in m_pImpl->m_aNamedEntries (tested above)
    4440             : 
    4441          70 :                 ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges[ 0 ] );
    4442          70 :                 m_pImpl->m_aNamedEntries.push_back(pEntry);
    4443          72 :             }
    4444             :         }
    4445             :     }
    4446             : 
    4447          72 :     if (!bDone)
    4448             :     {
    4449             :         //  invalid element - double names are handled above
    4450           2 :         throw lang::IllegalArgumentException();
    4451          74 :     }
    4452          70 : }
    4453             : 
    4454          26 : static bool lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
    4455             :                             const OUString& rName, size_t& rIndex )
    4456             : {
    4457          26 :     if (pDocSh)
    4458             :     {
    4459          26 :         OUString aRangeStr;
    4460          26 :         ScDocument& rDoc = pDocSh->GetDocument();
    4461         134 :         for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
    4462             :         {
    4463         108 :             aRangeStr = rRanges[ i ]->Format(SCA_VALID | SCA_TAB_3D, &rDoc);
    4464         108 :             if ( aRangeStr == rName )
    4465             :             {
    4466           0 :                 rIndex = i;
    4467           0 :                 return true;
    4468             :             }
    4469          26 :         }
    4470             :     }
    4471          26 :     return false;   // nicht gefunden
    4472             : }
    4473             : 
    4474          18 : static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
    4475             :                             const ScRangeList& rRanges, ScDocShell* pDocSh,
    4476             :                             const OUString& rName, ScRange& rFound )
    4477             : {
    4478             :     //  exact range in list?
    4479             : 
    4480          18 :     size_t nIndex = 0;
    4481          18 :     if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
    4482             :     {
    4483           0 :         rFound = *rRanges[ nIndex ];
    4484           0 :         return true;
    4485             :     }
    4486             : 
    4487             :     //  range contained in selection? (sheet must be specified)
    4488             : 
    4489          18 :     ScRange aCellRange;
    4490          18 :     sal_uInt16 nParse = aCellRange.ParseAny( rName, &pDocSh->GetDocument() );
    4491          18 :     if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
    4492             :     {
    4493           0 :         ScMarkData aMarkData;
    4494           0 :         aMarkData.MarkFromRangeList( rRanges, false );
    4495           0 :         aMarkData.MarkToMulti();        // needed for IsAllMarked
    4496           0 :         if ( aMarkData.IsAllMarked( aCellRange ) )
    4497             :         {
    4498           0 :             rFound = aCellRange;
    4499           0 :             return true;
    4500           0 :         }
    4501             :     }
    4502             : 
    4503             :     //  named entry in this object?
    4504             : 
    4505          18 :     if ( !rNamedEntries.empty() )
    4506             :     {
    4507          62 :         for ( sal_uInt16 n=0; n<rNamedEntries.size(); n++ )
    4508          56 :             if ( rNamedEntries[n].GetName() == rName )
    4509             :             {
    4510             :                 //  test if named entry is contained in rRanges
    4511             : 
    4512          12 :                 const ScRange& rComp = rNamedEntries[n].GetRange();
    4513          12 :                 ScMarkData aMarkData;
    4514          12 :                 aMarkData.MarkFromRangeList( rRanges, false );
    4515          12 :                 aMarkData.MarkToMulti();        // needed for IsAllMarked
    4516          12 :                 if ( aMarkData.IsAllMarked( rComp ) )
    4517             :                 {
    4518          12 :                     rFound = rComp;
    4519          12 :                     return true;
    4520           0 :                 }
    4521             :             }
    4522             :     }
    4523             : 
    4524           6 :     return false;       // not found
    4525             : }
    4526             : 
    4527           8 : void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
    4528             :                                 throw(container::NoSuchElementException,
    4529             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4530             : {
    4531           8 :     SolarMutexGuard aGuard;
    4532           8 :     bool bDone = false;
    4533          16 :     OUString aNameStr(aName);
    4534           8 :     ScDocShell* pDocSh = GetDocShell();
    4535           8 :     const ScRangeList& rRanges = GetRangeList();
    4536           8 :     size_t nIndex = 0;
    4537           8 :     if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
    4538             :     {
    4539             :         //  einzelnen Range weglassen
    4540           0 :         ScRangeList aNew;
    4541           0 :         for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
    4542           0 :             if (i != nIndex)
    4543           0 :                 aNew.Append( *rRanges[ i ] );
    4544           0 :         SetNewRanges(aNew);
    4545           0 :         bDone = true;
    4546             :     }
    4547           8 :     else if (pDocSh)
    4548             :     {
    4549             :         //  deselect any ranges (parsed or named entry)
    4550           8 :         ScRangeList aDiff;
    4551           8 :         bool bValid = ( aDiff.Parse( aNameStr, &pDocSh->GetDocument() ) & SCA_VALID ) != 0;
    4552           8 :         if (!bValid && !m_pImpl->m_aNamedEntries.empty())
    4553             :         {
    4554           8 :             sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size();
    4555          36 :             for (sal_uInt16 n=0; n<nCount && !bValid; n++)
    4556          28 :                 if (m_pImpl->m_aNamedEntries[n].GetName() == aNameStr)
    4557             :                 {
    4558           6 :                     aDiff.RemoveAll();
    4559           6 :                     aDiff.Append(m_pImpl->m_aNamedEntries[n].GetRange());
    4560           6 :                     bValid = true;
    4561             :                 }
    4562             :         }
    4563           8 :         if ( bValid )
    4564             :         {
    4565           6 :             ScMarkData aMarkData;
    4566           6 :             aMarkData.MarkFromRangeList( rRanges, false );
    4567             : 
    4568          12 :             for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ )
    4569             :             {
    4570           6 :                 ScRange* pDiffRange = aDiff[ i ];
    4571           6 :                 if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
    4572           6 :                     aMarkData.SetMultiMarkArea( *pDiffRange, false );
    4573             :             }
    4574             : 
    4575          12 :             ScRangeList aNew;
    4576           6 :             aMarkData.FillRangeListWithMarks( &aNew, false );
    4577           6 :             SetNewRanges(aNew);
    4578             : 
    4579          12 :             bDone = true;       //! error if range was not selected before?
    4580           8 :         }
    4581             :     }
    4582             : 
    4583           8 :     if (!m_pImpl->m_aNamedEntries.empty())
    4584           8 :         lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aNameStr);
    4585             : 
    4586           8 :     if (!bDone)
    4587          10 :         throw container::NoSuchElementException();      // not found
    4588           6 : }
    4589             : 
    4590             : // XNameReplace
    4591             : 
    4592           4 : void SAL_CALL ScCellRangesObj::replaceByName( const OUString& aName, const uno::Any& aElement )
    4593             :                             throw(lang::IllegalArgumentException, container::NoSuchElementException,
    4594             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4595             : {
    4596           4 :     SolarMutexGuard aGuard;
    4597             :     //! zusammenfassen?
    4598           4 :     removeByName( aName );
    4599           4 :     insertByName( aName, aElement );
    4600           4 : }
    4601             : 
    4602             : // XNameAccess
    4603             : 
    4604          10 : uno::Any SAL_CALL ScCellRangesObj::getByName( const OUString& aName )
    4605             :             throw(container::NoSuchElementException,
    4606             :                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4607             : {
    4608          10 :     SolarMutexGuard aGuard;
    4609          10 :     uno::Any aRet;
    4610             : 
    4611          20 :     OUString aNameStr(aName);
    4612          10 :     ScDocShell* pDocSh = GetDocShell();
    4613          10 :     const ScRangeList& rRanges = GetRangeList();
    4614          10 :     ScRange aRange;
    4615          20 :     if (lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges,
    4616          10 :                 pDocSh, aNameStr, aRange))
    4617             :     {
    4618           8 :         uno::Reference<table::XCellRange> xRange;
    4619           8 :         if ( aRange.aStart == aRange.aEnd )
    4620           0 :             xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
    4621             :         else
    4622           8 :             xRange.set(new ScCellRangeObj( pDocSh, aRange ));
    4623           8 :         aRet <<= xRange;
    4624             :     }
    4625             :     else
    4626           2 :         throw container::NoSuchElementException();
    4627          18 :     return aRet;
    4628             : }
    4629             : 
    4630          44 : static bool lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
    4631             :                         const ScRange& rRange, OUString& rName )
    4632             : {
    4633          44 :     sal_uInt16 nCount = rNamedEntries.size();
    4634         120 :     for (sal_uInt16 i=0; i<nCount; i++)
    4635         120 :         if (rNamedEntries[i].GetRange() == rRange)
    4636             :         {
    4637          44 :             rName = rNamedEntries[i].GetName();
    4638          44 :             return true;
    4639             :         }
    4640           0 :     return false;
    4641             : }
    4642             : 
    4643          10 : uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getElementNames()
    4644             :                                                 throw(uno::RuntimeException, std::exception)
    4645             : {
    4646          10 :     SolarMutexGuard aGuard;
    4647             : 
    4648          10 :     ScDocShell* pDocSh = GetDocShell();
    4649          10 :     const ScRangeList& rRanges = GetRangeList();
    4650          10 :     if (pDocSh)
    4651             :     {
    4652          10 :         OUString aRangeStr;
    4653          10 :         ScDocument& rDoc = pDocSh->GetDocument();
    4654          10 :         size_t nCount = rRanges.size();
    4655             : 
    4656          20 :         uno::Sequence<OUString> aSeq(nCount);
    4657          10 :         OUString* pAry = aSeq.getArray();
    4658          54 :         for (size_t i=0; i < nCount; i++)
    4659             :         {
    4660             :             //  use given name if for exactly this range, otherwise just format
    4661          44 :             ScRange aRange = *rRanges[ i ];
    4662          88 :             if (m_pImpl->m_aNamedEntries.empty() ||
    4663          44 :                 !lcl_FindEntryName(m_pImpl->m_aNamedEntries, aRange, aRangeStr))
    4664             :             {
    4665           0 :                 aRangeStr = aRange.Format(SCA_VALID | SCA_TAB_3D, &rDoc);
    4666             :             }
    4667          44 :             pAry[i] = aRangeStr;
    4668             :         }
    4669          20 :         return aSeq;
    4670             :     }
    4671           0 :     return uno::Sequence<OUString>(0);
    4672             : }
    4673             : 
    4674           8 : sal_Bool SAL_CALL ScCellRangesObj::hasByName( const OUString& aName )
    4675             :                                         throw(uno::RuntimeException, std::exception)
    4676             : {
    4677           8 :     SolarMutexGuard aGuard;
    4678          16 :     OUString aNameStr(aName);
    4679           8 :     ScDocShell* pDocSh = GetDocShell();
    4680           8 :     const ScRangeList& rRanges = GetRangeList();
    4681           8 :     ScRange aRange;
    4682           8 :     return lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, pDocSh,
    4683          16 :                 aNameStr, aRange);
    4684             : }
    4685             : 
    4686             : // XEnumerationAccess
    4687             : 
    4688         104 : uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
    4689             :                                                     throw(uno::RuntimeException, std::exception)
    4690             : {
    4691         104 :     SolarMutexGuard aGuard;
    4692         104 :     return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.SheetCellRangesEnumeration"));
    4693             : }
    4694             : 
    4695             : // XIndexAccess
    4696             : 
    4697        1034 : sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException, std::exception)
    4698             : {
    4699        1034 :     SolarMutexGuard aGuard;
    4700        1034 :     const ScRangeList& rRanges = GetRangeList();
    4701        1034 :     return rRanges.size();
    4702             : }
    4703             : 
    4704         958 : uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
    4705             :                             throw(lang::IndexOutOfBoundsException,
    4706             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4707             : {
    4708         958 :     SolarMutexGuard aGuard;
    4709        1916 :     uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
    4710         958 :     if (xRange.is())
    4711        1908 :         return uno::makeAny(xRange);
    4712             :     else
    4713         962 :         throw lang::IndexOutOfBoundsException();
    4714             : }
    4715             : 
    4716           2 : uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException, std::exception)
    4717             : {
    4718           2 :     SolarMutexGuard aGuard;
    4719           2 :     return cppu::UnoType<table::XCellRange>::get();
    4720             : }
    4721             : 
    4722          98 : sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException, std::exception)
    4723             : {
    4724          98 :     SolarMutexGuard aGuard;
    4725          98 :     const ScRangeList& rRanges = GetRangeList();
    4726          98 :     return !rRanges.empty();
    4727             : }
    4728             : 
    4729             : // XServiceInfo
    4730           8 : OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    4731             : {
    4732           8 :     return OUString( "ScCellRangesObj" );
    4733             : }
    4734             : 
    4735          24 : sal_Bool SAL_CALL ScCellRangesObj::supportsService( const OUString& rServiceName )
    4736             :                                                     throw(uno::RuntimeException, std::exception)
    4737             : {
    4738          24 :     return cppu::supportsService(this, rServiceName);
    4739             : }
    4740             : 
    4741          24 : uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
    4742             :                                                     throw(uno::RuntimeException, std::exception)
    4743             : {
    4744          24 :     uno::Sequence<OUString> aRet(4);
    4745          24 :     OUString* pArray = aRet.getArray();
    4746          24 :     pArray[0] = OUString( SCSHEETCELLRANGES_SERVICE );
    4747          24 :     pArray[1] = OUString( SCCELLPROPERTIES_SERVICE );
    4748          24 :     pArray[2] = OUString( SCCHARPROPERTIES_SERVICE );
    4749          24 :     pArray[3] = OUString( SCPARAPROPERTIES_SERVICE );
    4750          24 :     return aRet;
    4751             : }
    4752             : 
    4753           0 : uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
    4754             : {
    4755           0 :     SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
    4756           0 :     if ( pObjSh && pObjSh->ISA(ScDocShell) )
    4757           0 :         return new ScCellRangeObj( static_cast<ScDocShell*>(pObjSh), rR );
    4758           0 :     return NULL;
    4759             : }
    4760             : 
    4761       49422 : ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
    4762             :     ScCellRangesBase( pDocSh, rR ),
    4763       49422 :     pRangePropSet( lcl_GetRangePropertySet() ),
    4764       98844 :     aRange( rR )
    4765             : {
    4766       49422 :     aRange.Justify();       // Anfang / Ende richtig
    4767       49422 : }
    4768             : 
    4769       63644 : ScCellRangeObj::~ScCellRangeObj()
    4770             : {
    4771       63644 : }
    4772             : 
    4773        6456 : void ScCellRangeObj::RefChanged()
    4774             : {
    4775        6456 :     ScCellRangesBase::RefChanged();
    4776             : 
    4777        6456 :     const ScRangeList& rRanges = GetRangeList();
    4778             :     OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
    4779        6456 :     if ( !rRanges.empty() )
    4780             :     {
    4781        6404 :         const ScRange* pFirst = rRanges[0];
    4782        6404 :         aRange = ScRange(*pFirst);
    4783        6404 :         aRange.Justify();
    4784             :     }
    4785        6456 : }
    4786             : 
    4787      445748 : uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
    4788             :                                                 throw(uno::RuntimeException, std::exception)
    4789             : {
    4790      445748 :     SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
    4791      435668 :     SC_QUERYINTERFACE( table::XCellRange )
    4792      419148 :     SC_QUERYINTERFACE( sheet::XSheetCellRange )
    4793      414006 :     SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
    4794      414002 :     SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
    4795      414002 :     SC_QUERYINTERFACE( sheet::XCellRangeData )
    4796      413954 :     SC_QUERYINTERFACE( sheet::XCellRangeFormula )
    4797      413950 :     SC_QUERYINTERFACE( sheet::XMultipleOperation )
    4798      413948 :     SC_QUERYINTERFACE( util::XMergeable )
    4799      413932 :     SC_QUERYINTERFACE( sheet::XCellSeries )
    4800      413912 :     SC_QUERYINTERFACE( table::XAutoFormattable )
    4801      413912 :     SC_QUERYINTERFACE( util::XSortable )
    4802      413910 :     SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
    4803      413908 :     SC_QUERYINTERFACE( sheet::XSheetFilterable )
    4804      413904 :     SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
    4805      413892 :     SC_QUERYINTERFACE( table::XColumnRowRange )
    4806      403650 :     SC_QUERYINTERFACE( util::XImportable )
    4807      403644 :     SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
    4808      403638 :     SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
    4809             : 
    4810      403576 :     return ScCellRangesBase::queryInterface( rType );
    4811             : }
    4812             : 
    4813     1437552 : void SAL_CALL ScCellRangeObj::acquire() throw()
    4814             : {
    4815     1437552 :     ScCellRangesBase::acquire();
    4816     1437552 : }
    4817             : 
    4818     1437342 : void SAL_CALL ScCellRangeObj::release() throw()
    4819             : {
    4820     1437342 :     ScCellRangesBase::release();
    4821     1437342 : }
    4822             : 
    4823          10 : uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException, std::exception)
    4824             : {
    4825          10 :     static uno::Sequence<uno::Type> aTypes;
    4826          10 :     if ( aTypes.getLength() == 0 )
    4827             :     {
    4828           4 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
    4829           4 :         long nParentLen = aParentTypes.getLength();
    4830           4 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    4831             : 
    4832           4 :         aTypes.realloc( nParentLen + 17 );
    4833           4 :         uno::Type* pPtr = aTypes.getArray();
    4834           4 :         pPtr[nParentLen + 0] = cppu::UnoType<sheet::XCellRangeAddressable>::get();
    4835           4 :         pPtr[nParentLen + 1] = cppu::UnoType<sheet::XSheetCellRange>::get();
    4836           4 :         pPtr[nParentLen + 2] = cppu::UnoType<sheet::XArrayFormulaRange>::get();
    4837           4 :         pPtr[nParentLen + 3] = cppu::UnoType<sheet::XArrayFormulaTokens>::get();
    4838           4 :         pPtr[nParentLen + 4] = cppu::UnoType<sheet::XCellRangeData>::get();
    4839           4 :         pPtr[nParentLen + 5] = cppu::UnoType<sheet::XCellRangeFormula>::get();
    4840           4 :         pPtr[nParentLen + 6] = cppu::UnoType<sheet::XMultipleOperation>::get();
    4841           4 :         pPtr[nParentLen + 7] = cppu::UnoType<util::XMergeable>::get();
    4842           4 :         pPtr[nParentLen + 8] = cppu::UnoType<sheet::XCellSeries>::get();
    4843           4 :         pPtr[nParentLen + 9] = cppu::UnoType<table::XAutoFormattable>::get();
    4844           4 :         pPtr[nParentLen +10] = cppu::UnoType<util::XSortable>::get();
    4845           4 :         pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetFilterableEx>::get();
    4846           4 :         pPtr[nParentLen +12] = cppu::UnoType<sheet::XSubTotalCalculatable>::get();
    4847           4 :         pPtr[nParentLen +13] = cppu::UnoType<table::XColumnRowRange>::get();
    4848           4 :         pPtr[nParentLen +14] = cppu::UnoType<util::XImportable>::get();
    4849           4 :         pPtr[nParentLen +15] = cppu::UnoType<sheet::XCellFormatRangesSupplier>::get();
    4850           4 :         pPtr[nParentLen +16] = cppu::UnoType<sheet::XUniqueCellFormatRangesSupplier>::get();
    4851             : 
    4852          56 :         for (long i=0; i<nParentLen; i++)
    4853          56 :             pPtr[i] = pParentPtr[i];                // parent types first
    4854             :     }
    4855          10 :     return aTypes;
    4856             : }
    4857             : 
    4858           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
    4859             :                                                     throw(uno::RuntimeException, std::exception)
    4860             : {
    4861           0 :     return css::uno::Sequence<sal_Int8>();
    4862             : }
    4863             : 
    4864             : // XCellRange
    4865             : 
    4866             : //  ColumnCount / RowCount sind weggefallen
    4867             : //! werden im Writer fuer Tabellen noch gebraucht ???
    4868             : 
    4869       24620 : uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
    4870             :                                         sal_Int32 nColumn, sal_Int32 nRow )
    4871             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
    4872             : {
    4873       24620 :     ScDocShell* pDocSh = GetDocShell();
    4874       24620 :     if (!pDocSh)
    4875           0 :         throw uno::RuntimeException();
    4876             : 
    4877       24620 :     if ( nColumn >= 0 && nRow >= 0 )
    4878             :     {
    4879       24618 :         sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
    4880       24618 :         sal_Int32 nPosY = aRange.aStart.Row() + nRow;
    4881             : 
    4882       24618 :         if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
    4883             :         {
    4884       24618 :             ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
    4885       49236 :             return new ScCellObj( pDocSh, aNew );
    4886             :         }
    4887             :     }
    4888             : 
    4889           2 :     throw lang::IndexOutOfBoundsException();
    4890             : }
    4891             : 
    4892       16408 : uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
    4893             :                                         sal_Int32 nColumn, sal_Int32 nRow )
    4894             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    4895             : {
    4896       16408 :     SolarMutexGuard aGuard;
    4897             : 
    4898       16408 :     return GetCellByPosition_Impl(nColumn, nRow);
    4899             : }
    4900             : 
    4901       11554 : uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
    4902             :                 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
    4903             :                                     throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    4904             : {
    4905       11554 :     SolarMutexGuard aGuard;
    4906             : 
    4907       11554 :     ScDocShell* pDocSh = GetDocShell();
    4908       11554 :     if (!pDocSh)
    4909           0 :         throw uno::RuntimeException();
    4910             : 
    4911       11554 :     if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
    4912             :     {
    4913       11552 :         sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
    4914       11552 :         sal_Int32 nStartY = aRange.aStart.Row() + nTop;
    4915       11552 :         sal_Int32 nEndX = aRange.aStart.Col() + nRight;
    4916       11552 :         sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
    4917             : 
    4918       23104 :         if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
    4919       23104 :              nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
    4920             :         {
    4921       11552 :             ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
    4922       23104 :                           (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
    4923       23104 :             return new ScCellRangeObj( pDocSh, aNew );
    4924             :         }
    4925             :     }
    4926             : 
    4927       11552 :     throw lang::IndexOutOfBoundsException();
    4928             : }
    4929             : 
    4930         188 : uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
    4931             :                         const OUString& aName ) throw(uno::RuntimeException, std::exception)
    4932             : {
    4933         188 :     return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
    4934             : }
    4935             : 
    4936         188 : uno::Reference<table::XCellRange>  ScCellRangeObj::getCellRangeByName(
    4937             :                         const OUString& aName, const ScAddress::Details& rDetails  ) throw(uno::RuntimeException)
    4938             : {
    4939             :     //  name refers to the whole document (with the range's table as default),
    4940             :     //  valid only if the range is within this range
    4941             : 
    4942         188 :     SolarMutexGuard aGuard;
    4943         188 :     ScDocShell* pDocSh = GetDocShell();
    4944         188 :     if ( pDocSh )
    4945             :     {
    4946         188 :         ScDocument& rDoc = pDocSh->GetDocument();
    4947         188 :         SCTAB nTab = aRange.aStart.Tab();
    4948             : 
    4949         188 :         ScRange aCellRange;
    4950         188 :         bool bFound = false;
    4951         188 :         OUString aString(aName);
    4952         188 :         sal_uInt16 nParse = aCellRange.ParseAny( aString, &rDoc, rDetails );
    4953         188 :         if ( nParse & SCA_VALID )
    4954             :         {
    4955         188 :             if ( !(nParse & SCA_TAB_3D) )   // keine Tabelle angegeben -> auf dieser Tabelle
    4956             :             {
    4957         122 :                 aCellRange.aStart.SetTab(nTab);
    4958         122 :                 aCellRange.aEnd.SetTab(nTab);
    4959             :             }
    4960         188 :             bFound = true;
    4961             :         }
    4962             :         else
    4963             :         {
    4964           0 :             ScRangeUtil aRangeUtil;
    4965           0 :             if ( aRangeUtil.MakeRangeFromName( aString, &rDoc, nTab, aCellRange, RUTL_NAMES ) ||
    4966           0 :                  aRangeUtil.MakeRangeFromName( aString, &rDoc, nTab, aCellRange, RUTL_DBASE ) )
    4967           0 :                 bFound = true;
    4968             :         }
    4969             : 
    4970         188 :         if (bFound)         // valid only if within this object's range
    4971             :         {
    4972         188 :             if (!aRange.In(aCellRange))
    4973           0 :                 bFound = false;
    4974             :         }
    4975             : 
    4976         188 :         if (bFound)
    4977             :         {
    4978         188 :             if ( aCellRange.aStart == aCellRange.aEnd )
    4979           8 :                 return new ScCellObj( pDocSh, aCellRange.aStart );
    4980             :             else
    4981         180 :                 return new ScCellRangeObj( pDocSh, aCellRange );
    4982           0 :         }
    4983             :     }
    4984             : 
    4985         188 :     throw uno::RuntimeException();
    4986             : }
    4987             : 
    4988             : // XColumnRowRange
    4989             : 
    4990        2700 : uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException, std::exception)
    4991             : {
    4992        2700 :     SolarMutexGuard aGuard;
    4993        2700 :     ScDocShell* pDocSh = GetDocShell();
    4994        2700 :     if (pDocSh)
    4995        2700 :         return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
    4996        2700 :                                         aRange.aStart.Col(), aRange.aEnd.Col() );
    4997             : 
    4998             :     OSL_FAIL("Dokument ungueltig");
    4999           0 :     return NULL;
    5000             : }
    5001             : 
    5002        6910 : uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException, std::exception)
    5003             : {
    5004        6910 :     SolarMutexGuard aGuard;
    5005        6910 :     ScDocShell* pDocSh = GetDocShell();
    5006        6910 :     if (pDocSh)
    5007        6910 :         return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
    5008        6910 :                                     aRange.aStart.Row(), aRange.aEnd.Row() );
    5009             : 
    5010             :     OSL_FAIL("Dokument ungueltig");
    5011           0 :     return NULL;
    5012             : }
    5013             : 
    5014             : // XAddressableCellRange
    5015             : 
    5016       11580 : table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException, std::exception)
    5017             : {
    5018       11580 :     SolarMutexGuard aGuard;
    5019       11580 :     table::CellRangeAddress aRet;
    5020       11580 :     ScUnoConversion::FillApiRange( aRet, aRange );
    5021       11580 :     return aRet;
    5022             : }
    5023             : 
    5024             : // XSheetCellRange
    5025             : 
    5026        2128 : uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
    5027             :                                                 throw(uno::RuntimeException, std::exception)
    5028             : {
    5029        2128 :     SolarMutexGuard aGuard;
    5030        2128 :     ScDocShell* pDocSh = GetDocShell();
    5031        2128 :     if (pDocSh)
    5032        2128 :         return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
    5033             : 
    5034             :     OSL_FAIL("Dokument ungueltig");
    5035           0 :     return NULL;
    5036             : }
    5037             : 
    5038             : // XArrayFormulaRange
    5039             : 
    5040           4 : OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException, std::exception)
    5041             : {
    5042           4 :     SolarMutexGuard aGuard;
    5043             : 
    5044             :     //  Matrix-Formel, wenn eindeutig Teil einer Matrix,
    5045             :     //  also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
    5046             :     //  Sonst Leerstring.
    5047             : 
    5048           4 :     ScDocShell* pDocSh = GetDocShell();
    5049           4 :     if (!pDocSh)
    5050           0 :         return EMPTY_OUSTRING;
    5051             : 
    5052           8 :     OUString aFormula;
    5053             : 
    5054           4 :     ScDocument& rDoc = pDocSh->GetDocument();
    5055           8 :     ScRefCellValue aCell1;
    5056           8 :     ScRefCellValue aCell2;
    5057           4 :     aCell1.assign(rDoc, aRange.aStart);
    5058           4 :     aCell2.assign(rDoc, aRange.aEnd);
    5059           4 :     if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
    5060             :     {
    5061           2 :         const ScFormulaCell* pFCell1 = aCell1.mpFormula;
    5062           2 :         const ScFormulaCell* pFCell2 = aCell2.mpFormula;
    5063           2 :         ScAddress aStart1;
    5064           2 :         ScAddress aStart2;
    5065           2 :         if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
    5066             :         {
    5067           2 :             if (aStart1 == aStart2)               // beides dieselbe Matrix
    5068           2 :                 pFCell1->GetFormula(aFormula);    // egal, von welcher Zelle
    5069             :         }
    5070             :     }
    5071           8 :     return aFormula;
    5072             : }
    5073             : 
    5074           2 : void ScCellRangeObj::SetArrayFormula_Impl(const OUString& rFormula,
    5075             :     const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar)
    5076             :         throw (uno::RuntimeException, std::exception)
    5077             : {
    5078           2 :     ScDocShell* pDocSh = GetDocShell();
    5079           2 :     if (pDocSh)
    5080             :     {
    5081           2 :         if ( !rFormula.isEmpty() )
    5082             :         {
    5083           2 :             if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5084             :             {
    5085             :                 //  don't set array formula for sheet object
    5086           0 :                 throw uno::RuntimeException();
    5087             :             }
    5088             : 
    5089           2 :             pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, NULL, rFormula, true, true, rFormulaNmsp, eGrammar );
    5090             :         }
    5091             :         else
    5092             :         {
    5093             :             //  empty string -> erase array formula
    5094           0 :             ScMarkData aMark;
    5095           0 :             aMark.SetMarkArea( aRange );
    5096           0 :             aMark.SelectTable( aRange.aStart.Tab(), true );
    5097           0 :             pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
    5098             :         }
    5099             :     }
    5100           2 : }
    5101             : 
    5102           2 : void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula )
    5103             :                                                 throw(uno::RuntimeException, std::exception)
    5104             : {
    5105           2 :     SolarMutexGuard aGuard;
    5106             :     // GRAM_PODF_A1 for API compatibility.
    5107           2 :     SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
    5108           2 : }
    5109             : 
    5110           0 : void ScCellRangeObj::SetArrayFormulaWithGrammar(const OUString& rFormula,
    5111             :     const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar)
    5112             :         throw (uno::RuntimeException, std::exception)
    5113             : {
    5114           0 :     SolarMutexGuard aGuard;
    5115           0 :     SetArrayFormula_Impl( rFormula, rFormulaNmsp, eGrammar);
    5116           0 : }
    5117             : 
    5118             : // XArrayFormulaTokens
    5119             : 
    5120           0 : uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens()
    5121             :     throw (uno::RuntimeException, std::exception)
    5122             : {
    5123           0 :     SolarMutexGuard aGuard;
    5124             : 
    5125             :     // same cell logic as in getArrayFormula
    5126             : 
    5127           0 :     uno::Sequence<sheet::FormulaToken> aSequence;
    5128           0 :     ScDocShell* pDocSh = GetDocShell();
    5129           0 :     if (!pDocSh)
    5130           0 :         return aSequence;
    5131             : 
    5132           0 :     ScDocument& rDoc = pDocSh->GetDocument();
    5133           0 :     ScRefCellValue aCell1;
    5134           0 :     ScRefCellValue aCell2;
    5135           0 :     aCell1.assign(rDoc, aRange.aStart);
    5136           0 :     aCell2.assign(rDoc, aRange.aEnd);
    5137           0 :     if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
    5138             :     {
    5139           0 :         const ScFormulaCell* pFCell1 = aCell1.mpFormula;
    5140           0 :         const ScFormulaCell* pFCell2 = aCell2.mpFormula;
    5141           0 :         ScAddress aStart1;
    5142           0 :         ScAddress aStart2;
    5143           0 :         if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
    5144             :         {
    5145           0 :             if (aStart1 == aStart2)
    5146             :             {
    5147           0 :                 const ScTokenArray* pTokenArray = pFCell1->GetCode();
    5148           0 :                 if (pTokenArray)
    5149           0 :                     (void)ScTokenConversion::ConvertToTokenSequence(rDoc, aSequence, *pTokenArray);
    5150             :             }
    5151             :         }
    5152             :     }
    5153             : 
    5154           0 :     return aSequence;
    5155             : }
    5156             : 
    5157           0 : void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
    5158             : {
    5159           0 :     SolarMutexGuard aGuard;
    5160           0 :     ScDocShell* pDocSh = GetDocShell();
    5161           0 :     if ( pDocSh )
    5162             :     {
    5163           0 :         if ( rTokens.getLength() )
    5164             :         {
    5165           0 :             if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5166             :             {
    5167           0 :                 throw uno::RuntimeException();
    5168             :             }
    5169             : 
    5170           0 :             ScDocument& rDoc = pDocSh->GetDocument();
    5171           0 :             ScTokenArray aTokenArray;
    5172           0 :             (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
    5173             : 
    5174             :             // Actually GRAM_PODF_A1 is a don't-care here because of the token
    5175             :             // array being set, it fits with other API compatibility grammars
    5176             :             // though.
    5177           0 :             pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_OUSTRING, true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 );
    5178             :         }
    5179             :         else
    5180             :         {
    5181             :             //  empty sequence -> erase array formula
    5182           0 :             ScMarkData aMark;
    5183           0 :             aMark.SetMarkArea( aRange );
    5184           0 :             aMark.SelectTable( aRange.aStart.Tab(), true );
    5185           0 :             pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
    5186             :         }
    5187           0 :     }
    5188           0 : }
    5189             : 
    5190             : // XCellRangeData
    5191             : 
    5192          34 : uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
    5193             :                                     throw(uno::RuntimeException, std::exception)
    5194             : {
    5195          34 :     SolarMutexGuard aGuard;
    5196             : 
    5197          34 :     if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5198             :     {
    5199             :         //  don't create a data array for the sheet
    5200           0 :         throw uno::RuntimeException();
    5201             :     }
    5202             : 
    5203          34 :     ScDocShell* pDocSh = GetDocShell();
    5204          34 :     if (pDocSh)
    5205             :     {
    5206          34 :         uno::Any aAny;
    5207             :         // bAllowNV = TRUE: errors as void
    5208          34 :         if ( ScRangeToSequence::FillMixedArray( aAny, &pDocSh->GetDocument(), aRange, true ) )
    5209             :         {
    5210          34 :             uno::Sequence< uno::Sequence<uno::Any> > aSeq;
    5211          34 :             if ( aAny >>= aSeq )
    5212          68 :                 return aSeq;            // success
    5213           0 :         }
    5214             :     }
    5215             : 
    5216          34 :     throw uno::RuntimeException();      // no other exceptions specified
    5217             : }
    5218             : 
    5219          16 : void SAL_CALL ScCellRangeObj::setDataArray(
    5220             :                         const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
    5221             :                                     throw(uno::RuntimeException, std::exception)
    5222             : {
    5223          16 :     SolarMutexGuard aGuard;
    5224             : 
    5225          16 :     bool bDone = false;
    5226          16 :     ScDocShell* pDocSh = GetDocShell();
    5227          16 :     if (pDocSh)
    5228             :     {
    5229             :         //! move lcl_PutDataArray to docfunc?
    5230          16 :         bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
    5231             :     }
    5232             : 
    5233          16 :     if (!bDone)
    5234           0 :         throw uno::RuntimeException();      // no other exceptions specified
    5235          16 : }
    5236             : 
    5237             : // XCellRangeFormula
    5238             : 
    5239          10 : uno::Sequence< uno::Sequence<OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
    5240             :                                     throw(uno::RuntimeException, std::exception)
    5241             : {
    5242          10 :     SolarMutexGuard aGuard;
    5243             : 
    5244          10 :     if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
    5245             :     {
    5246             :         //  don't create a data array for the sheet
    5247           0 :         throw uno::RuntimeException();
    5248             :     }
    5249             : 
    5250          10 :     ScDocShell* pDocSh = GetDocShell();
    5251          10 :     if (pDocSh)
    5252             :     {
    5253          10 :         SCCOL nStartCol = aRange.aStart.Col();
    5254          10 :         SCROW nStartRow = aRange.aStart.Row();
    5255          10 :         SCCOL nEndCol = aRange.aEnd.Col();
    5256          10 :         SCROW nEndRow = aRange.aEnd.Row();
    5257          10 :         SCCOL nColCount = nEndCol + 1 - nStartCol;
    5258          10 :         SCROW nRowCount = nEndRow + 1 - nStartRow;
    5259          10 :         SCTAB nTab = aRange.aStart.Tab();
    5260             : 
    5261          10 :         uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount );
    5262          10 :         uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
    5263          60 :         for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
    5264             :         {
    5265          50 :             uno::Sequence<OUString> aColSeq( nColCount );
    5266          50 :             OUString* pColAry = aColSeq.getArray();
    5267         240 :             for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
    5268         380 :                 pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
    5269         190 :                                     ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), true );
    5270             : 
    5271          50 :             pRowAry[nRowIndex] = aColSeq;
    5272          50 :         }
    5273             : 
    5274          20 :         return aRowSeq;
    5275             :     }
    5276             : 
    5277          10 :     throw uno::RuntimeException();      // no other exceptions specified
    5278             : }
    5279             : 
    5280           4 : void SAL_CALL ScCellRangeObj::setFormulaArray(
    5281             :                         const uno::Sequence< uno::Sequence<OUString> >& aArray )
    5282             :                                     throw(uno::RuntimeException, std::exception)
    5283             : {
    5284           4 :     SolarMutexGuard aGuard;
    5285             : 
    5286           4 :     bool bDone = false;
    5287           4 :     ScDocShell* pDocSh = GetDocShell();
    5288           4 :     if (pDocSh)
    5289             :     {
    5290           4 :         ScExternalRefManager::ApiGuard aExtRefGuard(&pDocSh->GetDocument());
    5291             : 
    5292             :         // GRAM_PODF_A1 for API compatibility.
    5293           4 :         bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_PODF_A1 );
    5294             :     }
    5295             : 
    5296           4 :     if (!bDone)
    5297           0 :         throw uno::RuntimeException();      // no other exceptions specified
    5298           4 : }
    5299             : 
    5300             : // XMultipleOperation
    5301             : 
    5302           6 : void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
    5303             :                                         sheet::TableOperationMode nMode,
    5304             :                                         const table::CellAddress& aColumnCell,
    5305             :                                         const table::CellAddress& aRowCell )
    5306             :                                     throw(uno::RuntimeException, std::exception)
    5307             : {
    5308           6 :     SolarMutexGuard aGuard;
    5309           6 :     ScDocShell* pDocSh = GetDocShell();
    5310           6 :     if (pDocSh)
    5311             :     {
    5312           6 :         bool bError = false;
    5313           6 :         ScTabOpParam aParam;
    5314          12 :         aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
    5315             :                                               (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
    5316           6 :                                               false, false, false );
    5317          12 :         aParam.aRefFormulaEnd  = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
    5318             :                                               (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
    5319           6 :                                               false, false, false );
    5320          12 :         aParam.aRefRowCell     = ScRefAddress( (SCCOL)aRowCell.Column,
    5321             :                                               (SCROW)aRowCell.Row, aRowCell.Sheet,
    5322           6 :                                               false, false, false );
    5323          12 :         aParam.aRefColCell     = ScRefAddress( (SCCOL)aColumnCell.Column,
    5324             :                                               (SCROW)aColumnCell.Row, aColumnCell.Sheet,
    5325           6 :                                               false, false, false );
    5326             : 
    5327           6 :         switch (nMode)
    5328             :         {
    5329             :             case sheet::TableOperationMode_COLUMN:
    5330           2 :                 aParam.meMode = ScTabOpParam::Column;
    5331           2 :                 break;
    5332             :             case sheet::TableOperationMode_ROW:
    5333           2 :                 aParam.meMode = ScTabOpParam::Row;
    5334           2 :                 break;
    5335             :             case sheet::TableOperationMode_BOTH:
    5336           2 :                 aParam.meMode = ScTabOpParam::Both;
    5337           2 :                 break;
    5338             :             default:
    5339           0 :                 bError = true;
    5340             :         }
    5341             : 
    5342           6 :         if (!bError)
    5343           6 :             pDocSh->GetDocFunc().TabOp( aRange, NULL, aParam, true, true );
    5344           6 :     }
    5345           6 : }
    5346             : 
    5347             : // XMergeable
    5348             : 
    5349          20 : void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException, std::exception)
    5350             : {
    5351          20 :     SolarMutexGuard aGuard;
    5352          20 :     ScDocShell* pDocSh = GetDocShell();
    5353          20 :     if ( pDocSh )
    5354             :     {
    5355             :         ScCellMergeOption aMergeOption(
    5356          20 :             aRange.aStart.Col(), aRange.aStart.Row(),
    5357          40 :             aRange.aEnd.Col(), aRange.aEnd.Row(), false);
    5358          20 :         aMergeOption.maTabs.insert(aRange.aStart.Tab());
    5359          20 :         if ( bMerge )
    5360          10 :             pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
    5361             :         else
    5362          10 :             pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true );
    5363             : 
    5364             :         //! Fehler abfangen?
    5365          20 :     }
    5366          20 : }
    5367             : 
    5368           8 : sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException, std::exception)
    5369             : {
    5370           8 :     SolarMutexGuard aGuard;
    5371           8 :     ScDocShell* pDocSh = GetDocShell();
    5372           8 :     return pDocSh && pDocSh->GetDocument().HasAttrib( aRange, HASATTR_MERGED );
    5373             : }
    5374             : 
    5375             : // XCellSeries
    5376             : 
    5377          26 : void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
    5378             :                         sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
    5379             :                         double fStep, double fEndValue ) throw(uno::RuntimeException, std::exception)
    5380             : {
    5381          26 :     SolarMutexGuard aGuard;
    5382          26 :     ScDocShell* pDocSh = GetDocShell();
    5383          26 :     if ( pDocSh )
    5384             :     {
    5385          26 :         bool bError = false;
    5386             : 
    5387          26 :         FillDir eDir = FILL_TO_BOTTOM;
    5388          26 :         switch (nFillDirection)
    5389             :         {
    5390             :             case sheet::FillDirection_TO_BOTTOM:
    5391           8 :                 eDir = FILL_TO_BOTTOM;
    5392           8 :                 break;
    5393             :             case sheet::FillDirection_TO_RIGHT:
    5394          10 :                 eDir = FILL_TO_RIGHT;
    5395          10 :                 break;
    5396             :             case sheet::FillDirection_TO_TOP:
    5397           4 :                 eDir = FILL_TO_TOP;
    5398           4 :                 break;
    5399             :             case sheet::FillDirection_TO_LEFT:
    5400           4 :                 eDir = FILL_TO_LEFT;
    5401           4 :                 break;
    5402             :             default:
    5403           0 :                 bError = true;
    5404             :         }
    5405             : 
    5406          26 :         FillCmd eCmd = FILL_SIMPLE;
    5407          26 :         switch ( nFillMode )
    5408             :         {
    5409             :             case sheet::FillMode_SIMPLE:
    5410          18 :                 eCmd = FILL_SIMPLE;
    5411          18 :                 break;
    5412             :             case sheet::FillMode_LINEAR:
    5413           4 :                 eCmd = FILL_LINEAR;
    5414           4 :                 break;
    5415             :             case sheet::FillMode_GROWTH:
    5416           4 :                 eCmd = FILL_GROWTH;
    5417           4 :                 break;
    5418             :             case sheet::FillMode_DATE:
    5419           0 :                 eCmd = FILL_DATE;
    5420           0 :                 break;
    5421             :             case sheet::FillMode_AUTO:
    5422           0 :                 eCmd = FILL_AUTO;
    5423           0 :                 break;
    5424             :             default:
    5425           0 :                 bError = true;
    5426             :         }
    5427             : 
    5428          26 :         FillDateCmd eDateCmd = FILL_DAY;
    5429          26 :         switch ( nFillDateMode )
    5430             :         {
    5431             :             case sheet::FillDateMode_FILL_DATE_DAY:
    5432          26 :                 eDateCmd = FILL_DAY;
    5433          26 :                 break;
    5434             :             case sheet::FillDateMode_FILL_DATE_WEEKDAY:
    5435           0 :                 eDateCmd = FILL_WEEKDAY;
    5436           0 :                 break;
    5437             :             case sheet::FillDateMode_FILL_DATE_MONTH:
    5438           0 :                 eDateCmd = FILL_MONTH;
    5439           0 :                 break;
    5440             :             case sheet::FillDateMode_FILL_DATE_YEAR:
    5441           0 :                 eDateCmd = FILL_YEAR;
    5442           0 :                 break;
    5443             :             default:
    5444           0 :                 bError = true;
    5445             :         }
    5446             : 
    5447          26 :         if (!bError)
    5448          26 :             pDocSh->GetDocFunc().FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
    5449          52 :                                                 MAXDOUBLE, fStep, fEndValue, true, true );
    5450          26 :     }
    5451          26 : }
    5452             : 
    5453           4 : void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
    5454             :                                 sal_Int32 nSourceCount ) throw(uno::RuntimeException, std::exception)
    5455             : {
    5456           4 :     SolarMutexGuard aGuard;
    5457           4 :     ScDocShell* pDocSh = GetDocShell();
    5458           4 :     if ( pDocSh && nSourceCount )
    5459             :     {
    5460           4 :         ScRange aSourceRange(aRange);
    5461           4 :         SCsCOLROW nCount = 0;                   // "Dest-Count"
    5462           4 :         FillDir eDir = FILL_TO_BOTTOM;
    5463           4 :         bool bError = false;
    5464           4 :         switch (nFillDirection)
    5465             :         {
    5466             :             case sheet::FillDirection_TO_BOTTOM:
    5467           2 :                 aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
    5468           2 :                 nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
    5469           2 :                 eDir = FILL_TO_BOTTOM;
    5470           2 :                 break;
    5471             :             case sheet::FillDirection_TO_RIGHT:
    5472           2 :                 aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
    5473           2 :                 nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
    5474           2 :                 eDir = FILL_TO_RIGHT;
    5475           2 :                 break;
    5476             :             case sheet::FillDirection_TO_TOP:
    5477           0 :                 aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
    5478           0 :                 nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
    5479           0 :                 eDir = FILL_TO_TOP;
    5480           0 :                 break;
    5481             :             case sheet::FillDirection_TO_LEFT:
    5482           0 :                 aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
    5483           0 :                 nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
    5484           0 :                 eDir = FILL_TO_LEFT;
    5485           0 :                 break;
    5486             :             default:
    5487           0 :                 bError = true;
    5488             :         }
    5489           4 :         if (nCount < 0 || nCount > MAXROW)      // overflow
    5490           0 :             bError = true;
    5491             : 
    5492           4 :         if (!bError)
    5493           4 :             pDocSh->GetDocFunc().FillAuto( aSourceRange, NULL, eDir, nCount, true, true );
    5494           4 :     }
    5495           4 : }
    5496             : 
    5497             : // XAutoFormattable
    5498             : 
    5499           0 : void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName )
    5500             :                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    5501             : {
    5502           0 :     SolarMutexGuard aGuard;
    5503           0 :     ScDocShell* pDocSh = GetDocShell();
    5504           0 :     if ( pDocSh )
    5505             :     {
    5506           0 :         ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
    5507           0 :         ScAutoFormat::const_iterator it = pAutoFormat->find(aName);
    5508           0 :         if (it != pAutoFormat->end())
    5509             :         {
    5510           0 :             ScAutoFormat::const_iterator itBeg = pAutoFormat->begin();
    5511           0 :             size_t nIndex = std::distance(itBeg, it);
    5512           0 :             pDocSh->GetDocFunc().AutoFormat(aRange, NULL, nIndex, true, true);
    5513             :         }
    5514             :         else
    5515           0 :             throw lang::IllegalArgumentException();
    5516           0 :     }
    5517           0 : }
    5518             : 
    5519             : // XSortable
    5520             : 
    5521           2 : uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
    5522             :                                                 throw(uno::RuntimeException, std::exception)
    5523             : {
    5524           2 :     SolarMutexGuard aGuard;
    5525           4 :     ScSortParam aParam;
    5526           2 :     ScDocShell* pDocSh = GetDocShell();
    5527           2 :     if ( pDocSh )
    5528             :     {
    5529             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5530           2 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5531           2 :         if (pData)
    5532             :         {
    5533           0 :             pData->GetSortParam(aParam);
    5534             : 
    5535             :             //  im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5536           0 :             ScRange aDBRange;
    5537           0 :             pData->GetArea(aDBRange);
    5538             :             SCCOLROW nFieldStart = aParam.bByRow ?
    5539           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
    5540           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Row());
    5541           0 :             for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
    5542           0 :                 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
    5543           0 :                     aParam.maKeyState[i].nField -= nFieldStart;
    5544             :         }
    5545             :     }
    5546             : 
    5547           2 :     uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
    5548           2 :     ScSortDescriptor::FillProperties( aSeq, aParam );
    5549           4 :     return aSeq;
    5550             : }
    5551             : 
    5552           8 : void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
    5553             :                                                 throw(uno::RuntimeException, std::exception)
    5554             : {
    5555           8 :     SolarMutexGuard aGuard;
    5556           8 :     ScDocShell* pDocSh = GetDocShell();
    5557           8 :     if (pDocSh)
    5558             :     {
    5559             :         sal_uInt16 i;
    5560           8 :         ScSortParam aParam;
    5561           8 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
    5562           8 :         if (pData)
    5563             :         {
    5564             :             //  alten Einstellungen holen, falls nicht alles neu gesetzt wird
    5565           8 :             pData->GetSortParam(aParam);
    5566             :             SCCOLROW nOldStart = aParam.bByRow ?
    5567           8 :                 static_cast<SCCOLROW>(aRange.aStart.Col()) :
    5568          16 :                 static_cast<SCCOLROW>(aRange.aStart.Row());
    5569          32 :             for (i=0; i<aParam.GetSortKeyCount(); i++)
    5570          24 :                 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nOldStart )
    5571           6 :                     aParam.maKeyState[i].nField -= nOldStart;
    5572             :         }
    5573             : 
    5574           8 :         ScSortDescriptor::FillSortParam( aParam, aDescriptor );
    5575             : 
    5576             :         //  im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5577             :         //  ByRow kann bei FillSortParam umgesetzt worden sein
    5578             :         SCCOLROW nFieldStart = aParam.bByRow ?
    5579           8 :             static_cast<SCCOLROW>(aRange.aStart.Col()) :
    5580          16 :             static_cast<SCCOLROW>(aRange.aStart.Row());
    5581          32 :         for (i=0; i<aParam.GetSortKeyCount(); i++)
    5582          24 :             aParam.maKeyState[i].nField += nFieldStart;
    5583             : 
    5584           8 :         SCTAB nTab = aRange.aStart.Tab();
    5585           8 :         aParam.nCol1 = aRange.aStart.Col();
    5586           8 :         aParam.nRow1 = aRange.aStart.Row();
    5587           8 :         aParam.nCol2 = aRange.aEnd.Col();
    5588           8 :         aParam.nRow2 = aRange.aEnd.Row();
    5589             : 
    5590           8 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );       // ggf. Bereich anlegen
    5591             : 
    5592          16 :         ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
    5593          16 :         (void)aFunc.Sort( nTab, aParam, true, true, true );
    5594           8 :     }
    5595           8 : }
    5596             : 
    5597             : // XFilterable
    5598             : 
    5599           4 : uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
    5600             :                                 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
    5601             : {
    5602           4 :     SolarMutexGuard aGuard;
    5603           4 :     ScDocShell* pDocSh = GetDocShell();
    5604           4 :     ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
    5605           4 :     if ( !bEmpty && pDocSh )
    5606             :     {
    5607             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5608           0 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5609           0 :         if (pData)
    5610             :         {
    5611           0 :             ScQueryParam aParam;
    5612           0 :             pData->GetQueryParam(aParam);
    5613             :             //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5614           0 :             ScRange aDBRange;
    5615           0 :             pData->GetArea(aDBRange);
    5616             :             SCCOLROW nFieldStart = aParam.bByRow ?
    5617           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
    5618           0 :                 static_cast<SCCOLROW>(aDBRange.aStart.Row());
    5619           0 :             SCSIZE nCount = aParam.GetEntryCount();
    5620           0 :             for (SCSIZE i=0; i<nCount; i++)
    5621             :             {
    5622           0 :                 ScQueryEntry& rEntry = aParam.GetEntry(i);
    5623           0 :                 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
    5624           0 :                     rEntry.nField -= nFieldStart;
    5625             :             }
    5626           0 :             pNew->SetParam(aParam);
    5627             :         }
    5628             :     }
    5629           4 :     return pNew;
    5630             : }
    5631             : 
    5632           2 : void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
    5633             :                                                 throw(uno::RuntimeException, std::exception)
    5634             : {
    5635           2 :     SolarMutexGuard aGuard;
    5636             : 
    5637             :     //  das koennte theoretisch ein fremdes Objekt sein, also nur das
    5638             :     //  oeffentliche XSheetFilterDescriptor Interface benutzen, um
    5639             :     //  die Daten in ein ScFilterDescriptor Objekt zu kopieren:
    5640             :     //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
    5641             : 
    5642           2 :     ScDocShell* pDocSh = GetDocShell();
    5643           4 :     ScFilterDescriptor aImpl(pDocSh);
    5644           4 :     uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
    5645           2 :     if ( xDescriptor2.is() )
    5646             :     {
    5647           2 :         aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
    5648             :     }
    5649             :     else
    5650             :     {
    5651           0 :         aImpl.setFilterFields( xDescriptor->getFilterFields() );
    5652             :     }
    5653             :     //  Rest sind jetzt Properties...
    5654             : 
    5655           4 :     uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
    5656           2 :     if (xPropSet.is())
    5657           2 :         lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
    5658             : 
    5659             :     //  ausfuehren...
    5660             : 
    5661           2 :     if (pDocSh)
    5662             :     {
    5663           2 :         ScQueryParam aParam = aImpl.GetParam();
    5664             :         //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5665             :         SCCOLROW nFieldStart = aParam.bByRow ?
    5666           2 :             static_cast<SCCOLROW>(aRange.aStart.Col()) :
    5667           4 :             static_cast<SCCOLROW>(aRange.aStart.Row());
    5668           2 :         SCSIZE nCount = aParam.GetEntryCount();
    5669           2 :         svl::SharedStringPool& rPool = pDocSh->GetDocument().GetSharedStringPool();
    5670          18 :         for (SCSIZE i=0; i<nCount; i++)
    5671             :         {
    5672          16 :             ScQueryEntry& rEntry = aParam.GetEntry(i);
    5673          16 :             if (rEntry.bDoQuery)
    5674             :             {
    5675           4 :                 rEntry.nField += nFieldStart;
    5676             :                 //  Im Dialog wird immer der String angezeigt -> muss zum Wert passen
    5677           4 :                 ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
    5678           4 :                 rItems.resize(1);
    5679           4 :                 ScQueryEntry::Item& rItem = rItems.front();
    5680           4 :                 if (rItem.meType != ScQueryEntry::ByString)
    5681             :                 {
    5682           2 :                     OUString aStr;
    5683           2 :                     pDocSh->GetDocument().GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
    5684           2 :                     rItem.maString = rPool.intern(aStr);
    5685             :                 }
    5686             :             }
    5687             :         }
    5688             : 
    5689           2 :         SCTAB nTab = aRange.aStart.Tab();
    5690           2 :         aParam.nCol1 = aRange.aStart.Col();
    5691           2 :         aParam.nRow1 = aRange.aStart.Row();
    5692           2 :         aParam.nCol2 = aRange.aEnd.Col();
    5693           2 :         aParam.nRow2 = aRange.aEnd.Row();
    5694             : 
    5695           2 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );   // ggf. Bereich anlegen
    5696             : 
    5697             :         //! keep source range in filter descriptor
    5698             :         //! if created by createFilterDescriptorByObject ???
    5699             : 
    5700           4 :         ScDBDocFunc aFunc(*pDocSh);
    5701           4 :         aFunc.Query( nTab, aParam, NULL, true, true );  // Bereich muss angelegt sein
    5702           2 :     }
    5703           2 : }
    5704             : 
    5705             : //! get/setAutoFilter als Properties!!!
    5706             : 
    5707             : // XAdvancedFilterSource
    5708             : 
    5709           2 : uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
    5710             :                         const uno::Reference<sheet::XSheetFilterable>& xObject )
    5711             :                                                 throw(uno::RuntimeException, std::exception)
    5712             : {
    5713           2 :     SolarMutexGuard aGuard;
    5714             : 
    5715             :     //  this ist hier nicht der Bereich, der gefiltert wird, sondern der
    5716             :     //  Bereich mit der Abfrage...
    5717             : 
    5718           4 :     uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
    5719             : 
    5720           2 :     ScDocShell* pDocSh = GetDocShell();
    5721           2 :     if ( pDocSh && xAddr.is() )
    5722             :     {
    5723             :         //! Test, ob xObject im selben Dokument ist
    5724             : 
    5725           2 :         ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);  //! stattdessen vom Objekt?
    5726             : 
    5727           2 :         ScQueryParam aParam = pNew->GetParam();
    5728           2 :         aParam.bHasHeader = true;
    5729             : 
    5730           2 :         table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
    5731           2 :         aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
    5732           2 :         aParam.nRow1 = (SCROW)aDataAddress.StartRow;
    5733           2 :         aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
    5734           2 :         aParam.nRow2 = (SCROW)aDataAddress.EndRow;
    5735           2 :         aParam.nTab  = aDataAddress.Sheet;
    5736             : 
    5737           2 :         ScDocument& rDoc = pDocSh->GetDocument();
    5738             :         bool bOk = rDoc.CreateQueryParam(
    5739           2 :                             aRange.aStart.Col(), aRange.aStart.Row(),
    5740           2 :                             aRange.aEnd.Col(), aRange.aEnd.Row(),
    5741           6 :                             aRange.aStart.Tab(), aParam );
    5742           2 :         if ( bOk )
    5743             :         {
    5744             :             //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5745             :             SCCOLROW nFieldStart = aParam.bByRow ?
    5746             :                 static_cast<SCCOLROW>(aDataAddress.StartColumn) :
    5747           2 :                 static_cast<SCCOLROW>(aDataAddress.StartRow);
    5748           2 :             SCSIZE nCount = aParam.GetEntryCount();
    5749          18 :             for (SCSIZE i=0; i<nCount; i++)
    5750             :             {
    5751          16 :                 ScQueryEntry& rEntry = aParam.GetEntry(i);
    5752          16 :                 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
    5753           2 :                     rEntry.nField -= nFieldStart;
    5754             :             }
    5755             : 
    5756           2 :             pNew->SetParam( aParam );
    5757           2 :             return pNew;
    5758             :         }
    5759             :         else
    5760             :         {
    5761           0 :             delete pNew;
    5762           0 :             return NULL;        // ungueltig -> null
    5763           2 :         }
    5764             :     }
    5765             : 
    5766             :     OSL_FAIL("kein Dokument oder kein Bereich");
    5767           2 :     return NULL;
    5768             : }
    5769             : 
    5770             : // XSubTotalSource
    5771             : 
    5772          12 : uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
    5773             :                                 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
    5774             : {
    5775          12 :     SolarMutexGuard aGuard;
    5776          12 :     ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
    5777          12 :     ScDocShell* pDocSh = GetDocShell();
    5778          12 :     if ( !bEmpty && pDocSh )
    5779             :     {
    5780             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5781           0 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5782           0 :         if (pData)
    5783             :         {
    5784           0 :             ScSubTotalParam aParam;
    5785           0 :             pData->GetSubTotalParam(aParam);
    5786             :             //  im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5787           0 :             ScRange aDBRange;
    5788           0 :             pData->GetArea(aDBRange);
    5789           0 :             SCCOL nFieldStart = aDBRange.aStart.Col();
    5790           0 :             for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
    5791             :             {
    5792           0 :                 if ( aParam.bGroupActive[i] )
    5793             :                 {
    5794           0 :                     if ( aParam.nField[i] >= nFieldStart )
    5795           0 :                         aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
    5796           0 :                     for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
    5797           0 :                         if ( aParam.pSubTotals[i][j] >= nFieldStart )
    5798           0 :                             aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
    5799             :                 }
    5800             :             }
    5801           0 :             pNew->SetParam(aParam);
    5802             :         }
    5803             :     }
    5804          12 :     return pNew;
    5805             : }
    5806             : 
    5807           2 : void SAL_CALL ScCellRangeObj::applySubTotals(
    5808             :     const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
    5809             :     sal_Bool bReplace)
    5810             :     throw (uno::RuntimeException, std::exception)
    5811             : {
    5812           2 :     SolarMutexGuard aGuard;
    5813             : 
    5814           4 :     if (!xDescriptor.is()) return;
    5815             : 
    5816           2 :     ScDocShell* pDocSh = GetDocShell();
    5817             :     ScSubTotalDescriptorBase* pImp =
    5818           2 :         ScSubTotalDescriptorBase::getImplementation( xDescriptor );
    5819             : 
    5820           2 :     if (pDocSh && pImp)
    5821             :     {
    5822           2 :         ScSubTotalParam aParam;
    5823           2 :         pImp->GetData(aParam);      // virtuelle Methode der Basisklasse
    5824             : 
    5825             :         //  im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    5826           2 :         SCCOL nFieldStart = aRange.aStart.Col();
    5827           8 :         for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
    5828             :         {
    5829           6 :             if ( aParam.bGroupActive[i] )
    5830             :             {
    5831           2 :                 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
    5832           4 :                 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
    5833           2 :                     aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
    5834             :             }
    5835             :         }
    5836             : 
    5837           2 :         aParam.bReplace = bReplace;
    5838             : 
    5839           2 :         SCTAB nTab = aRange.aStart.Tab();
    5840           2 :         aParam.nCol1 = aRange.aStart.Col();
    5841           2 :         aParam.nRow1 = aRange.aStart.Row();
    5842           2 :         aParam.nCol2 = aRange.aEnd.Col();
    5843           2 :         aParam.nRow2 = aRange.aEnd.Row();
    5844             : 
    5845           2 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );   // ggf. Bereich anlegen
    5846             : 
    5847           2 :         ScDBDocFunc aFunc(*pDocSh);
    5848           2 :         aFunc.DoSubTotals( nTab, aParam, NULL, true, true );    // Bereich muss angelegt sein
    5849           2 :     }
    5850             : }
    5851             : 
    5852           2 : void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException, std::exception)
    5853             : {
    5854           2 :     SolarMutexGuard aGuard;
    5855             : 
    5856           2 :     ScDocShell* pDocSh = GetDocShell();
    5857           2 :     if (pDocSh)
    5858             :     {
    5859           2 :         ScSubTotalParam aParam;
    5860           2 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5861           2 :         if (pData)
    5862           0 :             pData->GetSubTotalParam(aParam);    // auch bei Remove die Feld-Eintraege behalten
    5863             : 
    5864           2 :         aParam.bRemoveOnly = true;
    5865             : 
    5866           2 :         SCTAB nTab = aRange.aStart.Tab();
    5867           2 :         aParam.nCol1 = aRange.aStart.Col();
    5868           2 :         aParam.nRow1 = aRange.aStart.Row();
    5869           2 :         aParam.nCol2 = aRange.aEnd.Col();
    5870           2 :         aParam.nRow2 = aRange.aEnd.Row();
    5871             : 
    5872           2 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );   // ggf. Bereich anlegen
    5873             : 
    5874           2 :         ScDBDocFunc aFunc(*pDocSh);
    5875           2 :         aFunc.DoSubTotals( nTab, aParam, NULL, true, true );    // Bereich muss angelegt sein
    5876           2 :     }
    5877           2 : }
    5878             : 
    5879           8 : uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
    5880             :                                                 throw(uno::RuntimeException, std::exception)
    5881             : {
    5882           8 :     SolarMutexGuard aGuard;
    5883          16 :     ScImportParam aParam;
    5884           8 :     ScDocShell* pDocSh = GetDocShell();
    5885           8 :     if ( !bEmpty && pDocSh )
    5886             :     {
    5887             :         // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
    5888           6 :         ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
    5889           6 :         if (pData)
    5890           0 :             pData->GetImportParam(aParam);
    5891             :     }
    5892             : 
    5893           8 :     uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
    5894           8 :     ScImportDescriptor::FillProperties( aSeq, aParam );
    5895          16 :     return aSeq;
    5896             : }
    5897             : 
    5898           8 : void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
    5899             :                                             throw(uno::RuntimeException, std::exception)
    5900             : {
    5901           8 :     SolarMutexGuard aGuard;
    5902           8 :     ScDocShell* pDocSh = GetDocShell();
    5903           8 :     if (pDocSh)
    5904             :     {
    5905           8 :         ScImportParam aParam;
    5906           8 :         ScImportDescriptor::FillImportParam( aParam, aDescriptor );
    5907             : 
    5908           8 :         SCTAB nTab = aRange.aStart.Tab();
    5909           8 :         aParam.nCol1 = aRange.aStart.Col();
    5910           8 :         aParam.nRow1 = aRange.aStart.Row();
    5911           8 :         aParam.nCol2 = aRange.aEnd.Col();
    5912           8 :         aParam.nRow2 = aRange.aEnd.Row();
    5913             : 
    5914             :         //! TODO: could we get passed a valid result set by any means?
    5915             : 
    5916           8 :         pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );       // ggf. Bereich anlegen
    5917             : 
    5918          16 :         ScDBDocFunc aFunc(*pDocSh);                         // Bereich muss angelegt sein
    5919          16 :         aFunc.DoImport( nTab, aParam, NULL, true );         //! Api-Flag as parameter
    5920           8 :     }
    5921           8 : }
    5922             : 
    5923             : // XCellFormatRangesSupplier
    5924             : 
    5925           6 : uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
    5926             :                                                 throw(uno::RuntimeException, std::exception)
    5927             : {
    5928           6 :     SolarMutexGuard aGuard;
    5929           6 :     ScDocShell* pDocSh = GetDocShell();
    5930           6 :     if ( pDocSh )
    5931           6 :         return new ScCellFormatsObj( pDocSh, aRange );
    5932           0 :     return NULL;
    5933             : }
    5934             : 
    5935             : // XUniqueCellFormatRangesSupplier
    5936             : 
    5937          62 : uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
    5938             :                                                 throw(uno::RuntimeException, std::exception)
    5939             : {
    5940          62 :     SolarMutexGuard aGuard;
    5941          62 :     ScDocShell* pDocSh = GetDocShell();
    5942          62 :     if ( pDocSh )
    5943          62 :         return new ScUniqueCellFormatsObj( pDocSh, aRange );
    5944           0 :     return NULL;
    5945             : }
    5946             : 
    5947             : // XPropertySet erweitert fuer Range-Properties
    5948             : 
    5949         964 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
    5950             :                                                         throw(uno::RuntimeException, std::exception)
    5951             : {
    5952         964 :     SolarMutexGuard aGuard;
    5953             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    5954         964 :         new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
    5955         964 :     return aRef;
    5956             : }
    5957             : 
    5958         694 : void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    5959             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    5960             : {
    5961             :     //  Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
    5962             :     //  -> nothing to do here
    5963             : 
    5964         694 :     ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
    5965         692 : }
    5966             : 
    5967       19372 : void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    5968             :     throw(uno::RuntimeException, std::exception)
    5969             : {
    5970       19372 :     if ( pEntry )
    5971             :     {
    5972       19372 :         if ( pEntry->nWID == SC_WID_UNO_POS )
    5973             :         {
    5974         688 :             ScDocShell* pDocSh = GetDocShell();
    5975         688 :             if (pDocSh)
    5976             :             {
    5977             :                 //  GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
    5978         688 :                 Rectangle aMMRect(pDocSh->GetDocument().GetMMRect(
    5979         688 :                                         aRange.aStart.Col(), aRange.aStart.Row(),
    5980        2064 :                                         aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
    5981         688 :                 awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
    5982         688 :                 rAny <<= aPos;
    5983             :             }
    5984             :         }
    5985       18684 :         else if ( pEntry->nWID == SC_WID_UNO_SIZE )
    5986             :         {
    5987         426 :             ScDocShell* pDocSh = GetDocShell();
    5988         426 :             if (pDocSh)
    5989             :             {
    5990             :                 //  GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
    5991         426 :                 Rectangle aMMRect = pDocSh->GetDocument().GetMMRect(
    5992         426 :                                         aRange.aStart.Col(), aRange.aStart.Row(),
    5993        1278 :                                         aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
    5994         426 :                 Size aSize(aMMRect.GetSize());
    5995         426 :                 awt::Size aAwtSize( aSize.Width(), aSize.Height() );
    5996         426 :                 rAny <<= aAwtSize;
    5997             :             }
    5998             :         }
    5999             :         else
    6000       18258 :             ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
    6001             :     }
    6002       19372 : }
    6003             : 
    6004        3280 : const SfxItemPropertyMap& ScCellRangeObj::GetItemPropertyMap()
    6005             : {
    6006        3280 :     return pRangePropSet->getPropertyMap();
    6007             : }
    6008             : 
    6009             : // XServiceInfo
    6010             : 
    6011          12 : OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    6012             : {
    6013          12 :     return OUString( "ScCellRangeObj" );
    6014             : }
    6015             : 
    6016          20 : sal_Bool SAL_CALL ScCellRangeObj::supportsService( const OUString& rServiceName )
    6017             :                                                     throw(uno::RuntimeException, std::exception)
    6018             : {
    6019          20 :     return cppu::supportsService(this, rServiceName);
    6020             : }
    6021             : 
    6022          20 : uno::Sequence<OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
    6023             :                                                     throw(uno::RuntimeException, std::exception)
    6024             : {
    6025          20 :     uno::Sequence<OUString> aRet(5);
    6026          20 :     OUString* pArray = aRet.getArray();
    6027          20 :     pArray[0] = OUString( SCSHEETCELLRANGE_SERVICE );
    6028          20 :     pArray[1] = OUString( SCCELLRANGE_SERVICE );
    6029          20 :     pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
    6030          20 :     pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
    6031          20 :     pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
    6032          20 :     return aRet;
    6033             : }
    6034             : 
    6035          20 : const SvxItemPropertySet* ScCellObj::GetEditPropertySet()
    6036             : {
    6037          20 :     return lcl_GetEditPropertySet();
    6038             : }
    6039             : 
    6040           0 : const SfxItemPropertyMap& ScCellObj::GetCellPropertyMap()
    6041             : {
    6042           0 :     return lcl_GetCellPropertySet()->getPropertyMap();
    6043             : }
    6044             : 
    6045       25732 : ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
    6046             :     ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
    6047       25732 :     pCellPropSet( lcl_GetCellPropertySet() ),
    6048             :     aCellPos( rP ),
    6049       51464 :     nActionLockCount( 0 )
    6050             : {
    6051             :     //  pUnoText is allocated on demand (GetUnoText)
    6052             :     //  can't be aggregated because getString/setString is handled here
    6053       25732 : }
    6054             : 
    6055          46 : SvxUnoText& ScCellObj::GetUnoText()
    6056             : {
    6057          46 :     if (!mxUnoText.is())
    6058             :     {
    6059          20 :         mxUnoText.set(new ScCellTextObj(GetDocShell(), aCellPos));
    6060          20 :         if (nActionLockCount)
    6061             :         {
    6062             :             ScCellEditSource* pEditSource =
    6063           0 :                 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6064           0 :             if (pEditSource)
    6065           0 :                 pEditSource->SetDoUpdateData(false);
    6066             :         }
    6067             :     }
    6068          46 :     return *mxUnoText;
    6069             : }
    6070             : 
    6071       51368 : ScCellObj::~ScCellObj()
    6072             : {
    6073       51368 : }
    6074             : 
    6075        3464 : void ScCellObj::RefChanged()
    6076             : {
    6077        3464 :     ScCellRangeObj::RefChanged();
    6078             : 
    6079        3464 :     const ScRangeList& rRanges = GetRangeList();
    6080             :     OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
    6081        3464 :     if ( !rRanges.empty() )
    6082             :     {
    6083        3420 :         const ScRange* pFirst = rRanges[ 0 ];
    6084        3420 :         aCellPos = pFirst->aStart;
    6085             :     }
    6086        3464 : }
    6087             : 
    6088      273948 : uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    6089             : {
    6090      273948 :     SC_QUERYINTERFACE( table::XCell )
    6091      258444 :     SC_QUERYINTERFACE( table::XCell2 )
    6092      258444 :     SC_QUERYINTERFACE( sheet::XFormulaTokens )
    6093      258444 :     SC_QUERYINTERFACE( sheet::XCellAddressable )
    6094      255532 :     SC_QUERYINTERFACE( text::XText )
    6095      255334 :     SC_QUERYINTERFACE( text::XSimpleText )
    6096      255152 :     SC_QUERYINTERFACE( text::XTextRange )
    6097      254820 :     SC_QUERYINTERFACE( container::XEnumerationAccess )
    6098      254816 :     SC_QUERYINTERFACE( container::XElementAccess )
    6099      254812 :     SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
    6100      254796 :     SC_QUERYINTERFACE( text::XTextFieldsSupplier )
    6101      254790 :     SC_QUERYINTERFACE( document::XActionLockable )
    6102             : 
    6103      254788 :     return ScCellRangeObj::queryInterface( rType );
    6104             : }
    6105             : 
    6106      819382 : void SAL_CALL ScCellObj::acquire() throw()
    6107             : {
    6108      819382 :     ScCellRangeObj::acquire();
    6109      819382 : }
    6110             : 
    6111      819334 : void SAL_CALL ScCellObj::release() throw()
    6112             : {
    6113      819334 :     ScCellRangeObj::release();
    6114      819334 : }
    6115             : 
    6116           4 : uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException, std::exception)
    6117             : {
    6118           4 :     static uno::Sequence<uno::Type> aTypes;
    6119           4 :     if ( aTypes.getLength() == 0 )
    6120             :     {
    6121           2 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
    6122           2 :         long nParentLen = aParentTypes.getLength();
    6123           2 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    6124             : 
    6125           2 :         aTypes.realloc( nParentLen + 9 );
    6126           2 :         uno::Type* pPtr = aTypes.getArray();
    6127           2 :         pPtr[nParentLen + 0] = cppu::UnoType<table::XCell>::get();
    6128           2 :         pPtr[nParentLen + 1] = cppu::UnoType<sheet::XCellAddressable>::get();
    6129           2 :         pPtr[nParentLen + 2] = cppu::UnoType<text::XText>::get();
    6130           2 :         pPtr[nParentLen + 3] = cppu::UnoType<container::XEnumerationAccess>::get();
    6131           2 :         pPtr[nParentLen + 4] = cppu::UnoType<sheet::XSheetAnnotationAnchor>::get();
    6132           2 :         pPtr[nParentLen + 5] = cppu::UnoType<text::XTextFieldsSupplier>::get();
    6133           2 :         pPtr[nParentLen + 6] = cppu::UnoType<document::XActionLockable>::get();
    6134           2 :         pPtr[nParentLen + 7] = cppu::UnoType<sheet::XFormulaTokens>::get();
    6135           2 :         pPtr[nParentLen + 8] = cppu::UnoType<table::XCell2>::get();
    6136             : 
    6137          62 :         for (long i=0; i<nParentLen; i++)
    6138          62 :             pPtr[i] = pParentPtr[i];                // parent types first
    6139             :     }
    6140           4 :     return aTypes;
    6141             : }
    6142             : 
    6143           0 : uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException, std::exception)
    6144             : {
    6145           0 :     return css::uno::Sequence<sal_Int8>();
    6146             : }
    6147             : 
    6148             : //  Hilfsfunktionen
    6149             : 
    6150         262 : OUString ScCellObj::GetInputString_Impl(bool bEnglish) const      // fuer getFormula / FormulaLocal
    6151             : {
    6152         262 :     if (GetDocShell())
    6153         262 :         return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
    6154           0 :     return OUString();
    6155             : }
    6156             : 
    6157         662 : OUString ScCellObj::GetOutputString_Impl() const
    6158             : {
    6159         662 :     ScDocShell* pDocSh = GetDocShell();
    6160         662 :     OUString aVal;
    6161         662 :     if ( pDocSh )
    6162             :     {
    6163         662 :         ScDocument& rDoc = pDocSh->GetDocument();
    6164         662 :         ScRefCellValue aCell;
    6165         662 :         aCell.assign(rDoc, aCellPos);
    6166             : 
    6167         662 :         aVal = ScCellFormat::GetOutputString(rDoc, aCellPos, aCell);
    6168             :     }
    6169         662 :     return aVal;
    6170             : }
    6171             : 
    6172        4092 : void ScCellObj::SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish)
    6173             : {
    6174        4092 :     ScDocShell* pDocSh = GetDocShell();
    6175        4092 :     if ( pDocSh )
    6176             :     {
    6177             :         // GRAM_PODF_A1 for API compatibility.
    6178        4092 :         (void)pDocSh->GetDocFunc().SetCellText(
    6179        8184 :             aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_PODF_A1 );
    6180             :     }
    6181        4092 : }
    6182             : 
    6183        4944 : double ScCellObj::GetValue_Impl() const
    6184             : {
    6185        4944 :     ScDocShell* pDocSh = GetDocShell();
    6186        4944 :     if ( pDocSh )
    6187        4944 :         return pDocSh->GetDocument().GetValue( aCellPos );
    6188             : 
    6189           0 :     return 0.0;
    6190             : }
    6191             : 
    6192        7094 : void ScCellObj::SetValue_Impl(double fValue)
    6193             : {
    6194        7094 :     ScDocShell* pDocSh = GetDocShell();
    6195        7094 :     if ( pDocSh )
    6196        7094 :         pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false);
    6197        7094 : }
    6198             : 
    6199             : // only for XML import
    6200             : 
    6201        3058 : void ScCellObj::InputEnglishString( const OUString& rText )
    6202             : {
    6203             :     // This is like a mixture of setFormula and property FormulaLocal:
    6204             :     // The cell's number format is checked for "text", a new cell format may be set,
    6205             :     // but all parsing is in English.
    6206             : 
    6207        3058 :     ScDocShell* pDocSh = GetDocShell();
    6208        3058 :     if (!pDocSh)
    6209           0 :         return;
    6210             : 
    6211        3058 :     OUString aString(rText);
    6212        3058 :     ScDocument& rDoc = pDocSh->GetDocument();
    6213        3058 :     SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
    6214        3058 :     sal_uInt32 nOldFormat = rDoc.GetNumberFormat( aCellPos );
    6215        3058 :     if (pFormatter->GetType(nOldFormat) == NUMBERFORMAT_TEXT)
    6216             :     {
    6217           0 :         SetString_Impl(aString, false, false);      // text cell
    6218           0 :         return;
    6219             :     }
    6220             : 
    6221        3058 :     ScDocFunc &rFunc = pDocSh->GetDocFunc();
    6222             : 
    6223             :     ScInputStringType aRes =
    6224        6116 :         ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US);
    6225             : 
    6226        3058 :     if (aRes.meType != ScInputStringType::Unknown)
    6227             :     {
    6228         770 :         if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType)
    6229             :         {
    6230             :             // apply a format for the recognized type and the old format's language
    6231           2 :             sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType);
    6232           2 :             if (nNewFormat != nOldFormat)
    6233             :             {
    6234           0 :                 ScPatternAttr aPattern( rDoc.GetPool() );
    6235           0 :                 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
    6236             :                 // ATTR_LANGUAGE_FORMAT remains unchanged
    6237           0 :                 rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true );
    6238             :             }
    6239             :         }
    6240             :     }
    6241        3058 :     switch (aRes.meType)
    6242             :     {
    6243             :         case ScInputStringType::Formula:
    6244             :             rFunc.SetFormulaCell(
    6245             :                 aCellPos,
    6246           2 :                 new ScFormulaCell(&rDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1),
    6247           4 :                 false);
    6248           2 :         break;
    6249             :         case ScInputStringType::Number:
    6250           2 :             rFunc.SetValueCell(aCellPos, aRes.mfValue, false);
    6251           2 :         break;
    6252             :         case ScInputStringType::Text:
    6253         766 :             rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false);
    6254         766 :         break;
    6255             :         default:
    6256        2288 :             SetString_Impl(aString, false, false); // probably empty string
    6257        3058 :     }
    6258             : }
    6259             : 
    6260             : //  XText
    6261             : 
    6262          24 : uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
    6263             :                                                     throw(uno::RuntimeException, std::exception)
    6264             : {
    6265          24 :     SolarMutexGuard aGuard;
    6266          24 :     return new ScCellTextCursor( *this );
    6267             : }
    6268             : 
    6269           2 : uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
    6270             :                                     const uno::Reference<text::XTextRange>& aTextPosition )
    6271             :                                                     throw(uno::RuntimeException, std::exception)
    6272             : {
    6273           2 :     SolarMutexGuard aGuard;
    6274           2 :     SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
    6275           2 :     uno::Reference<text::XTextCursor> xCursor(pCursor);
    6276             : 
    6277           2 :     SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
    6278           2 :     if(pRange)
    6279           2 :         pCursor->SetSelection( pRange->GetSelection() );
    6280             :     else
    6281             :     {
    6282           0 :         ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
    6283           0 :         if(pOther)
    6284           0 :             pCursor->SetSelection( pOther->GetSelection() );
    6285             :         else
    6286           0 :             throw uno::RuntimeException();
    6287             :     }
    6288             : 
    6289           2 :     return xCursor;
    6290             : }
    6291             : 
    6292         662 : OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException, std::exception)
    6293             : {
    6294         662 :     SolarMutexGuard aGuard;
    6295         662 :     return GetOutputString_Impl();
    6296             : }
    6297             : 
    6298          68 : void SAL_CALL ScCellObj::setString( const OUString& aText ) throw(uno::RuntimeException, std::exception)
    6299             : {
    6300          68 :     SolarMutexGuard aGuard;
    6301         136 :     OUString aString(aText);
    6302          68 :     SetString_Impl(aString, false, false);  // immer Text
    6303             : 
    6304             :     // don't create pUnoText here if not there
    6305          68 :     if (mxUnoText.is())
    6306          80 :         mxUnoText->SetSelection(ESelection( 0,0, 0,aString.getLength() ));
    6307          68 : }
    6308             : 
    6309           4 : void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
    6310             :                                         const OUString& aString, sal_Bool bAbsorb )
    6311             :                                     throw(uno::RuntimeException, std::exception)
    6312             : {
    6313             :     // special handling for ScCellTextCursor is no longer needed,
    6314             :     // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
    6315             : 
    6316           4 :     SolarMutexGuard aGuard;
    6317           4 :     GetUnoText().insertString(xRange, aString, bAbsorb);
    6318           4 : }
    6319             : 
    6320           4 : void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
    6321             :                                                 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
    6322             :                                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    6323             : {
    6324           4 :     SolarMutexGuard aGuard;
    6325           4 :     GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
    6326           4 : }
    6327             : 
    6328          14 : void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
    6329             :                                                 const uno::Reference<text::XTextContent >& xContent,
    6330             :                                                 sal_Bool bAbsorb )
    6331             :                                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    6332             : {
    6333          14 :     SolarMutexGuard aGuard;
    6334          14 :     ScDocShell* pDocSh = GetDocShell();
    6335          14 :     if ( pDocSh && xContent.is() )
    6336             :     {
    6337          12 :         ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
    6338          12 :         SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
    6339             : 
    6340          12 :         if ( pCellField && !pCellField->IsInserted() && pTextRange )
    6341             :         {
    6342          12 :             SvxEditSource* pEditSource = pTextRange->GetEditSource();
    6343          12 :             ESelection aSelection(pTextRange->GetSelection());
    6344             : 
    6345          12 :             if (!bAbsorb)
    6346             :             {
    6347             :                 //  nicht ersetzen -> hinten anhaengen
    6348           4 :                 aSelection.Adjust();
    6349           4 :                 aSelection.nStartPara = aSelection.nEndPara;
    6350           4 :                 aSelection.nStartPos  = aSelection.nEndPos;
    6351             :             }
    6352             : 
    6353          12 :             if (pCellField->GetFieldType() == text::textfield::Type::TABLE)
    6354           0 :                 pCellField->setPropertyValue(SC_UNONAME_TABLEPOS, uno::makeAny<sal_Int32>(aCellPos.Tab()));
    6355             : 
    6356          12 :             SvxFieldItem aItem = pCellField->CreateFieldItem();
    6357          12 :             SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
    6358          12 :             pForwarder->QuickInsertField( aItem, aSelection );
    6359          12 :             pEditSource->UpdateData();
    6360             : 
    6361             :             //  neue Selektion: ein Zeichen
    6362          12 :             aSelection.Adjust();
    6363          12 :             aSelection.nEndPara = aSelection.nStartPara;
    6364          12 :             aSelection.nEndPos = aSelection.nStartPos + 1;
    6365          24 :             uno::Reference<text::XTextRange> xParent(this);
    6366             :             pCellField->InitDoc(
    6367          12 :                 xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
    6368             : 
    6369             :             //  for bAbsorb=FALSE, the new selection must be behind the inserted content
    6370             :             //  (the xml filter relies on this)
    6371          12 :             if (!bAbsorb)
    6372           4 :                 aSelection.nStartPos = aSelection.nEndPos;
    6373             : 
    6374          12 :             pTextRange->SetSelection( aSelection );
    6375             : 
    6376          36 :             return;
    6377             :         }
    6378             :     }
    6379           4 :     GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
    6380             : }
    6381             : 
    6382           2 : void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
    6383             :                                 throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
    6384             : {
    6385           2 :     SolarMutexGuard aGuard;
    6386           2 :     if ( xContent.is() )
    6387             :     {
    6388           2 :         ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
    6389           2 :         if ( pCellField && pCellField->IsInserted() )
    6390             :         {
    6391             :             //! Testen, ob das Feld in dieser Zelle ist
    6392           2 :             pCellField->DeleteField();
    6393           4 :             return;
    6394             :         }
    6395             :     }
    6396           0 :     GetUnoText().removeTextContent(xContent);
    6397             : }
    6398             : 
    6399           8 : uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException, std::exception)
    6400             : {
    6401           8 :     SolarMutexGuard aGuard;
    6402           8 :     return this;
    6403             : }
    6404             : 
    6405           2 : uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException, std::exception)
    6406             : {
    6407           2 :     SolarMutexGuard aGuard;
    6408           2 :     return GetUnoText().getStart();
    6409             : }
    6410             : 
    6411           2 : uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException, std::exception)
    6412             : {
    6413           2 :     SolarMutexGuard aGuard;
    6414           2 :     return GetUnoText().getEnd();
    6415             : }
    6416             : 
    6417           2 : uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
    6418             :                                                     throw(uno::RuntimeException, std::exception)
    6419             : {
    6420           2 :     SolarMutexGuard aGuard;
    6421           2 :     return GetUnoText().createEnumeration();
    6422             : }
    6423             : 
    6424           2 : uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException, std::exception)
    6425             : {
    6426           2 :     SolarMutexGuard aGuard;
    6427           2 :     return GetUnoText().getElementType();
    6428             : }
    6429             : 
    6430           2 : sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException, std::exception)
    6431             : {
    6432           2 :     SolarMutexGuard aGuard;
    6433           2 :     return GetUnoText().hasElements();
    6434             : }
    6435             : 
    6436             : //  XCell
    6437             : 
    6438         242 : OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException, std::exception)
    6439             : {
    6440         242 :     SolarMutexGuard aGuard;
    6441         242 :     return GetInputString_Impl( true /* English */ );
    6442             : }
    6443             : 
    6444        1732 : void SAL_CALL ScCellObj::setFormula( const OUString& aFormula ) throw(uno::RuntimeException, std::exception)
    6445             : {
    6446        1732 :     SolarMutexGuard aGuard;
    6447        3464 :     OUString aString(aFormula);
    6448        3464 :     SetString_Impl(aString, true, true); // Interpret as English
    6449        1732 : }
    6450             : 
    6451        4944 : double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException, std::exception)
    6452             : {
    6453        4944 :     SolarMutexGuard aGuard;
    6454        4944 :     return GetValue_Impl();
    6455             : }
    6456             : 
    6457        7094 : void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException, std::exception)
    6458             : {
    6459        7094 :     SolarMutexGuard aGuard;
    6460        7094 :     SetValue_Impl(nValue);
    6461        7094 : }
    6462             : 
    6463           0 : void SAL_CALL ScCellObj::setFormulaString( const OUString& aFormula) throw(uno::RuntimeException, std::exception)
    6464             : {
    6465           0 :     SolarMutexGuard aGuard;
    6466           0 :     ScDocShell *pDocSh = GetDocShell();
    6467           0 :     if( pDocSh )
    6468             :     {
    6469           0 :         ScFormulaCell* pCell = new ScFormulaCell( &pDocSh->GetDocument(), aCellPos );
    6470           0 :         pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE );
    6471           0 :         pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false);
    6472           0 :     }
    6473           0 : }
    6474           0 : void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException, std::exception)
    6475             : {
    6476           0 :     SolarMutexGuard aGuard;
    6477           0 :     ScDocShell* pDocSh = GetDocShell();
    6478           0 :     if ( pDocSh && pDocSh->GetDocument().GetCellType( aCellPos ) == CELLTYPE_FORMULA )
    6479             :     {
    6480           0 :         ScFormulaCell* pCell = pDocSh->GetDocument().GetFormulaCell(aCellPos);
    6481           0 :         if (!pCell)
    6482           0 :             return;
    6483           0 :         pCell->SetHybridDouble( nValue );
    6484           0 :         pCell->ResetDirty();
    6485           0 :         pCell->SetChanged(false);
    6486           0 :     }
    6487             : }
    6488             : 
    6489        8162 : table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException, std::exception)
    6490             : {
    6491        8162 :     SolarMutexGuard aGuard;
    6492        8162 :     table::CellContentType eRet = table::CellContentType_EMPTY;
    6493        8162 :     ScDocShell* pDocSh = GetDocShell();
    6494        8162 :     if (pDocSh)
    6495             :     {
    6496        8162 :         CellType eCalcType = pDocSh->GetDocument().GetCellType( aCellPos );
    6497        8162 :         switch (eCalcType)
    6498             :         {
    6499             :             case CELLTYPE_VALUE:
    6500        4820 :                 eRet = table::CellContentType_VALUE;
    6501        4820 :                 break;
    6502             :             case CELLTYPE_STRING:
    6503             :             case CELLTYPE_EDIT:
    6504         356 :                 eRet = table::CellContentType_TEXT;
    6505         356 :                 break;
    6506             :             case CELLTYPE_FORMULA:
    6507         130 :                 eRet = table::CellContentType_FORMULA;
    6508         130 :                 break;
    6509             :             default:
    6510        2856 :                 eRet = table::CellContentType_EMPTY;
    6511             :         }
    6512             :     }
    6513             :     else
    6514             :     {
    6515             :         OSL_FAIL("keine DocShell");     //! Exception oder so?
    6516             :     }
    6517             : 
    6518        8162 :     return eRet;
    6519             : }
    6520             : 
    6521          98 : table::CellContentType ScCellObj::GetResultType_Impl()
    6522             : {
    6523          98 :     ScDocShell* pDocSh = GetDocShell();
    6524          98 :     if ( pDocSh )
    6525             :     {
    6526          98 :         ScRefCellValue aCell;
    6527          98 :         aCell.assign(pDocSh->GetDocument(), aCellPos);
    6528          98 :         if (aCell.meType == CELLTYPE_FORMULA)
    6529             :         {
    6530          78 :             bool bValue = aCell.mpFormula->IsValue();
    6531          78 :             return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
    6532          20 :         }
    6533             :     }
    6534          20 :     return getType();   // wenn keine Formel
    6535             : }
    6536             : 
    6537           4 : sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException, std::exception)
    6538             : {
    6539           4 :     SolarMutexGuard aGuard;
    6540           4 :     ScDocShell* pDocSh = GetDocShell();
    6541           4 :     if (!pDocSh)
    6542             :     {
    6543             :         OSL_FAIL("keine DocShell");     //! Exception oder so?
    6544           0 :         return 0;
    6545             :     }
    6546             : 
    6547           4 :     sal_uInt16 nError = 0;
    6548           8 :     ScRefCellValue aCell;
    6549           4 :     aCell.assign(pDocSh->GetDocument(), aCellPos);
    6550           4 :     if (aCell.meType == CELLTYPE_FORMULA)
    6551           2 :         nError = aCell.mpFormula->GetErrCode();
    6552             : 
    6553           8 :     return nError;
    6554             : }
    6555             : 
    6556             : // XFormulaTokens
    6557             : 
    6558           0 : uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens()
    6559             :     throw (uno::RuntimeException, std::exception)
    6560             : {
    6561           0 :     SolarMutexGuard aGuard;
    6562           0 :     uno::Sequence<sheet::FormulaToken> aSequence;
    6563           0 :     ScDocShell* pDocSh = GetDocShell();
    6564           0 :     if (!pDocSh)
    6565           0 :         return aSequence;
    6566             : 
    6567           0 :     ScDocument& rDoc = pDocSh->GetDocument();
    6568           0 :     ScRefCellValue aCell;
    6569           0 :     aCell.assign(rDoc, aCellPos);
    6570           0 :     if (aCell.meType == CELLTYPE_FORMULA)
    6571             :     {
    6572           0 :         ScTokenArray* pTokenArray = aCell.mpFormula->GetCode();
    6573           0 :         if (pTokenArray)
    6574           0 :             ScTokenConversion::ConvertToTokenSequence(rDoc, aSequence, *pTokenArray);
    6575             :     }
    6576           0 :     return aSequence;
    6577             : }
    6578             : 
    6579           0 : void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
    6580             : {
    6581           0 :     SolarMutexGuard aGuard;
    6582           0 :     ScDocShell* pDocSh = GetDocShell();
    6583           0 :     if ( pDocSh )
    6584             :     {
    6585           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    6586           0 :         ScTokenArray aTokenArray;
    6587           0 :         (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
    6588             : 
    6589           0 :         ScFormulaCell* pNewCell = new ScFormulaCell(&rDoc, aCellPos, aTokenArray);
    6590           0 :         (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false);
    6591           0 :     }
    6592           0 : }
    6593             : 
    6594             : // XCellAddressable
    6595             : 
    6596        2918 : table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException, std::exception)
    6597             : {
    6598        2918 :     SolarMutexGuard aGuard;
    6599        2918 :     table::CellAddress aAdr;
    6600        2918 :     aAdr.Sheet  = aCellPos.Tab();
    6601        2918 :     aAdr.Column = aCellPos.Col();
    6602        2918 :     aAdr.Row    = aCellPos.Row();
    6603        2918 :     return aAdr;
    6604             : }
    6605             : 
    6606             : // XSheetAnnotationAnchor
    6607             : 
    6608          16 : uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
    6609             :                                                 throw(uno::RuntimeException, std::exception)
    6610             : {
    6611          16 :     SolarMutexGuard aGuard;
    6612          16 :     ScDocShell* pDocSh = GetDocShell();
    6613          16 :     if ( pDocSh )
    6614          16 :         return new ScAnnotationObj( pDocSh, aCellPos );
    6615             : 
    6616             :     OSL_FAIL("getAnnotation ohne DocShell");
    6617           0 :     return NULL;
    6618             : }
    6619             : 
    6620             : // XFieldTypesSupplier
    6621             : 
    6622           8 : uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
    6623             :                                                 throw(uno::RuntimeException, std::exception)
    6624             : {
    6625           8 :     SolarMutexGuard aGuard;
    6626           8 :     ScDocShell* pDocSh = GetDocShell();
    6627           8 :     if ( pDocSh )
    6628             :     {
    6629           8 :         uno::Reference<text::XTextRange> xContent(this);
    6630           8 :         return new ScCellFieldsObj(xContent, pDocSh, aCellPos);
    6631             :     }
    6632             : 
    6633           0 :     return NULL;
    6634             : }
    6635             : 
    6636           0 : uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
    6637             :                                                 throw(uno::RuntimeException, std::exception)
    6638             : {
    6639             :     //  sowas gibts nicht im Calc (?)
    6640           0 :     return NULL;
    6641             : }
    6642             : 
    6643             : // XPropertySet erweitert fuer Zell-Properties
    6644             : 
    6645         634 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
    6646             :                                                         throw(uno::RuntimeException, std::exception)
    6647             : {
    6648         634 :     SolarMutexGuard aGuard;
    6649             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    6650         634 :         new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
    6651         634 :     return aRef;
    6652             : }
    6653             : 
    6654          96 : void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    6655             :                                 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    6656             : {
    6657          96 :     if ( pEntry )
    6658             :     {
    6659          96 :         if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
    6660             :         {
    6661           4 :             OUString aStrVal;
    6662           4 :             aValue >>= aStrVal;
    6663           8 :             OUString aString(aStrVal);
    6664           8 :             SetString_Impl(aString, true, false);   // lokal interpretieren
    6665             :         }
    6666          92 :         else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
    6667             :         {
    6668             :             //  Read-Only
    6669             :             //! Exception oder so...
    6670             :         }
    6671             :         else
    6672          90 :             ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
    6673             :     }
    6674          96 : }
    6675             : 
    6676       16262 : void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    6677             :     throw(uno::RuntimeException, std::exception)
    6678             : {
    6679       16262 :     if ( pEntry )
    6680             :     {
    6681       16262 :         if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
    6682             :         {
    6683             :             // sal_False = lokal
    6684          20 :             rAny <<= OUString( GetInputString_Impl(false) );
    6685             :         }
    6686       16242 :         else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
    6687             :         {
    6688          98 :             table::CellContentType eType = GetResultType_Impl();
    6689          98 :             rAny <<= eType;
    6690             :         }
    6691             :         else
    6692       16144 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    6693             :     }
    6694       16262 : }
    6695             : 
    6696       15310 : const SfxItemPropertyMap& ScCellObj::GetItemPropertyMap()
    6697             : {
    6698       15310 :     return pCellPropSet->getPropertyMap();
    6699             : }
    6700             : 
    6701             : // XServiceInfo
    6702             : 
    6703          26 : OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    6704             : {
    6705          26 :     return OUString( "ScCellObj" );
    6706             : }
    6707             : 
    6708          34 : sal_Bool SAL_CALL ScCellObj::supportsService( const OUString& rServiceName )
    6709             :                                                     throw(uno::RuntimeException, std::exception)
    6710             : {
    6711          34 :     return cppu::supportsService(this, rServiceName);
    6712             : }
    6713             : 
    6714          34 : uno::Sequence<OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
    6715             :                                                     throw(uno::RuntimeException, std::exception)
    6716             : {
    6717          34 :     uno::Sequence<OUString> aRet(7);
    6718          34 :     OUString* pArray = aRet.getArray();
    6719          34 :     pArray[0] = OUString( SCSHEETCELL_SERVICE );
    6720          34 :     pArray[1] = OUString( SCCELL_SERVICE );
    6721          34 :     pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
    6722          34 :     pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
    6723          34 :     pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
    6724          34 :     pArray[5] = OUString( SCSHEETCELLRANGE_SERVICE );
    6725          34 :     pArray[6] = OUString( SCCELLRANGE_SERVICE );
    6726          34 :     return aRet;
    6727             : }
    6728             : 
    6729             : // XActionLockable
    6730             : 
    6731           6 : sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException, std::exception)
    6732             : {
    6733           6 :     SolarMutexGuard aGuard;
    6734           6 :     return nActionLockCount != 0;
    6735             : }
    6736             : 
    6737           4 : void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException, std::exception)
    6738             : {
    6739           4 :     SolarMutexGuard aGuard;
    6740           4 :     if (!nActionLockCount)
    6741             :     {
    6742           4 :         if (mxUnoText.is())
    6743             :         {
    6744             :             ScCellEditSource* pEditSource =
    6745           0 :                 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6746           0 :             if (pEditSource)
    6747           0 :                 pEditSource->SetDoUpdateData(false);
    6748             :         }
    6749             :     }
    6750           4 :     nActionLockCount++;
    6751           4 : }
    6752             : 
    6753           2 : void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException, std::exception)
    6754             : {
    6755           2 :     SolarMutexGuard aGuard;
    6756           2 :     if (nActionLockCount > 0)
    6757             :     {
    6758           2 :         nActionLockCount--;
    6759           2 :         if (!nActionLockCount)
    6760             :         {
    6761           2 :             if (mxUnoText.is())
    6762             :             {
    6763             :                 ScCellEditSource* pEditSource =
    6764           0 :                     static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6765           0 :                 if (pEditSource)
    6766             :                 {
    6767           0 :                     pEditSource->SetDoUpdateData(true);
    6768           0 :                     if (pEditSource->IsDirty())
    6769           0 :                         pEditSource->UpdateData();
    6770             :                 }
    6771             :             }
    6772             :         }
    6773           2 :     }
    6774           2 : }
    6775             : 
    6776           2 : void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException, std::exception)
    6777             : {
    6778           2 :     SolarMutexGuard aGuard;
    6779           2 :     if (mxUnoText.is())
    6780             :     {
    6781             :         ScCellEditSource* pEditSource =
    6782           0 :             static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6783           0 :         if (pEditSource)
    6784             :         {
    6785           0 :             pEditSource->SetDoUpdateData(nLock == 0);
    6786           0 :             if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
    6787           0 :                 pEditSource->UpdateData();
    6788             :         }
    6789             :     }
    6790           2 :     nActionLockCount = nLock;
    6791           2 : }
    6792             : 
    6793           2 : sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException, std::exception)
    6794             : {
    6795           2 :     SolarMutexGuard aGuard;
    6796           2 :     sal_uInt16 nRet(nActionLockCount);
    6797           2 :     if (mxUnoText.is())
    6798             :     {
    6799             :         ScCellEditSource* pEditSource =
    6800           0 :             static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
    6801           0 :         if (pEditSource)
    6802             :         {
    6803           0 :             pEditSource->SetDoUpdateData(true);
    6804           0 :             if (pEditSource->IsDirty())
    6805           0 :                 pEditSource->UpdateData();
    6806             :         }
    6807             :     }
    6808           2 :     nActionLockCount = 0;
    6809           2 :     return nRet;
    6810             : }
    6811             : 
    6812        6236 : ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
    6813             :     ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
    6814        6236 :     pSheetPropSet(lcl_GetSheetPropertySet())
    6815             : {
    6816        6236 : }
    6817             : 
    6818       12160 : ScTableSheetObj::~ScTableSheetObj()
    6819             : {
    6820       12160 : }
    6821             : 
    6822           0 : void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
    6823             : {
    6824           0 :     InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
    6825           0 : }
    6826             : 
    6827       90067 : uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    6828             : {
    6829       90067 :     SC_QUERYINTERFACE( sheet::XSpreadsheet )
    6830       88079 :     SC_QUERYINTERFACE( container::XNamed )
    6831       87525 :     SC_QUERYINTERFACE( sheet::XSheetPageBreak )
    6832       87519 :     SC_QUERYINTERFACE( sheet::XCellRangeMovement )
    6833       87507 :     SC_QUERYINTERFACE( table::XTableChartsSupplier )
    6834       87403 :     SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
    6835       87321 :     SC_QUERYINTERFACE( sheet::XScenariosSupplier )
    6836       87319 :     SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
    6837       87297 :     SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
    6838       86553 :     SC_QUERYINTERFACE( sheet::XPrintAreas )
    6839       86489 :     SC_QUERYINTERFACE( sheet::XSheetAuditing )
    6840       86487 :     SC_QUERYINTERFACE( sheet::XSheetOutline )
    6841       86445 :     SC_QUERYINTERFACE( util::XProtectable )
    6842       86389 :     SC_QUERYINTERFACE( sheet::XScenario )
    6843       86389 :     SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
    6844       86389 :     SC_QUERYINTERFACE( sheet::XSheetLinkable )
    6845       86329 :     SC_QUERYINTERFACE( sheet::XExternalSheetName )
    6846       86329 :     SC_QUERYINTERFACE( document::XEventsSupplier )
    6847             : 
    6848       86329 :     return ScCellRangeObj::queryInterface( rType );
    6849             : }
    6850             : 
    6851      287215 : void SAL_CALL ScTableSheetObj::acquire() throw()
    6852             : {
    6853      287215 :     ScCellRangeObj::acquire();
    6854      287215 : }
    6855             : 
    6856      287059 : void SAL_CALL ScTableSheetObj::release() throw()
    6857             : {
    6858      287059 :     ScCellRangeObj::release();
    6859      287059 : }
    6860             : 
    6861           8 : uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException, std::exception)
    6862             : {
    6863           8 :     static uno::Sequence<uno::Type> aTypes;
    6864           8 :     if ( aTypes.getLength() == 0 )
    6865             :     {
    6866           4 :         uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
    6867           4 :         long nParentLen = aParentTypes.getLength();
    6868           4 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    6869             : 
    6870           4 :         aTypes.realloc( nParentLen + 18 );
    6871           4 :         uno::Type* pPtr = aTypes.getArray();
    6872           4 :         pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSpreadsheet>::get();
    6873           4 :         pPtr[nParentLen + 1] = cppu::UnoType<container::XNamed>::get();
    6874           4 :         pPtr[nParentLen + 2] = cppu::UnoType<sheet::XSheetPageBreak>::get();
    6875           4 :         pPtr[nParentLen + 3] = cppu::UnoType<sheet::XCellRangeMovement>::get();
    6876           4 :         pPtr[nParentLen + 4] = cppu::UnoType<table::XTableChartsSupplier>::get();
    6877           4 :         pPtr[nParentLen + 5] = cppu::UnoType<sheet::XDataPilotTablesSupplier>::get();
    6878           4 :         pPtr[nParentLen + 6] = cppu::UnoType<sheet::XScenariosSupplier>::get();
    6879           4 :         pPtr[nParentLen + 7] = cppu::UnoType<sheet::XSheetAnnotationsSupplier>::get();
    6880           4 :         pPtr[nParentLen + 8] = cppu::UnoType<drawing::XDrawPageSupplier>::get();
    6881           4 :         pPtr[nParentLen + 9] = cppu::UnoType<sheet::XPrintAreas>::get();
    6882           4 :         pPtr[nParentLen +10] = cppu::UnoType<sheet::XSheetAuditing>::get();
    6883           4 :         pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetOutline>::get();
    6884           4 :         pPtr[nParentLen +12] = cppu::UnoType<util::XProtectable>::get();
    6885           4 :         pPtr[nParentLen +13] = cppu::UnoType<sheet::XScenario>::get();
    6886           4 :         pPtr[nParentLen +14] = cppu::UnoType<sheet::XScenarioEnhanced>::get();
    6887           4 :         pPtr[nParentLen +15] = cppu::UnoType<sheet::XSheetLinkable>::get();
    6888           4 :         pPtr[nParentLen +16] = cppu::UnoType<sheet::XExternalSheetName>::get();
    6889           4 :         pPtr[nParentLen +17] = cppu::UnoType<document::XEventsSupplier>::get();
    6890             : 
    6891         124 :         for (long i=0; i<nParentLen; i++)
    6892         124 :             pPtr[i] = pParentPtr[i];                // parent types first
    6893             :     }
    6894           8 :     return aTypes;
    6895             : }
    6896             : 
    6897           0 : uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException, std::exception)
    6898             : {
    6899           0 :     return css::uno::Sequence<sal_Int8>();
    6900             : }
    6901             : 
    6902             : //  Hilfsfunktionen
    6903             : 
    6904       12068 : SCTAB ScTableSheetObj::GetTab_Impl() const
    6905             : {
    6906       12068 :     const ScRangeList& rRanges = GetRangeList();
    6907             :     OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
    6908       12068 :     if ( !rRanges.empty() )
    6909             :     {
    6910       12068 :         const ScRange* pFirst = rRanges[ 0 ];
    6911       12068 :         return pFirst->aStart.Tab();
    6912             :     }
    6913           0 :     return 0;   // soll nicht sein
    6914             : }
    6915             : 
    6916             : // former XSheet
    6917             : 
    6918         104 : uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException, std::exception)
    6919             : {
    6920         104 :     SolarMutexGuard aGuard;
    6921         104 :     ScDocShell* pDocSh = GetDocShell();
    6922         104 :     if ( pDocSh )
    6923         104 :         return new ScChartsObj( pDocSh, GetTab_Impl() );
    6924             : 
    6925             :     OSL_FAIL("kein Dokument");
    6926           0 :     return NULL;
    6927             : }
    6928             : 
    6929          96 : uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
    6930             :                                                 throw(uno::RuntimeException, std::exception)
    6931             : {
    6932          96 :     SolarMutexGuard aGuard;
    6933          96 :     ScDocShell* pDocSh = GetDocShell();
    6934          96 :     if ( pDocSh )
    6935          96 :         return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
    6936             : 
    6937             :     OSL_FAIL("kein Dokument");
    6938           0 :     return NULL;
    6939             : }
    6940             : 
    6941           4 : uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException, std::exception)
    6942             : {
    6943           4 :     SolarMutexGuard aGuard;
    6944           4 :     ScDocShell* pDocSh = GetDocShell();
    6945             : 
    6946           4 :     if ( pDocSh )
    6947           4 :         return new ScScenariosObj( pDocSh, GetTab_Impl() );
    6948             : 
    6949             :     OSL_FAIL("kein Dokument");
    6950           0 :     return NULL;
    6951             : }
    6952             : 
    6953          22 : uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
    6954             :                                                 throw(uno::RuntimeException, std::exception)
    6955             : {
    6956          22 :     SolarMutexGuard aGuard;
    6957          22 :     ScDocShell* pDocSh = GetDocShell();
    6958             : 
    6959          22 :     if ( pDocSh )
    6960          22 :         return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
    6961             : 
    6962             :     OSL_FAIL("kein Dokument");
    6963           0 :     return NULL;
    6964             : }
    6965             : 
    6966         186 : uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
    6967             :                         const OUString& rRange ) throw(uno::RuntimeException, std::exception)
    6968             : {
    6969         186 :     SolarMutexGuard aGuard;
    6970         186 :     return ScCellRangeObj::getCellRangeByName( rRange );
    6971             : }
    6972             : 
    6973         120 : uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
    6974             :                                                 throw(uno::RuntimeException, std::exception)
    6975             : {
    6976         120 :     SolarMutexGuard aGuard;
    6977         120 :     ScDocShell* pDocSh = GetDocShell();
    6978         120 :     if ( pDocSh )
    6979             :     {
    6980             :         //! einzelne Zelle oder ganze Tabelle???????
    6981         120 :         SCTAB nTab = GetTab_Impl();
    6982         120 :         return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
    6983             :     }
    6984           0 :     return NULL;
    6985             : }
    6986             : 
    6987         478 : uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
    6988             :                         const uno::Reference<sheet::XSheetCellRange>& xCellRange )
    6989             :                                                 throw(uno::RuntimeException, std::exception)
    6990             : {
    6991         478 :     SolarMutexGuard aGuard;
    6992         478 :     ScDocShell* pDocSh = GetDocShell();
    6993         478 :     if ( pDocSh && xCellRange.is() )
    6994             :     {
    6995         478 :         ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
    6996         478 :         if (pRangesImp)
    6997             :         {
    6998         478 :             const ScRangeList& rRanges = pRangesImp->GetRangeList();
    6999             :             OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
    7000         478 :             return new ScCellCursorObj( pDocSh, *rRanges[ 0 ] );
    7001             :         }
    7002             :     }
    7003           0 :     return NULL;
    7004             : }
    7005             : 
    7006             : // XSheetCellRange
    7007             : 
    7008        2544 : uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
    7009             :                                                 throw(uno::RuntimeException, std::exception)
    7010             : {
    7011        2544 :     SolarMutexGuard aGuard;
    7012        2544 :     return this;        //!???
    7013             : }
    7014             : 
    7015             : // XCellRange
    7016             : 
    7017        8212 : uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
    7018             :                                         sal_Int32 nColumn, sal_Int32 nRow )
    7019             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    7020             : {
    7021        8212 :     SolarMutexGuard aGuard;
    7022        8212 :     return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
    7023             : }
    7024             : 
    7025       11454 : uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
    7026             :                 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
    7027             :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
    7028             : {
    7029       11454 :     SolarMutexGuard aGuard;
    7030       11454 :     return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
    7031             : }
    7032             : 
    7033          12 : uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
    7034             :                                                 throw(uno::RuntimeException, std::exception)
    7035             : {
    7036          12 :     SolarMutexGuard aGuard;
    7037          12 :     ScDocShell* pDocSh = GetDocShell();
    7038          12 :     if ( pDocSh )
    7039             :     {
    7040          12 :         ScDocument& rDoc = pDocSh->GetDocument();
    7041          12 :         SCTAB nTab = GetTab_Impl();
    7042             : 
    7043          12 :         Size aSize(rDoc.GetPageSize( nTab ));
    7044          12 :         if (aSize.Width() && aSize.Height())        // effektive Groesse schon gesetzt?
    7045          12 :             rDoc.UpdatePageBreaks( nTab );
    7046             :         else
    7047             :         {
    7048             :             //  Umbrueche updaten wie in ScDocShell::PageStyleModified:
    7049           0 :             ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
    7050           0 :             aPrintFunc.UpdatePages();
    7051             :         }
    7052             : 
    7053          12 :         SCCOL nCount = 0;
    7054             :         SCCOL nCol;
    7055       12300 :         for (nCol=0; nCol<=MAXCOL; nCol++)
    7056       12288 :             if (rDoc.HasColBreak(nCol, nTab))
    7057          32 :                 ++nCount;
    7058             : 
    7059          12 :         sheet::TablePageBreakData aData;
    7060          12 :         uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
    7061          12 :         sheet::TablePageBreakData* pAry = aSeq.getArray();
    7062          12 :         sal_uInt16 nPos = 0;
    7063       12300 :         for (nCol=0; nCol<=MAXCOL; nCol++)
    7064             :         {
    7065       12288 :             ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
    7066       12288 :             if (nBreak)
    7067             :             {
    7068          32 :                 aData.Position    = nCol;
    7069          32 :                 aData.ManualBreak = (nBreak & BREAK_MANUAL);
    7070          32 :                 pAry[nPos] = aData;
    7071          32 :                 ++nPos;
    7072             :             }
    7073             :         }
    7074          12 :         return aSeq;
    7075             :     }
    7076           0 :     return uno::Sequence<sheet::TablePageBreakData>(0);
    7077             : }
    7078             : 
    7079          12 : uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
    7080             :                                                 throw(uno::RuntimeException, std::exception)
    7081             : {
    7082          12 :     SolarMutexGuard aGuard;
    7083          12 :     ScDocShell* pDocSh = GetDocShell();
    7084          12 :     if ( pDocSh )
    7085             :     {
    7086          12 :         ScDocument& rDoc = pDocSh->GetDocument();
    7087          12 :         SCTAB nTab = GetTab_Impl();
    7088             : 
    7089          12 :         Size aSize(rDoc.GetPageSize( nTab ));
    7090          12 :         if (aSize.Width() && aSize.Height())        // effektive Groesse schon gesetzt?
    7091          10 :             rDoc.UpdatePageBreaks( nTab );
    7092             :         else
    7093             :         {
    7094             :             //  Umbrueche updaten wie in ScDocShell::PageStyleModified:
    7095           2 :             ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
    7096           2 :             aPrintFunc.UpdatePages();
    7097             :         }
    7098          12 :         return rDoc.GetRowBreakData(nTab);
    7099             :     }
    7100           0 :     return uno::Sequence<sheet::TablePageBreakData>(0);
    7101             : }
    7102             : 
    7103           0 : void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException, std::exception)
    7104             : {
    7105           0 :     SolarMutexGuard aGuard;
    7106           0 :     ScDocShell* pDocSh = GetDocShell();
    7107           0 :     if ( pDocSh )
    7108             :     {
    7109             :         //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
    7110             : 
    7111           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    7112           0 :         bool bUndo (rDoc.IsUndoEnabled());
    7113           0 :         SCTAB nTab = GetTab_Impl();
    7114             : 
    7115           0 :         if (bUndo)
    7116             :         {
    7117           0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    7118           0 :             pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
    7119           0 :             rDoc.CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, false, pUndoDoc );
    7120           0 :             pDocSh->GetUndoManager()->AddUndoAction(
    7121           0 :                                     new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
    7122             :         }
    7123             : 
    7124           0 :         rDoc.RemoveManualBreaks(nTab);
    7125           0 :         rDoc.UpdatePageBreaks(nTab);
    7126             : 
    7127             :         //? UpdatePageBreakData( sal_True );
    7128           0 :         pDocSh->SetDocumentModified();
    7129           0 :         pDocSh->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PAINT_GRID);
    7130           0 :     }
    7131           0 : }
    7132             : 
    7133             : // XNamed
    7134             : 
    7135         550 : OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException, std::exception)
    7136             : {
    7137         550 :     SolarMutexGuard aGuard;
    7138         550 :     OUString aName;
    7139         550 :     ScDocShell* pDocSh = GetDocShell();
    7140         550 :     if ( pDocSh )
    7141         550 :         pDocSh->GetDocument().GetName( GetTab_Impl(), aName );
    7142         550 :     return aName;
    7143             : }
    7144             : 
    7145          24 : void SAL_CALL ScTableSheetObj::setName( const OUString& aNewName )
    7146             :                                                 throw(uno::RuntimeException, std::exception)
    7147             : {
    7148          24 :     SolarMutexGuard aGuard;
    7149          24 :     ScDocShell* pDocSh = GetDocShell();
    7150          24 :     if ( pDocSh )
    7151             :     {
    7152          24 :         OUString aString(aNewName);
    7153          24 :         pDocSh->GetDocFunc().RenameTable( GetTab_Impl(), aString, true, true );
    7154          24 :     }
    7155          24 : }
    7156             : 
    7157             : // XDrawPageSupplier
    7158             : 
    7159         744 : uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
    7160             :                                                 throw(uno::RuntimeException, std::exception)
    7161             : {
    7162         744 :     SolarMutexGuard aGuard;
    7163         744 :     ScDocShell* pDocSh = GetDocShell();
    7164         744 :     if ( pDocSh )
    7165             :     {
    7166         744 :         ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
    7167             :         OSL_ENSURE(pDrawLayer,"kann Draw-Layer nicht anlegen");
    7168             : 
    7169         744 :         SCTAB nTab = GetTab_Impl();
    7170         744 :         SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
    7171             :         OSL_ENSURE(pPage,"Draw-Page nicht gefunden");
    7172         744 :         if (pPage)
    7173         744 :             return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
    7174             : 
    7175             :         //  Das DrawPage-Objekt meldet sich als Listener am SdrModel an
    7176             :         //  und sollte von dort alle Aktionen mitbekommen
    7177             :     }
    7178           0 :     return NULL;
    7179             : }
    7180             : 
    7181             : // XCellMovement
    7182             : 
    7183           2 : void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
    7184             :                                 sheet::CellInsertMode nMode ) throw(uno::RuntimeException, std::exception)
    7185             : {
    7186           2 :     SolarMutexGuard aGuard;
    7187           2 :     ScDocShell* pDocSh = GetDocShell();
    7188           2 :     if ( pDocSh )
    7189             :     {
    7190           2 :         bool bDo = true;
    7191           2 :         InsCellCmd eCmd = INS_NONE;
    7192           2 :         switch (nMode)
    7193             :         {
    7194           0 :             case sheet::CellInsertMode_NONE:    bDo = false;            break;
    7195           0 :             case sheet::CellInsertMode_DOWN:    eCmd = INS_CELLSDOWN;   break;
    7196           2 :             case sheet::CellInsertMode_RIGHT:   eCmd = INS_CELLSRIGHT;  break;
    7197           0 :             case sheet::CellInsertMode_ROWS:    eCmd = INS_INSROWS;     break;
    7198           0 :             case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS;     break;
    7199             :             default:
    7200             :                 OSL_FAIL("insertCells: falscher Mode");
    7201           0 :                 bDo = false;
    7202             :         }
    7203             : 
    7204           2 :         if (bDo)
    7205             :         {
    7206             :             OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7207           2 :             ScRange aScRange;
    7208           2 :             ScUnoConversion::FillScRange( aScRange, rRangeAddress );
    7209           2 :             pDocSh->GetDocFunc().InsertCells( aScRange, NULL, eCmd, true, true );
    7210             :         }
    7211           2 :     }
    7212           2 : }
    7213             : 
    7214           6 : void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
    7215             :                                 sheet::CellDeleteMode nMode ) throw(uno::RuntimeException, std::exception)
    7216             : {
    7217           6 :     SolarMutexGuard aGuard;
    7218           6 :     ScDocShell* pDocSh = GetDocShell();
    7219           6 :     if ( pDocSh )
    7220             :     {
    7221           6 :         bool bDo = true;
    7222           6 :         DelCellCmd eCmd = DEL_NONE;
    7223           6 :         switch (nMode)
    7224             :         {
    7225           0 :             case sheet::CellDeleteMode_NONE:     bDo = false;           break;
    7226           2 :             case sheet::CellDeleteMode_UP:       eCmd = DEL_CELLSUP;    break;
    7227           4 :             case sheet::CellDeleteMode_LEFT:     eCmd = DEL_CELLSLEFT;  break;
    7228           0 :             case sheet::CellDeleteMode_ROWS:     eCmd = DEL_DELROWS;    break;
    7229           0 :             case sheet::CellDeleteMode_COLUMNS:  eCmd = DEL_DELCOLS;    break;
    7230             :             default:
    7231             :                 OSL_FAIL("deleteCells: falscher Mode");
    7232           0 :                 bDo = false;
    7233             :         }
    7234             : 
    7235           6 :         if (bDo)
    7236             :         {
    7237             :             OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7238           6 :             ScRange aScRange;
    7239           6 :             ScUnoConversion::FillScRange( aScRange, rRangeAddress );
    7240           6 :             pDocSh->GetDocFunc().DeleteCells( aScRange, NULL, eCmd, true, true );
    7241             :         }
    7242           6 :     }
    7243           6 : }
    7244             : 
    7245           2 : void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
    7246             :                                         const table::CellRangeAddress& aSource )
    7247             :                                         throw(uno::RuntimeException, std::exception)
    7248             : {
    7249           2 :     SolarMutexGuard aGuard;
    7250           2 :     ScDocShell* pDocSh = GetDocShell();
    7251           2 :     if ( pDocSh )
    7252             :     {
    7253             :         OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7254           2 :         ScRange aSourceRange;
    7255           2 :         ScUnoConversion::FillScRange( aSourceRange, aSource );
    7256           2 :         ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
    7257           2 :         pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, true, true, true, true );
    7258           2 :     }
    7259           2 : }
    7260             : 
    7261           2 : void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
    7262             :                                         const table::CellRangeAddress& aSource )
    7263             :                                         throw(uno::RuntimeException, std::exception)
    7264             : {
    7265           2 :     SolarMutexGuard aGuard;
    7266           2 :     ScDocShell* pDocSh = GetDocShell();
    7267           2 :     if ( pDocSh )
    7268             :     {
    7269             :         OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
    7270           2 :         ScRange aSourceRange;
    7271           2 :         ScUnoConversion::FillScRange( aSourceRange, aSource );
    7272           2 :         ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
    7273           2 :         pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, true, true, true );
    7274           2 :     }
    7275           2 : }
    7276             : 
    7277             : // XPrintAreas
    7278             : 
    7279          12 : void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
    7280             : {
    7281             :     //  Umbrueche und Undo
    7282          12 :     ScDocShell* pDocSh = GetDocShell();
    7283             : 
    7284          12 :     if(pDocSh)
    7285             :     {
    7286          12 :         ScDocument& rDoc = pDocSh->GetDocument();
    7287          12 :         const bool bUndo(rDoc.IsUndoEnabled());
    7288          12 :         const SCTAB nTab(GetTab_Impl());
    7289             : 
    7290          12 :         if(bUndo)
    7291             :         {
    7292           4 :             pDocSh->GetUndoManager()->AddUndoAction(
    7293             :                 new ScUndoPrintRange(
    7294             :                     pDocSh,
    7295             :                     nTab,
    7296             :                     pOldRanges,
    7297           4 :                     rDoc.CreatePrintRangeSaver())); // create new ranges
    7298             : 
    7299             :             // #i120105# ownership of old ranges has changed, mark as consumed
    7300           4 :             pOldRanges = 0;
    7301             :         }
    7302             : 
    7303          12 :         ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
    7304          12 :         SfxBindings* pBindings = pDocSh->GetViewBindings();
    7305             : 
    7306          12 :         if(pBindings)
    7307             :         {
    7308           4 :             pBindings->Invalidate(SID_DELETE_PRINTAREA);
    7309             :         }
    7310             : 
    7311          12 :         pDocSh->SetDocumentModified();
    7312             :     }
    7313             : 
    7314             :     // #i120105# pOldRanges not used, need to cleanup
    7315          12 :     delete pOldRanges;
    7316          12 : }
    7317             : 
    7318          56 : uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
    7319             :                                                 throw(uno::RuntimeException, std::exception)
    7320             : {
    7321          56 :     SolarMutexGuard aGuard;
    7322          56 :     ScDocShell* pDocSh = GetDocShell();
    7323          56 :     if ( pDocSh )
    7324             :     {
    7325          56 :         ScDocument& rDoc = pDocSh->GetDocument();
    7326          56 :         SCTAB nTab = GetTab_Impl();
    7327          56 :         sal_uInt16 nCount = rDoc.GetPrintRangeCount( nTab );
    7328             : 
    7329          56 :         table::CellRangeAddress aRangeAddress;
    7330          56 :         uno::Sequence<table::CellRangeAddress> aSeq(nCount);
    7331          56 :         table::CellRangeAddress* pAry = aSeq.getArray();
    7332          56 :         for (sal_uInt16 i=0; i<nCount; i++)
    7333             :         {
    7334           0 :             const ScRange* pRange = rDoc.GetPrintRange( nTab, i );
    7335             :             OSL_ENSURE(pRange,"wo ist der Druckbereich");
    7336           0 :             if (pRange)
    7337             :             {
    7338           0 :                 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
    7339           0 :                 aRangeAddress.Sheet = nTab; // core does not care about sheet index
    7340           0 :                 pAry[i] = aRangeAddress;
    7341             :             }
    7342             :         }
    7343          56 :         return aSeq;
    7344             :     }
    7345           0 :     return uno::Sequence<table::CellRangeAddress>();
    7346             : }
    7347             : 
    7348           0 : void SAL_CALL ScTableSheetObj::setPrintAreas(
    7349             :                     const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
    7350             :                                                 throw(uno::RuntimeException, std::exception)
    7351             : {
    7352           0 :     SolarMutexGuard aGuard;
    7353           0 :     ScPrintRangeSaver* pOldRanges = NULL;
    7354           0 :     ScDocShell* pDocSh = GetDocShell();
    7355           0 :     if ( pDocSh )
    7356             :     {
    7357           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    7358           0 :         SCTAB nTab = GetTab_Impl();
    7359             : 
    7360           0 :         if ( rDoc.IsUndoEnabled() )
    7361           0 :             pOldRanges = rDoc.CreatePrintRangeSaver();
    7362             : 
    7363           0 :         sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength();
    7364           0 :         rDoc.ClearPrintRanges( nTab );
    7365           0 :         if (nCount)
    7366             :         {
    7367           0 :             ScRange aPrintRange;
    7368           0 :             const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
    7369           0 :             for (sal_uInt16 i=0; i<nCount; i++)
    7370             :             {
    7371           0 :                 ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
    7372           0 :                 rDoc.AddPrintRange( nTab, aPrintRange );
    7373             :             }
    7374             :         }
    7375             : 
    7376           0 :         if ( rDoc.IsUndoEnabled() )
    7377           0 :             PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
    7378           0 :     }
    7379           0 : }
    7380             : 
    7381          58 : sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException, std::exception)
    7382             : {
    7383          58 :     SolarMutexGuard aGuard;
    7384          58 :     ScDocShell* pDocSh = GetDocShell();
    7385          58 :     if ( pDocSh )
    7386             :     {
    7387          58 :         ScDocument& rDoc = pDocSh->GetDocument();
    7388          58 :         SCTAB nTab = GetTab_Impl();
    7389          58 :         return ( rDoc.GetRepeatColRange(nTab) != NULL );
    7390             :     }
    7391           0 :     return false;
    7392             : }
    7393             : 
    7394           2 : void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
    7395             :                                                     throw(uno::RuntimeException, std::exception)
    7396             : {
    7397           2 :     SolarMutexGuard aGuard;
    7398           2 :     ScDocShell* pDocSh = GetDocShell();
    7399           2 :     if ( pDocSh )
    7400             :     {
    7401           2 :         ScDocument& rDoc = pDocSh->GetDocument();
    7402           2 :         SCTAB nTab = GetTab_Impl();
    7403             : 
    7404           2 :         ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
    7405             : 
    7406           2 :         if ( bPrintTitleColumns )
    7407             :         {
    7408           2 :             if ( !rDoc.GetRepeatColRange( nTab ) )         // keinen bestehenden Bereich veraendern
    7409             :             {
    7410           2 :                 ScRange aNew( 0, 0, nTab, 0, 0, nTab );     // Default
    7411           2 :                 rDoc.SetRepeatColRange( nTab, &aNew );     // einschalten
    7412             :             }
    7413             :         }
    7414             :         else
    7415           0 :             rDoc.SetRepeatColRange( nTab, NULL );          // abschalten
    7416             : 
    7417           2 :         PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
    7418             : 
    7419             :         //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
    7420           2 :     }
    7421           2 : }
    7422             : 
    7423          56 : table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException, std::exception)
    7424             : {
    7425          56 :     SolarMutexGuard aGuard;
    7426          56 :     table::CellRangeAddress aRet;
    7427          56 :     ScDocShell* pDocSh = GetDocShell();
    7428          56 :     if ( pDocSh )
    7429             :     {
    7430          56 :         ScDocument& rDoc = pDocSh->GetDocument();
    7431          56 :         SCTAB nTab = GetTab_Impl();
    7432          56 :         const ScRange* pRange = rDoc.GetRepeatColRange(nTab);
    7433          56 :         if (pRange)
    7434             :         {
    7435           0 :             ScUnoConversion::FillApiRange( aRet, *pRange );
    7436           0 :             aRet.Sheet = nTab; // core does not care about sheet index
    7437             :         }
    7438             :     }
    7439          56 :     return aRet;
    7440             : }
    7441             : 
    7442           0 : void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
    7443             :                                                     throw(uno::RuntimeException, std::exception)
    7444             : {
    7445           0 :     SolarMutexGuard aGuard;
    7446           0 :     ScDocShell* pDocSh = GetDocShell();
    7447           0 :     if ( pDocSh )
    7448             :     {
    7449           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    7450           0 :         SCTAB nTab = GetTab_Impl();
    7451             : 
    7452           0 :         ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
    7453             : 
    7454           0 :         ScRange aNew;
    7455           0 :         ScUnoConversion::FillScRange( aNew, aTitleColumns );
    7456           0 :         rDoc.SetRepeatColRange( nTab, &aNew );     // immer auch einschalten
    7457             : 
    7458           0 :         PrintAreaUndo_Impl( pOldRanges );           // Undo, Umbrueche, Modified etc.
    7459           0 :     }
    7460           0 : }
    7461             : 
    7462          62 : sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException, std::exception)
    7463             : {
    7464          62 :     SolarMutexGuard aGuard;
    7465          62 :     ScDocShell* pDocSh = GetDocShell();
    7466          62 :     if ( pDocSh )
    7467             :     {
    7468          62 :         ScDocument& rDoc = pDocSh->GetDocument();
    7469          62 :         SCTAB nTab = GetTab_Impl();
    7470          62 :         return ( rDoc.GetRepeatRowRange(nTab) != NULL );
    7471             :     }
    7472           0 :     return false;
    7473             : }
    7474             : 
    7475           6 : void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
    7476             :                                                 throw(uno::RuntimeException, std::exception)
    7477             : {
    7478           6 :     SolarMutexGuard aGuard;
    7479           6 :     ScDocShell* pDocSh = GetDocShell();
    7480           6 :     if ( pDocSh )
    7481             :     {
    7482           6 :         ScDocument& rDoc = pDocSh->GetDocument();
    7483           6 :         SCTAB nTab = GetTab_Impl();
    7484             : 
    7485           6 :         ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
    7486             : 
    7487           6 :         if ( bPrintTitleRows )
    7488             :         {
    7489           6 :             if ( !rDoc.GetRepeatRowRange( nTab ) )         // keinen bestehenden Bereich veraendern
    7490             :             {
    7491           6 :                 ScRange aNew( 0, 0, nTab, 0, 0, nTab );     // Default
    7492           6 :                 rDoc.SetRepeatRowRange( nTab, &aNew );     // einschalten
    7493             :             }
    7494             :         }
    7495             :         else
    7496           0 :             rDoc.SetRepeatRowRange( nTab, NULL );          // abschalten
    7497             : 
    7498           6 :         PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
    7499             : 
    7500             :         //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
    7501           6 :     }
    7502           6 : }
    7503             : 
    7504          56 : table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException, std::exception)
    7505             : {
    7506          56 :     SolarMutexGuard aGuard;
    7507          56 :     table::CellRangeAddress aRet;
    7508          56 :     ScDocShell* pDocSh = GetDocShell();
    7509          56 :     if ( pDocSh )
    7510             :     {
    7511          56 :         ScDocument& rDoc = pDocSh->GetDocument();
    7512          56 :         SCTAB nTab = GetTab_Impl();
    7513          56 :         const ScRange* pRange = rDoc.GetRepeatRowRange(nTab);
    7514          56 :         if (pRange)
    7515             :         {
    7516           0 :             ScUnoConversion::FillApiRange( aRet, *pRange );
    7517           0 :             aRet.Sheet = nTab; // core does not care about sheet index
    7518             :         }
    7519             :     }
    7520          56 :     return aRet;
    7521             : }
    7522             : 
    7523           4 : void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
    7524             :                                                     throw(uno::RuntimeException, std::exception)
    7525             : {
    7526           4 :     SolarMutexGuard aGuard;
    7527           4 :     ScDocShell* pDocSh = GetDocShell();
    7528           4 :     if ( pDocSh )
    7529             :     {
    7530           4 :         ScDocument& rDoc = pDocSh->GetDocument();
    7531           4 :         SCTAB nTab = GetTab_Impl();
    7532             : 
    7533           4 :         ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
    7534             : 
    7535           4 :         ScRange aNew;
    7536           4 :         ScUnoConversion::FillScRange( aNew, aTitleRows );
    7537           4 :         rDoc.SetRepeatRowRange( nTab, &aNew );     // immer auch einschalten
    7538             : 
    7539           4 :         PrintAreaUndo_Impl( pOldRanges );           // Undo, Umbrueche, Modified etc.
    7540           4 :     }
    7541           4 : }
    7542             : 
    7543             : // XSheetLinkable
    7544             : 
    7545          56 : sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException, std::exception)
    7546             : {
    7547          56 :     SolarMutexGuard aGuard;
    7548          56 :     sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
    7549          56 :     ScDocShell* pDocSh = GetDocShell();
    7550          56 :     if ( pDocSh )
    7551             :     {
    7552          56 :         sal_uInt8 nMode = pDocSh->GetDocument().GetLinkMode( GetTab_Impl() );
    7553          56 :         if ( nMode == SC_LINK_NORMAL )
    7554           0 :             eRet = sheet::SheetLinkMode_NORMAL;
    7555          56 :         else if ( nMode == SC_LINK_VALUE )
    7556           0 :             eRet = sheet::SheetLinkMode_VALUE;
    7557             :     }
    7558          56 :     return eRet;
    7559             : }
    7560             : 
    7561           0 : void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
    7562             :                                                 throw(uno::RuntimeException, std::exception)
    7563             : {
    7564           0 :     SolarMutexGuard aGuard;
    7565             : 
    7566             :     //! Filter und Options aus altem Link suchen
    7567             : 
    7568           0 :     OUString aUrl(getLinkUrl());
    7569           0 :     OUString aSheet(getLinkSheetName());
    7570             : 
    7571           0 :     OUString aEmpty;
    7572           0 :     link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
    7573           0 : }
    7574             : 
    7575           0 : OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException, std::exception)
    7576             : {
    7577           0 :     SolarMutexGuard aGuard;
    7578           0 :     OUString aFile;
    7579           0 :     ScDocShell* pDocSh = GetDocShell();
    7580           0 :     if ( pDocSh )
    7581           0 :         aFile = pDocSh->GetDocument().GetLinkDoc( GetTab_Impl() );
    7582           0 :     return aFile;
    7583             : }
    7584             : 
    7585           0 : void SAL_CALL ScTableSheetObj::setLinkUrl( const OUString& aLinkUrl )
    7586             :                                                 throw(uno::RuntimeException, std::exception)
    7587             : {
    7588           0 :     SolarMutexGuard aGuard;
    7589             : 
    7590             :     //! Filter und Options aus altem Link suchen
    7591             : 
    7592           0 :     sheet::SheetLinkMode eMode = getLinkMode();
    7593           0 :     OUString aSheet(getLinkSheetName());
    7594             : 
    7595           0 :     OUString aEmpty;
    7596           0 :     link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
    7597           0 : }
    7598             : 
    7599           0 : OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException, std::exception)
    7600             : {
    7601           0 :     SolarMutexGuard aGuard;
    7602           0 :     OUString aSheet;
    7603           0 :     ScDocShell* pDocSh = GetDocShell();
    7604           0 :     if ( pDocSh )
    7605           0 :         aSheet = pDocSh->GetDocument().GetLinkTab( GetTab_Impl() );
    7606           0 :     return aSheet;
    7607             : }
    7608             : 
    7609           0 : void SAL_CALL ScTableSheetObj::setLinkSheetName( const OUString& aLinkSheetName )
    7610             :                                                 throw(uno::RuntimeException, std::exception)
    7611             : {
    7612           0 :     SolarMutexGuard aGuard;
    7613             : 
    7614             :     //! Filter und Options aus altem Link suchen
    7615             : 
    7616           0 :     sheet::SheetLinkMode eMode = getLinkMode();
    7617           0 :     OUString aUrl(getLinkUrl());
    7618             : 
    7619           0 :     OUString aEmpty;
    7620           0 :     link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
    7621           0 : }
    7622             : 
    7623           4 : void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aSheetName,
    7624             :                         const OUString& aFilterName, const OUString& aFilterOptions,
    7625             :                         sheet::SheetLinkMode nMode ) throw(uno::RuntimeException, std::exception)
    7626             : {
    7627           4 :     SolarMutexGuard aGuard;
    7628           4 :     ScDocShell* pDocSh = GetDocShell();
    7629           4 :     if ( pDocSh )
    7630             :     {
    7631           4 :         ScDocument& rDoc = pDocSh->GetDocument();
    7632           4 :         SCTAB nTab = GetTab_Impl();
    7633             : 
    7634           4 :         OUString aFileString = aUrl;
    7635           8 :         OUString aFilterString = aFilterName;
    7636           8 :         OUString aOptString = aFilterOptions;
    7637           8 :         OUString aSheetString = aSheetName;
    7638             : 
    7639           4 :         aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
    7640           4 :         if (aFilterString.isEmpty())
    7641           4 :             ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false );
    7642             : 
    7643             :         //  remove application prefix from filter name here, so the filter options
    7644             :         //  aren't reset when the filter name is changed in ScTableLink::DataChanged
    7645           4 :         ScDocumentLoader::RemoveAppPrefix( aFilterString );
    7646             : 
    7647           4 :         sal_uInt8 nLinkMode = SC_LINK_NONE;
    7648           4 :         if ( nMode == sheet::SheetLinkMode_NORMAL )
    7649           0 :             nLinkMode = SC_LINK_NORMAL;
    7650           4 :         else if ( nMode == sheet::SheetLinkMode_VALUE )
    7651           4 :             nLinkMode = SC_LINK_VALUE;
    7652             : 
    7653           4 :         sal_uLong nRefresh = 0;
    7654           4 :         rDoc.SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
    7655             : 
    7656           4 :         pDocSh->UpdateLinks();                  // ggf. Link eintragen oder loeschen
    7657           4 :         SfxBindings* pBindings = pDocSh->GetViewBindings();
    7658           4 :         if (pBindings)
    7659           4 :             pBindings->Invalidate(SID_LINKS);
    7660             : 
    7661             :         //! Undo fuer Link-Daten an der Table
    7662             : 
    7663           4 :         if ( nLinkMode != SC_LINK_NONE && rDoc.IsExecuteLinkEnabled() )        // Link updaten
    7664             :         {
    7665             :             //  Update immer, auch wenn der Link schon da war
    7666             :             //! Update nur fuer die betroffene Tabelle???
    7667             : 
    7668           4 :             sfx2::LinkManager* pLinkManager = rDoc.GetLinkManager();
    7669           4 :             sal_uInt16 nCount = pLinkManager->GetLinks().size();
    7670           8 :             for ( sal_uInt16 i=0; i<nCount; i++ )
    7671             :             {
    7672           4 :                 ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
    7673           4 :                 if (pBase->ISA(ScTableLink))
    7674             :                 {
    7675           4 :                     ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase);
    7676           4 :                     if ( aFileString.equals(pTabLink->GetFileName()) )
    7677           4 :                         pTabLink->Update();                         // inkl. Paint&Undo
    7678             : 
    7679             :                     //! Der Dateiname sollte nur einmal vorkommen (?)
    7680             :                 }
    7681             :             }
    7682           4 :         }
    7683             : 
    7684             :         //! Notify fuer ScSheetLinkObj Objekte!!!
    7685           4 :     }
    7686           4 : }
    7687             : 
    7688             : // XSheetAuditing
    7689             : 
    7690           0 : sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
    7691             :                                                 throw(uno::RuntimeException, std::exception)
    7692             : {
    7693           0 :     SolarMutexGuard aGuard;
    7694           0 :     ScDocShell* pDocSh = GetDocShell();
    7695           0 :     if ( pDocSh )
    7696             :     {
    7697           0 :         SCTAB nTab = GetTab_Impl();
    7698             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7699           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7700           0 :         return pDocSh->GetDocFunc().DetectiveDelSucc( aPos );
    7701             :     }
    7702           0 :     return false;
    7703             : }
    7704             : 
    7705           0 : sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
    7706             :                                             throw(uno::RuntimeException, std::exception)
    7707             : {
    7708           0 :     SolarMutexGuard aGuard;
    7709           0 :     ScDocShell* pDocSh = GetDocShell();
    7710           0 :     if ( pDocSh )
    7711             :     {
    7712           0 :         SCTAB nTab = GetTab_Impl();
    7713             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7714           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7715           0 :         return pDocSh->GetDocFunc().DetectiveDelPred( aPos );
    7716             :     }
    7717           0 :     return false;
    7718             : }
    7719             : 
    7720           0 : sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
    7721             :                                             throw(uno::RuntimeException, std::exception)
    7722             : {
    7723           0 :     SolarMutexGuard aGuard;
    7724           0 :     ScDocShell* pDocSh = GetDocShell();
    7725           0 :     if ( pDocSh )
    7726             :     {
    7727           0 :         SCTAB nTab = GetTab_Impl();
    7728             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7729           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7730           0 :         return pDocSh->GetDocFunc().DetectiveAddSucc( aPos );
    7731             :     }
    7732           0 :     return false;
    7733             : }
    7734             : 
    7735           2 : sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
    7736             :                                             throw(uno::RuntimeException, std::exception)
    7737             : {
    7738           2 :     SolarMutexGuard aGuard;
    7739           2 :     ScDocShell* pDocSh = GetDocShell();
    7740           2 :     if ( pDocSh )
    7741             :     {
    7742           2 :         SCTAB nTab = GetTab_Impl();
    7743             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7744           2 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7745           2 :         return pDocSh->GetDocFunc().DetectiveAddPred( aPos );
    7746             :     }
    7747           0 :     return false;
    7748             : }
    7749             : 
    7750           0 : sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
    7751             :                                             throw(uno::RuntimeException, std::exception)
    7752             : {
    7753           0 :     SolarMutexGuard aGuard;
    7754           0 :     ScDocShell* pDocSh = GetDocShell();
    7755           0 :     if ( pDocSh )
    7756             :     {
    7757           0 :         SCTAB nTab = GetTab_Impl();
    7758             :         OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
    7759           0 :         ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
    7760           0 :         return pDocSh->GetDocFunc().DetectiveAddError( aPos );
    7761             :     }
    7762           0 :     return false;
    7763             : }
    7764             : 
    7765           0 : sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException, std::exception)
    7766             : {
    7767           0 :     SolarMutexGuard aGuard;
    7768           0 :     ScDocShell* pDocSh = GetDocShell();
    7769           0 :     if ( pDocSh )
    7770           0 :         return pDocSh->GetDocFunc().DetectiveMarkInvalid( GetTab_Impl() );
    7771           0 :     return false;
    7772             : }
    7773             : 
    7774           0 : void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException, std::exception)
    7775             : {
    7776           0 :     SolarMutexGuard aGuard;
    7777           0 :     ScDocShell* pDocSh = GetDocShell();
    7778           0 :     if ( pDocSh )
    7779           0 :         pDocSh->GetDocFunc().DetectiveDelAll( GetTab_Impl() );
    7780           0 : }
    7781             : 
    7782             : // XSheetOutline
    7783             : 
    7784          16 : void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
    7785             :                                         table::TableOrientation nOrientation )
    7786             :                                     throw (uno::RuntimeException,
    7787             :                                            std::exception)
    7788             : {
    7789          16 :     SolarMutexGuard aGuard;
    7790          16 :     ScDocShell* pDocSh = GetDocShell();
    7791          16 :     if ( pDocSh )
    7792             :     {
    7793          16 :         bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
    7794          16 :         ScRange aGroupRange;
    7795          16 :         ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
    7796          16 :         ScOutlineDocFunc aFunc(*pDocSh);
    7797          16 :         aFunc.MakeOutline( aGroupRange, bColumns, true, true );
    7798          16 :     }
    7799          16 : }
    7800             : 
    7801           8 : void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
    7802             :                                         table::TableOrientation nOrientation )
    7803             :                                     throw (uno::RuntimeException,
    7804             :                                            std::exception)
    7805             : {
    7806           8 :     SolarMutexGuard aGuard;
    7807           8 :     ScDocShell* pDocSh = GetDocShell();
    7808           8 :     if ( pDocSh )
    7809             :     {
    7810           8 :         bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
    7811           8 :         ScRange aGroupRange;
    7812           8 :         ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
    7813           8 :         ScOutlineDocFunc aFunc(*pDocSh);
    7814           8 :         aFunc.RemoveOutline( aGroupRange, bColumns, true, true );
    7815           8 :     }
    7816           8 : }
    7817             : 
    7818           2 : void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
    7819             :     throw(uno::RuntimeException, std::exception)
    7820             : {
    7821           2 :     SolarMutexGuard aGuard;
    7822           2 :     ScDocShell* pDocSh = GetDocShell();
    7823           2 :     if ( pDocSh )
    7824             :     {
    7825           2 :         ScRange aFormulaRange;
    7826           2 :         ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
    7827           2 :         ScOutlineDocFunc aFunc(*pDocSh);
    7828           2 :         aFunc.AutoOutline( aFormulaRange, true );
    7829           2 :     }
    7830           2 : }
    7831             : 
    7832          14 : void SAL_CALL ScTableSheetObj::clearOutline()
    7833             :     throw(uno::RuntimeException, std::exception)
    7834             : {
    7835          14 :     SolarMutexGuard aGuard;
    7836          14 :     ScDocShell* pDocSh = GetDocShell();
    7837          14 :     if ( pDocSh )
    7838             :     {
    7839          14 :         SCTAB nTab = GetTab_Impl();
    7840          14 :         ScOutlineDocFunc aFunc(*pDocSh);
    7841          14 :         aFunc.RemoveAllOutlines( nTab, true );
    7842          14 :     }
    7843          14 : }
    7844             : 
    7845          26 : void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
    7846             :     throw(uno::RuntimeException, std::exception)
    7847             : {
    7848          26 :     SolarMutexGuard aGuard;
    7849          26 :     ScDocShell* pDocSh = GetDocShell();
    7850          26 :     if ( pDocSh )
    7851             :     {
    7852          26 :         ScRange aMarkRange;
    7853          26 :         ScUnoConversion::FillScRange( aMarkRange, rCellRange );
    7854          26 :         ScOutlineDocFunc aFunc(*pDocSh);
    7855          26 :         aFunc.HideMarkedOutlines( aMarkRange, true );
    7856          26 :     }
    7857          26 : }
    7858             : 
    7859          20 : void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
    7860             :     throw(uno::RuntimeException, std::exception)
    7861             : {
    7862          20 :     SolarMutexGuard aGuard;
    7863          20 :     ScDocShell* pDocSh = GetDocShell();
    7864          20 :     if ( pDocSh )
    7865             :     {
    7866          20 :         ScRange aMarkRange;
    7867          20 :         ScUnoConversion::FillScRange( aMarkRange, rCellRange );
    7868          20 :         ScOutlineDocFunc aFunc(*pDocSh);
    7869          20 :         aFunc.ShowMarkedOutlines( aMarkRange, true );
    7870          20 :     }
    7871          20 : }
    7872             : 
    7873           2 : void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
    7874             :     throw(uno::RuntimeException, std::exception)
    7875             : {
    7876           2 :     SolarMutexGuard aGuard;
    7877           2 :     ScDocShell* pDocSh = GetDocShell();
    7878           2 :     if ( pDocSh )
    7879             :     {
    7880           2 :         bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
    7881           2 :         SCTAB nTab = GetTab_Impl();
    7882           2 :         ScOutlineDocFunc aFunc(*pDocSh);
    7883           2 :         aFunc.SelectLevel( nTab, bColumns, nLevel, true, true );
    7884           2 :     }
    7885           2 : }
    7886             : 
    7887             : // XProtectable
    7888             : 
    7889           0 : void SAL_CALL ScTableSheetObj::protect( const OUString& aPassword )
    7890             :                                             throw(uno::RuntimeException, std::exception)
    7891             : {
    7892           0 :     SolarMutexGuard aGuard;
    7893           0 :     ScDocShell* pDocSh = GetDocShell();
    7894             :     // #i108245# if already protected, don't change anything
    7895           0 :     if ( pDocSh && !pDocSh->GetDocument().IsTabProtected( GetTab_Impl() ) )
    7896             :     {
    7897           0 :         OUString aString(aPassword);
    7898           0 :         pDocSh->GetDocFunc().Protect( GetTab_Impl(), aString, true );
    7899           0 :     }
    7900           0 : }
    7901             : 
    7902           0 : void SAL_CALL ScTableSheetObj::unprotect( const OUString& aPassword )
    7903             :                             throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    7904             : {
    7905           0 :     SolarMutexGuard aGuard;
    7906           0 :     ScDocShell* pDocSh = GetDocShell();
    7907           0 :     if ( pDocSh )
    7908             :     {
    7909           0 :         OUString aString(aPassword);
    7910           0 :         bool bDone = pDocSh->GetDocFunc().Unprotect( GetTab_Impl(), aString, true );
    7911           0 :         if (!bDone)
    7912           0 :             throw lang::IllegalArgumentException();
    7913           0 :     }
    7914           0 : }
    7915             : 
    7916          56 : sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException, std::exception)
    7917             : {
    7918          56 :     SolarMutexGuard aGuard;
    7919          56 :     ScDocShell* pDocSh = GetDocShell();
    7920          56 :     if ( pDocSh )
    7921          56 :         return pDocSh->GetDocument().IsTabProtected( GetTab_Impl() );
    7922             : 
    7923             :     OSL_FAIL("keine DocShell");     //! Exception oder so?
    7924           0 :     return false;
    7925             : }
    7926             : 
    7927             : // XScenario
    7928             : 
    7929           0 : sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException, std::exception)
    7930             : {
    7931           0 :     SolarMutexGuard aGuard;
    7932           0 :     ScDocShell* pDocSh = GetDocShell();
    7933           0 :     if ( pDocSh )
    7934           0 :         return pDocSh->GetDocument().IsScenario( GetTab_Impl() );
    7935             : 
    7936           0 :     return false;
    7937             : }
    7938             : 
    7939           0 : OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException, std::exception)
    7940             : {
    7941           0 :     SolarMutexGuard aGuard;
    7942           0 :     ScDocShell* pDocSh = GetDocShell();
    7943           0 :     if ( pDocSh )
    7944             :     {
    7945           0 :         OUString aComment;
    7946           0 :         Color  aColor;
    7947             :         sal_uInt16 nFlags;
    7948           0 :         pDocSh->GetDocument().GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
    7949           0 :         return aComment;
    7950             :     }
    7951           0 :     return OUString();
    7952             : }
    7953             : 
    7954           0 : void SAL_CALL ScTableSheetObj::setScenarioComment( const OUString& aScenarioComment )
    7955             :                                                 throw(uno::RuntimeException, std::exception)
    7956             : {
    7957           0 :     SolarMutexGuard aGuard;
    7958           0 :     ScDocShell* pDocSh = GetDocShell();
    7959           0 :     if ( pDocSh )
    7960             :     {
    7961           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    7962           0 :         SCTAB nTab = GetTab_Impl();
    7963             : 
    7964           0 :         OUString aName;
    7965           0 :         OUString aComment;
    7966           0 :         Color  aColor;
    7967             :         sal_uInt16 nFlags;
    7968           0 :         rDoc.GetName( nTab, aName );
    7969           0 :         rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    7970             : 
    7971           0 :         aComment = aScenarioComment;
    7972             : 
    7973           0 :         pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    7974           0 :     }
    7975           0 : }
    7976             : 
    7977           0 : void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
    7978             :                                                 throw(uno::RuntimeException, std::exception)
    7979             : {
    7980           0 :     SolarMutexGuard aGuard;
    7981           0 :     ScDocShell* pDocSh = GetDocShell();
    7982           0 :     if ( pDocSh )
    7983             :     {
    7984           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    7985           0 :         SCTAB nTab = GetTab_Impl();
    7986             : 
    7987           0 :         if (rDoc.IsScenario(nTab))
    7988             :         {
    7989           0 :             ScMarkData aMarkData;
    7990           0 :             aMarkData.SelectTable( nTab, true );
    7991             : 
    7992           0 :             sal_uInt16 nRangeCount = (sal_uInt16)rScenRanges.getLength();
    7993           0 :             if (nRangeCount)
    7994             :             {
    7995           0 :                 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
    7996           0 :                 for (sal_uInt16 i=0; i<nRangeCount; i++)
    7997             :                 {
    7998             :                     OSL_ENSURE( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
    7999           0 :                     ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
    8000           0 :                                        (SCCOL)pAry[i].EndColumn,   (SCROW)pAry[i].EndRow,   nTab );
    8001             : 
    8002           0 :                     aMarkData.SetMultiMarkArea( aOneRange );
    8003             :                 }
    8004             :             }
    8005             : 
    8006             :             //  Szenario-Ranges sind durch Attribut gekennzeichnet
    8007           0 :             ScPatternAttr aPattern( rDoc.GetPool() );
    8008           0 :             aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
    8009           0 :             aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
    8010           0 :             pDocSh->GetDocFunc().ApplyAttributes( aMarkData, aPattern, true, true );
    8011             :         }
    8012           0 :     }
    8013           0 : }
    8014             : 
    8015           0 : void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException, std::exception)
    8016             : {
    8017           0 :     SolarMutexGuard aGuard;
    8018           0 :     ScDocShell* pDocSh = GetDocShell();
    8019           0 :     if ( pDocSh )
    8020             :     {
    8021           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    8022           0 :         SCTAB nTab = GetTab_Impl();
    8023           0 :         OUString aName;
    8024           0 :         rDoc.GetName( nTab, aName );       // Name dieses Szenarios
    8025             : 
    8026           0 :         SCTAB nDestTab = nTab;
    8027           0 :         while ( nDestTab > 0 && rDoc.IsScenario(nDestTab) )
    8028           0 :             --nDestTab;
    8029             : 
    8030           0 :         if ( !rDoc.IsScenario(nDestTab) )
    8031           0 :             pDocSh->UseScenario( nDestTab, aName );
    8032             : 
    8033             :         //! sonst Fehler oder so
    8034           0 :     }
    8035           0 : }
    8036             : 
    8037             : // XScenarioEnhanced
    8038             : 
    8039           0 : uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges(  )
    8040             :                                     throw(uno::RuntimeException, std::exception)
    8041             : {
    8042           0 :     SolarMutexGuard aGuard;
    8043           0 :     ScDocShell* pDocSh = GetDocShell();
    8044           0 :     if ( pDocSh )
    8045             :     {
    8046           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    8047           0 :         SCTAB nTab = GetTab_Impl();
    8048           0 :         const ScRangeList* pRangeList = rDoc.GetScenarioRanges(nTab);
    8049           0 :         if (pRangeList)
    8050             :         {
    8051           0 :             size_t nCount = pRangeList->size();
    8052           0 :             uno::Sequence< table::CellRangeAddress > aRetRanges( nCount );
    8053           0 :             table::CellRangeAddress* pAry = aRetRanges.getArray();
    8054           0 :             for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
    8055             :             {
    8056           0 :                 const ScRange* pRange = (*pRangeList)[nIndex];
    8057           0 :                 pAry->StartColumn = pRange->aStart.Col();
    8058           0 :                 pAry->StartRow = pRange->aStart.Row();
    8059           0 :                 pAry->EndColumn = pRange->aEnd.Col();
    8060           0 :                 pAry->EndRow = pRange->aEnd.Row();
    8061           0 :                 pAry->Sheet = pRange->aStart.Tab();
    8062           0 :                 ++pAry;
    8063             :             }
    8064           0 :             return aRetRanges;
    8065             :         }
    8066             :     }
    8067           0 :     return uno::Sequence< table::CellRangeAddress > ();
    8068             : }
    8069             : 
    8070             : // XExternalSheetName
    8071             : 
    8072           0 : void ScTableSheetObj::setExternalName( const OUString& aUrl, const OUString& aSheetName )
    8073             :     throw (container::ElementExistException, uno::RuntimeException, std::exception)
    8074             : {
    8075           0 :     SolarMutexGuard aGuard;
    8076           0 :     ScDocShell* pDocSh = GetDocShell();
    8077           0 :     if ( pDocSh )
    8078             :     {
    8079           0 :         ScDocument& rDoc = pDocSh->GetDocument();
    8080           0 :         const SCTAB nTab = GetTab_Impl();
    8081           0 :         const OUString aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
    8082           0 :         const OUString aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
    8083           0 :         if ( !rDoc.RenameTab( nTab, aDocTabName, false /*bUpdateRef*/, true /*bExternalDocument*/ ) )
    8084             :         {
    8085           0 :             throw container::ElementExistException( OUString(), *this );
    8086           0 :         }
    8087           0 :     }
    8088           0 : }
    8089             : 
    8090             : // XEventsSupplier
    8091             : 
    8092           0 : uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() throw (uno::RuntimeException, std::exception)
    8093             : {
    8094           0 :     SolarMutexGuard aGuard;
    8095           0 :     ScDocShell* pDocSh = GetDocShell();
    8096           0 :     if ( pDocSh )
    8097           0 :         return new ScSheetEventsObj( pDocSh, GetTab_Impl() );
    8098             : 
    8099           0 :     return NULL;
    8100             : }
    8101             : 
    8102             : // XPropertySet erweitert fuer Sheet-Properties
    8103             : 
    8104         730 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
    8105             :                                                         throw(uno::RuntimeException, std::exception)
    8106             : {
    8107         730 :     SolarMutexGuard aGuard;
    8108             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    8109         730 :         new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
    8110         730 :     return aRef;
    8111             : }
    8112             : 
    8113        2572 : void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    8114             :     throw(lang::IllegalArgumentException, uno::RuntimeException,
    8115             :           std::exception)
    8116             : {
    8117        2572 :     if ( pEntry )
    8118             :     {
    8119        2572 :         if ( IsScItemWid( pEntry->nWID ) )
    8120             :         {
    8121             :             //  for Item WIDs, call ScCellRangesBase directly
    8122           0 :             ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
    8123           0 :             return;
    8124             :         }
    8125             : 
    8126             :         //  own properties
    8127             : 
    8128        2572 :         ScDocShell* pDocSh = GetDocShell();
    8129        2572 :         if (!pDocSh)
    8130           0 :             return;                                                 //! Exception oder so?
    8131        2572 :         ScDocument& rDoc = pDocSh->GetDocument();
    8132        2572 :         SCTAB nTab = GetTab_Impl();
    8133        2572 :         ScDocFunc &rFunc = pDocSh->GetDocFunc();
    8134             : 
    8135        2572 :         if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
    8136             :         {
    8137         574 :             OUString aStrVal;
    8138         574 :             aValue >>= aStrVal;
    8139             :             OUString aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
    8140        1148 :                                                 aStrVal, SFX_STYLE_FAMILY_PAGE ));
    8141             : 
    8142             :             //! Undo? (auch bei SID_STYLE_APPLY an der View)
    8143             : 
    8144         574 :             if ( rDoc.GetPageStyle( nTab ) != aNewStr )
    8145             :             {
    8146          78 :                 rDoc.SetPageStyle( nTab, aNewStr );
    8147          78 :                 if (!rDoc.IsImportingXML())
    8148             :                 {
    8149           4 :                     ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
    8150             : 
    8151           4 :                     SfxBindings* pBindings = pDocSh->GetViewBindings();
    8152           4 :                     if (pBindings)
    8153             :                     {
    8154           4 :                         pBindings->Invalidate( SID_STYLE_FAMILY4 );
    8155           4 :                         pBindings->Invalidate( SID_STATUS_PAGESTYLE );
    8156           4 :                         pBindings->Invalidate( FID_RESET_PRINTZOOM );
    8157           4 :                         pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
    8158           4 :                         pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
    8159             :                     }
    8160             :                 }
    8161          78 :                 pDocSh->SetDocumentModified();
    8162         574 :             }
    8163             :         }
    8164        1998 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8165             :         {
    8166         970 :             bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8167         970 :             rFunc.SetTableVisible( nTab, bVis, true );
    8168             :         }
    8169        1028 :         else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
    8170             :         {
    8171           0 :             if (rDoc.IsScenario(nTab))
    8172           0 :                 rDoc.SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
    8173             :         }
    8174        1028 :         else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
    8175             :         {
    8176           0 :             if (rDoc.IsScenario(nTab))
    8177             :             {
    8178           0 :                 sal_Int32 nNewColor = 0;
    8179           0 :                 if (aValue >>= nNewColor)
    8180             :                 {
    8181           0 :                     OUString aName;
    8182           0 :                     OUString aComment;
    8183           0 :                     Color  aColor;
    8184             :                     sal_uInt16 nFlags;
    8185           0 :                     rDoc.GetName( nTab, aName );
    8186           0 :                     rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8187             : 
    8188           0 :                     aColor = Color(static_cast<sal_uInt32>(nNewColor));
    8189             : 
    8190           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8191             :                 }
    8192             :             }
    8193             :         }
    8194        1028 :         else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
    8195             :         {
    8196           0 :             if (rDoc.IsScenario(nTab))
    8197             :             {
    8198           0 :                 OUString aName;
    8199           0 :                 OUString aComment;
    8200           0 :                 Color  aColor;
    8201             :                 sal_uInt16 nFlags;
    8202           0 :                 rDoc.GetName( nTab, aName );
    8203           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8204           0 :                 bool bModify(false);
    8205             : 
    8206           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8207             :                 {
    8208           0 :                     if (!(nFlags & SC_SCENARIO_PROTECT))
    8209             :                     {
    8210           0 :                         nFlags |= SC_SCENARIO_PROTECT;
    8211           0 :                         bModify = true;
    8212             :                     }
    8213             :                 }
    8214             :                 else
    8215             :                 {
    8216           0 :                     if (nFlags & SC_SCENARIO_PROTECT)
    8217             :                     {
    8218           0 :                         nFlags -= SC_SCENARIO_PROTECT;
    8219           0 :                         bModify = true;
    8220             :                     }
    8221             :                 }
    8222             : 
    8223           0 :                 if (bModify)
    8224           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8225             :             }
    8226             :         }
    8227        1028 :         else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
    8228             :         {
    8229           0 :             if (rDoc.IsScenario(nTab))
    8230             :             {
    8231           0 :                 OUString aName;
    8232           0 :                 OUString aComment;
    8233           0 :                 Color  aColor;
    8234             :                 sal_uInt16 nFlags;
    8235           0 :                 rDoc.GetName( nTab, aName );
    8236           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8237           0 :                 bool bModify(false);
    8238             : 
    8239           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8240             :                 {
    8241           0 :                     if (!(nFlags & SC_SCENARIO_SHOWFRAME))
    8242             :                     {
    8243           0 :                         nFlags |= SC_SCENARIO_SHOWFRAME;
    8244           0 :                         bModify = true;
    8245             :                     }
    8246             :                 }
    8247             :                 else
    8248             :                 {
    8249           0 :                     if (nFlags & SC_SCENARIO_SHOWFRAME)
    8250             :                     {
    8251           0 :                         nFlags -= SC_SCENARIO_SHOWFRAME;
    8252           0 :                         bModify = true;
    8253             :                     }
    8254             :                 }
    8255             : 
    8256           0 :                 if (bModify)
    8257           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8258             :             }
    8259             :         }
    8260        1028 :         else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
    8261             :         {
    8262           0 :             if (rDoc.IsScenario(nTab))
    8263             :             {
    8264           0 :                 OUString aName;
    8265           0 :                 OUString aComment;
    8266           0 :                 Color  aColor;
    8267             :                 sal_uInt16 nFlags;
    8268           0 :                 rDoc.GetName( nTab, aName );
    8269           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8270           0 :                 bool bModify(false);
    8271             : 
    8272           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8273             :                 {
    8274           0 :                     if (!(nFlags & SC_SCENARIO_PRINTFRAME))
    8275             :                     {
    8276           0 :                         nFlags |= SC_SCENARIO_PRINTFRAME;
    8277           0 :                         bModify = true;
    8278             :                     }
    8279             :                 }
    8280             :                 else
    8281             :                 {
    8282           0 :                     if (nFlags & SC_SCENARIO_PRINTFRAME)
    8283             :                     {
    8284           0 :                         nFlags -= SC_SCENARIO_PRINTFRAME;
    8285           0 :                         bModify = true;
    8286             :                     }
    8287             :                 }
    8288             : 
    8289           0 :                 if (bModify)
    8290           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8291             :             }
    8292             :         }
    8293        1028 :         else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
    8294             :         {
    8295           0 :             if (rDoc.IsScenario(nTab))
    8296             :             {
    8297           0 :                 OUString aName;
    8298           0 :                 OUString aComment;
    8299           0 :                 Color  aColor;
    8300             :                 sal_uInt16 nFlags;
    8301           0 :                 rDoc.GetName( nTab, aName );
    8302           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8303           0 :                 bool bModify(false);
    8304             : 
    8305           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8306             :                 {
    8307           0 :                     if (!(nFlags & SC_SCENARIO_TWOWAY))
    8308             :                     {
    8309           0 :                         nFlags |= SC_SCENARIO_TWOWAY;
    8310           0 :                         bModify = true;
    8311             :                     }
    8312             :                 }
    8313             :                 else
    8314             :                 {
    8315           0 :                     if (nFlags & SC_SCENARIO_TWOWAY)
    8316             :                     {
    8317           0 :                         nFlags -= SC_SCENARIO_TWOWAY;
    8318           0 :                         bModify = true;
    8319             :                     }
    8320             :                 }
    8321             : 
    8322           0 :                 if (bModify)
    8323           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8324             :             }
    8325             :         }
    8326        1028 :         else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
    8327             :         {
    8328           0 :             if (rDoc.IsScenario(nTab))
    8329             :             {
    8330           0 :                 OUString aName;
    8331           0 :                 OUString aComment;
    8332           0 :                 Color  aColor;
    8333             :                 sal_uInt16 nFlags;
    8334           0 :                 rDoc.GetName( nTab, aName );
    8335           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8336           0 :                 bool bModify(false);
    8337             : 
    8338           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8339             :                 {
    8340           0 :                     if (!(nFlags & SC_SCENARIO_ATTRIB))
    8341             :                     {
    8342           0 :                         nFlags |= SC_SCENARIO_ATTRIB;
    8343           0 :                         bModify = true;
    8344             :                     }
    8345             :                 }
    8346             :                 else
    8347             :                 {
    8348           0 :                     if (nFlags & SC_SCENARIO_ATTRIB)
    8349             :                     {
    8350           0 :                         nFlags -= SC_SCENARIO_ATTRIB;
    8351           0 :                         bModify = true;
    8352             :                     }
    8353             :                 }
    8354             : 
    8355           0 :                 if (bModify)
    8356           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8357             :             }
    8358             :         }
    8359        1028 :         else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
    8360             :         {
    8361           0 :             if (rDoc.IsScenario(nTab))
    8362             :             {
    8363           0 :                 OUString aName;
    8364           0 :                 OUString aComment;
    8365           0 :                 Color  aColor;
    8366             :                 sal_uInt16 nFlags;
    8367           0 :                 rDoc.GetName( nTab, aName );
    8368           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8369           0 :                 bool bModify(false);
    8370             : 
    8371           0 :                 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    8372             :                 {
    8373           0 :                     if (nFlags & SC_SCENARIO_VALUE)
    8374             :                     {
    8375           0 :                         nFlags -= SC_SCENARIO_VALUE;
    8376           0 :                         bModify = true;
    8377             :                     }
    8378             :                 }
    8379             :                 else
    8380             :                 {
    8381           0 :                     if (!(nFlags & SC_SCENARIO_VALUE))
    8382             :                     {
    8383           0 :                         nFlags |= SC_SCENARIO_VALUE;
    8384           0 :                         bModify = true;
    8385             :                     }
    8386             :                 }
    8387             : 
    8388           0 :                 if (bModify)
    8389           0 :                     pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
    8390             :             }
    8391             :         }
    8392        1028 :         else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
    8393             :         {
    8394         500 :             sal_Int16 nValue = 0;
    8395         500 :             if (aValue >>= nValue)
    8396             :             {
    8397         500 :                 if (nValue == com::sun::star::text::WritingMode2::RL_TB)
    8398           4 :                     rFunc.SetLayoutRTL(nTab, true, true);
    8399             :                 else
    8400         496 :                     rFunc.SetLayoutRTL(nTab, false, true);
    8401             :             }
    8402             :         }
    8403         528 :         else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
    8404             :         {
    8405           0 :             bool bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8406           0 :             if (bAutoPrint)
    8407           0 :                 rDoc.SetPrintEntireSheet( nTab ); // clears all print ranges
    8408             :             else
    8409             :             {
    8410           0 :                 if (rDoc.IsPrintEntireSheet( nTab ))
    8411           0 :                     rDoc.ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
    8412             :             }
    8413             :         }
    8414         528 :         else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
    8415             :         {
    8416         264 :             sal_Int32 nColor = COL_AUTO;
    8417         264 :             if ( aValue >>= nColor )
    8418             :             {
    8419         264 :                 const Color aColor( static_cast< ColorData >( nColor ) );
    8420         264 :                 if ( rDoc.GetTabBgColor( nTab ) != aColor )
    8421          38 :                     rFunc.SetTabBgColor( nTab, aColor, true, true );
    8422             :             }
    8423             :         }
    8424         264 :         else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
    8425             :         {
    8426         260 :             OUString aCodeName;
    8427         260 :             if ( pDocSh && ( aValue >>= aCodeName ) )
    8428             :             {
    8429         260 :                 pDocSh->GetDocument().SetCodeName( GetTab_Impl(), aCodeName );
    8430         260 :             }
    8431             :         }
    8432             :         else
    8433           4 :             ScCellRangeObj::SetOnePropertyValue(pEntry, aValue);        // base class, no Item WID
    8434             :     }
    8435             : }
    8436             : 
    8437        3742 : void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
    8438             :                                             uno::Any& rAny )
    8439             :     throw(uno::RuntimeException,
    8440             :           std::exception)
    8441             : {
    8442        3742 :     if ( pEntry )
    8443             :     {
    8444        3742 :         ScDocShell* pDocSh = GetDocShell();
    8445        3742 :         if (!pDocSh)
    8446           0 :             throw uno::RuntimeException();
    8447        3742 :         ScDocument& rDoc = pDocSh->GetDocument();
    8448        3742 :         SCTAB nTab = GetTab_Impl();
    8449             : 
    8450        3742 :         if ( pEntry->nWID == SC_WID_UNO_NAMES )
    8451             :         {
    8452           0 :             rAny <<= uno::Reference<sheet::XNamedRanges>(new ScLocalNamedRangesObj(pDocSh, this));
    8453             :         }
    8454        3742 :         else if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
    8455             :         {
    8456         352 :             rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
    8457         176 :                                 rDoc.GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
    8458             :         }
    8459        3566 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8460             :         {
    8461          68 :             bool bVis = rDoc.IsVisible( nTab );
    8462          68 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
    8463             :         }
    8464        3498 :         else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
    8465             :         {
    8466             :             //  no target bitmaps for individual entries (would be all equal)
    8467             :             // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
    8468             :         }
    8469        3498 :         else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
    8470             :         {
    8471             :             //  LinkDisplayName for hyperlink dialog
    8472           0 :             rAny <<= getName();     // sheet name
    8473             :         }
    8474        3498 :         else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
    8475             :         {
    8476           0 :             if (rDoc.IsScenario(nTab))
    8477           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, rDoc.IsActiveScenario( nTab ));
    8478             :         }
    8479        3498 :         else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
    8480             :         {
    8481           0 :             if (rDoc.IsScenario(nTab))
    8482             :             {
    8483           0 :                 OUString aComment;
    8484           0 :                 Color  aColor;
    8485             :                 sal_uInt16 nFlags;
    8486           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8487             : 
    8488           0 :                 rAny <<= static_cast<sal_Int32>(aColor.GetColor());
    8489             :             }
    8490             :         }
    8491        3498 :         else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
    8492             :         {
    8493           0 :             if (rDoc.IsScenario(nTab))
    8494             :             {
    8495           0 :                 OUString aComment;
    8496           0 :                 Color  aColor;
    8497             :                 sal_uInt16 nFlags;
    8498           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8499             : 
    8500           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
    8501             :             }
    8502             :         }
    8503        3498 :         else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
    8504             :         {
    8505           0 :             if (rDoc.IsScenario(nTab))
    8506             :             {
    8507           0 :                 OUString aComment;
    8508           0 :                 Color  aColor;
    8509             :                 sal_uInt16 nFlags;
    8510           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8511             : 
    8512           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
    8513             :             }
    8514             :         }
    8515        3498 :         else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
    8516             :         {
    8517           0 :             if (rDoc.IsScenario(nTab))
    8518             :             {
    8519           0 :                 OUString aComment;
    8520           0 :                 Color  aColor;
    8521             :                 sal_uInt16 nFlags;
    8522           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8523             : 
    8524           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
    8525             :             }
    8526             :         }
    8527        3498 :         else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
    8528             :         {
    8529           0 :             if (rDoc.IsScenario(nTab))
    8530             :             {
    8531           0 :                 OUString aComment;
    8532           0 :                 Color  aColor;
    8533             :                 sal_uInt16 nFlags;
    8534           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8535             : 
    8536           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
    8537             :             }
    8538             :         }
    8539        3498 :         else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
    8540             :         {
    8541           0 :             if (rDoc.IsScenario(nTab))
    8542             :             {
    8543           0 :                 OUString aComment;
    8544           0 :                 Color  aColor;
    8545             :                 sal_uInt16 nFlags;
    8546           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8547             : 
    8548           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
    8549             :             }
    8550             :         }
    8551        3498 :         else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
    8552             :         {
    8553           0 :             if (rDoc.IsScenario(nTab))
    8554             :             {
    8555           0 :                 OUString aComment;
    8556           0 :                 Color  aColor;
    8557             :                 sal_uInt16 nFlags;
    8558           0 :                 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
    8559             : 
    8560           0 :                 ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
    8561             :             }
    8562             :         }
    8563        3498 :         else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
    8564             :         {
    8565          72 :             if (rDoc.IsLayoutRTL(nTab))
    8566           8 :                 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
    8567             :             else
    8568          64 :                 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
    8569             :         }
    8570        3426 :         else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
    8571             :         {
    8572           0 :             bool bAutoPrint = rDoc.IsPrintEntireSheet( nTab );
    8573           0 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
    8574             :         }
    8575        3426 :         else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
    8576             :         {
    8577          56 :             rAny <<= sal_Int32(rDoc.GetTabBgColor(nTab).GetColor());
    8578             :         }
    8579        3370 :         else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
    8580             :         {
    8581        3360 :             OUString aCodeName;
    8582        3360 :             if ( pDocSh )
    8583        3360 :                 pDocSh->GetDocument().GetCodeName( GetTab_Impl(), aCodeName );
    8584        3360 :             rAny <<= OUString( aCodeName );
    8585             :         }
    8586             :         else
    8587          10 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    8588             :     }
    8589        3742 : }
    8590             : 
    8591        5080 : const SfxItemPropertyMap& ScTableSheetObj::GetItemPropertyMap()
    8592             : {
    8593        5080 :     return pSheetPropSet->getPropertyMap();
    8594             : }
    8595             : 
    8596             : // XServiceInfo
    8597             : 
    8598           0 : OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException, std::exception)
    8599             : {
    8600           0 :     return OUString( "ScTableSheetObj" );
    8601             : }
    8602             : 
    8603           0 : sal_Bool SAL_CALL ScTableSheetObj::supportsService( const OUString& rServiceName )
    8604             :                                                     throw(uno::RuntimeException, std::exception)
    8605             : {
    8606           0 :     return cppu::supportsService(this, rServiceName);
    8607             : }
    8608             : 
    8609           0 : uno::Sequence<OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
    8610             :                                                     throw(uno::RuntimeException, std::exception)
    8611             : {
    8612           0 :     uno::Sequence<OUString> aRet(7);
    8613           0 :     OUString* pArray = aRet.getArray();
    8614           0 :     pArray[0] = OUString( SCSPREADSHEET_SERVICE );
    8615           0 :     pArray[1] = OUString( SCSHEETCELLRANGE_SERVICE );
    8616           0 :     pArray[2] = OUString( SCCELLRANGE_SERVICE );
    8617           0 :     pArray[3] = OUString( SCCELLPROPERTIES_SERVICE );
    8618           0 :     pArray[4] = OUString( SCCHARPROPERTIES_SERVICE );
    8619           0 :     pArray[5] = OUString( SCPARAPROPERTIES_SERVICE );
    8620           0 :     pArray[6] = OUString( SCLINKTARGET_SERVICE );
    8621           0 :     return aRet;
    8622             : }
    8623             : 
    8624             : // XUnoTunnel
    8625             : 
    8626        6936 : sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
    8627             :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
    8628             : {
    8629       13872 :     if ( rId.getLength() == 16 &&
    8630        6936 :           0 == memcmp( getUnoTunnelId().getConstArray(),
    8631       13872 :                                     rId.getConstArray(), 16 ) )
    8632             :     {
    8633         712 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
    8634             :     }
    8635             : 
    8636        6224 :     return ScCellRangeObj::getSomething( rId );
    8637             : }
    8638             : 
    8639             : namespace
    8640             : {
    8641             :     class theScTableSheetObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableSheetObjUnoTunnelId> {};
    8642             : }
    8643             : 
    8644       12718 : const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
    8645             : {
    8646       12718 :     return theScTableSheetObjUnoTunnelId::get().getSeq();
    8647             : }
    8648             : 
    8649        5782 : ScTableSheetObj* ScTableSheetObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
    8650             : {
    8651        5782 :     ScTableSheetObj* pRet = NULL;
    8652        5782 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
    8653        5782 :     if (xUT.is())
    8654        5782 :         pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
    8655        5782 :     return pRet;
    8656             : }
    8657             : 
    8658        2188 : ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
    8659             :     ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
    8660        2188 :     pColPropSet(lcl_GetColumnPropertySet())
    8661             : {
    8662        2188 : }
    8663             : 
    8664        4376 : ScTableColumnObj::~ScTableColumnObj()
    8665             : {
    8666        4376 : }
    8667             : 
    8668        4640 : uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    8669             : {
    8670        4640 :     SC_QUERYINTERFACE( container::XNamed )
    8671             : 
    8672        4640 :     return ScCellRangeObj::queryInterface( rType );
    8673             : }
    8674             : 
    8675       20220 : void SAL_CALL ScTableColumnObj::acquire() throw()
    8676             : {
    8677       20220 :     ScCellRangeObj::acquire();
    8678       20220 : }
    8679             : 
    8680       20220 : void SAL_CALL ScTableColumnObj::release() throw()
    8681             : {
    8682       20220 :     ScCellRangeObj::release();
    8683       20220 : }
    8684             : 
    8685           0 : uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException, std::exception)
    8686             : {
    8687           0 :     static uno::Sequence<uno::Type> aTypes;
    8688           0 :     if ( aTypes.getLength() == 0 )
    8689             :     {
    8690           0 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
    8691           0 :         long nParentLen = aParentTypes.getLength();
    8692           0 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
    8693             : 
    8694           0 :         aTypes.realloc( nParentLen + 1 );
    8695           0 :         uno::Type* pPtr = aTypes.getArray();
    8696           0 :         pPtr[nParentLen + 0] = cppu::UnoType<container::XNamed>::get();
    8697             : 
    8698           0 :         for (long i=0; i<nParentLen; i++)
    8699           0 :             pPtr[i] = pParentPtr[i];                // parent types first
    8700             :     }
    8701           0 :     return aTypes;
    8702             : }
    8703             : 
    8704           0 : uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException, std::exception)
    8705             : {
    8706           0 :     return css::uno::Sequence<sal_Int8>();
    8707             : }
    8708             : 
    8709             : // XNamed
    8710             : 
    8711           0 : OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException, std::exception)
    8712             : {
    8713           0 :     SolarMutexGuard aGuard;
    8714             : 
    8715           0 :     const ScRange& rRange = GetRange();
    8716             :     OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
    8717           0 :     SCCOL nCol = rRange.aStart.Col();
    8718             : 
    8719           0 :     return ScColToAlpha( nCol );        // from global.hxx
    8720             : }
    8721             : 
    8722           0 : void SAL_CALL ScTableColumnObj::setName( const OUString& /* aNewName */ )
    8723             :                                                 throw(uno::RuntimeException, std::exception)
    8724             : {
    8725           0 :     SolarMutexGuard aGuard;
    8726           0 :     throw uno::RuntimeException();      // read-only
    8727             : }
    8728             : 
    8729             : // XPropertySet erweitert fuer Spalten-Properties
    8730             : 
    8731          70 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
    8732             :                                                         throw(uno::RuntimeException, std::exception)
    8733             : {
    8734          70 :     SolarMutexGuard aGuard;
    8735             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    8736          70 :         new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
    8737          70 :     return aRef;
    8738             : }
    8739             : 
    8740           8 : void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue)
    8741             :     throw(lang::IllegalArgumentException, uno::RuntimeException,
    8742             :           std::exception)
    8743             : {
    8744           8 :     if ( pEntry )
    8745             :     {
    8746           8 :         if ( IsScItemWid( pEntry->nWID ) )
    8747             :         {
    8748             :             //  for Item WIDs, call ScCellRangesBase directly
    8749           0 :             ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
    8750           0 :             return;
    8751             :         }
    8752             : 
    8753             :         //  own properties
    8754             : 
    8755           8 :         ScDocShell* pDocSh = GetDocShell();
    8756           8 :         if (!pDocSh)
    8757           0 :             return;                                                 //! Exception oder so?
    8758           8 :         const ScRange& rRange = GetRange();
    8759             :         OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
    8760           8 :         SCCOL nCol = rRange.aStart.Col();
    8761           8 :         SCTAB nTab = rRange.aStart.Tab();
    8762           8 :         ScDocFunc &rFunc = pDocSh->GetDocFunc();
    8763             : 
    8764           8 :         std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nCol,nCol));
    8765             : 
    8766           8 :         if ( pEntry->nWID == SC_WID_UNO_CELLWID )
    8767             :         {
    8768           0 :             sal_Int32 nNewWidth = 0;
    8769           0 :             if ( aValue >>= nNewWidth )
    8770             :             {
    8771             :                 //  property is 1/100mm, column width is twips
    8772           0 :                 nNewWidth = HMMToTwips(nNewWidth);
    8773             :                 rFunc.SetWidthOrHeight(
    8774           0 :                     true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewWidth, true, true);
    8775             :             }
    8776             :         }
    8777           8 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8778             :         {
    8779           0 :             bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8780           0 :             ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
    8781           0 :             rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true);
    8782             :             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
    8783             :         }
    8784           8 :         else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
    8785             :         {
    8786           4 :             bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8787           4 :             if (bOpt)
    8788             :                 rFunc.SetWidthOrHeight(
    8789           4 :                     true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true);
    8790             :             // sal_False bei Spalten momentan ohne Auswirkung
    8791             :         }
    8792           4 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
    8793             :         {
    8794           4 :             bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8795           4 :             if (bSet)
    8796           2 :                 rFunc.InsertPageBreak( true, rRange.aStart, true, true, true );
    8797             :             else
    8798           2 :                 rFunc.RemovePageBreak( true, rRange.aStart, true, true, true );
    8799             :         }
    8800             :         else
    8801           0 :             ScCellRangeObj::SetOnePropertyValue(pEntry, aValue);        // base class, no Item WID
    8802             :     }
    8803             : }
    8804             : 
    8805         214 : void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    8806             :     throw(uno::RuntimeException, std::exception)
    8807             : {
    8808         214 :     if ( pEntry )
    8809             :     {
    8810         214 :         ScDocShell* pDocSh = GetDocShell();
    8811         214 :         if (!pDocSh)
    8812           0 :             throw uno::RuntimeException();
    8813             : 
    8814         214 :         ScDocument& rDoc = pDocSh->GetDocument();
    8815         214 :         const ScRange& rRange = GetRange();
    8816             :         OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
    8817         214 :         SCCOL nCol = rRange.aStart.Col();
    8818         214 :         SCTAB nTab = rRange.aStart.Tab();
    8819             : 
    8820         214 :         if ( pEntry->nWID == SC_WID_UNO_CELLWID )
    8821             :         {
    8822             :             // for hidden column, return original height
    8823          70 :             sal_uInt16 nWidth = rDoc.GetOriginalWidth( nCol, nTab );
    8824             :             //  property is 1/100mm, column width is twips
    8825          70 :             nWidth = (sal_uInt16) TwipsToHMM(nWidth);
    8826          70 :             rAny <<= (sal_Int32)( nWidth );
    8827             :         }
    8828         144 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8829             :         {
    8830          70 :             bool bHidden = rDoc.ColHidden(nCol, nTab);
    8831          70 :             ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
    8832             :         }
    8833          74 :         else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
    8834             :         {
    8835             :             //! momentan immer gesetzt ??!?!
    8836           0 :             bool bOpt = !(rDoc.GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
    8837           0 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
    8838             :         }
    8839          74 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
    8840             :         {
    8841           4 :             ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
    8842           4 :             ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
    8843             :         }
    8844          70 :         else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
    8845             :         {
    8846          70 :             ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
    8847          70 :             ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL) != 0);
    8848             :         }
    8849             :         else
    8850           0 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    8851             :     }
    8852         214 : }
    8853             : 
    8854          82 : const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap()
    8855             : {
    8856          82 :     return pColPropSet->getPropertyMap();
    8857             : }
    8858             : 
    8859         230 : ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
    8860             :     ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
    8861         230 :     pRowPropSet(lcl_GetRowPropertySet())
    8862             : {
    8863         230 : }
    8864             : 
    8865         460 : ScTableRowObj::~ScTableRowObj()
    8866             : {
    8867         460 : }
    8868             : 
    8869             : // XPropertySet erweitert fuer Zeilen-Properties
    8870             : 
    8871         114 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
    8872             :                                                         throw(uno::RuntimeException, std::exception)
    8873             : {
    8874         114 :     SolarMutexGuard aGuard;
    8875             :     static uno::Reference<beans::XPropertySetInfo> aRef(
    8876         114 :         new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
    8877         114 :     return aRef;
    8878             : }
    8879             : 
    8880           8 : void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
    8881             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    8882             : {
    8883           8 :     if ( pEntry )
    8884             :     {
    8885           8 :         if ( IsScItemWid( pEntry->nWID ) )
    8886             :         {
    8887             :             //  for Item WIDs, call ScCellRangesBase directly
    8888           0 :             ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
    8889           0 :             return;
    8890             :         }
    8891             : 
    8892             :         //  own properties
    8893             : 
    8894           8 :         ScDocShell* pDocSh = GetDocShell();
    8895           8 :         if (!pDocSh)
    8896           0 :             return;                                                 //! Exception oder so?
    8897           8 :         ScDocument& rDoc = pDocSh->GetDocument();
    8898           8 :         const ScRange& rRange = GetRange();
    8899             :         OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
    8900           8 :         SCROW nRow = rRange.aStart.Row();
    8901           8 :         SCTAB nTab = rRange.aStart.Tab();
    8902           8 :         ScDocFunc &rFunc = pDocSh->GetDocFunc();
    8903             : 
    8904           8 :         std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow,nRow));
    8905             : 
    8906           8 :         if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
    8907             :         {
    8908           0 :             sal_Int32 nNewHeight = 0;
    8909           0 :             if ( aValue >>= nNewHeight )
    8910             :             {
    8911             :                 //  property is 1/100mm, row height is twips
    8912           0 :                 nNewHeight = HMMToTwips(nNewHeight);
    8913             :                 rFunc.SetWidthOrHeight(
    8914           0 :                     false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewHeight, true, true);
    8915             :             }
    8916             :         }
    8917           8 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8918             :         {
    8919           4 :             bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8920           4 :             ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
    8921           4 :             rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true);
    8922             :             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
    8923             :         }
    8924           4 :         else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
    8925             :         {
    8926           0 :             bool bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8927             :             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
    8928           0 :             rDoc.SetRowFiltered(nRow, nRow, nTab, bFil);
    8929             :         }
    8930           4 :         else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
    8931             :         {
    8932           0 :             bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8933           0 :             if (bOpt)
    8934           0 :                 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
    8935             :             else
    8936             :             {
    8937             :                 //  set current height again manually
    8938           0 :                 sal_uInt16 nHeight = rDoc.GetOriginalHeight( nRow, nTab );
    8939           0 :                 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true);
    8940             :             }
    8941             :         }
    8942           4 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
    8943             :         {
    8944           4 :             bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    8945           4 :             if (bSet)
    8946           2 :                 rFunc.InsertPageBreak( false, rRange.aStart, true, true, true );
    8947             :             else
    8948           2 :                 rFunc.RemovePageBreak( false, rRange.aStart, true, true, true );
    8949             :         }
    8950             :         else
    8951           0 :             ScCellRangeObj::SetOnePropertyValue(pEntry, aValue);        // base class, no Item WID
    8952             :     }
    8953             : }
    8954             : 
    8955         364 : void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
    8956             :     throw(uno::RuntimeException, std::exception)
    8957             : {
    8958         364 :     if ( pEntry )
    8959             :     {
    8960         364 :         ScDocShell* pDocSh = GetDocShell();
    8961         364 :         if (!pDocSh)
    8962           0 :             throw uno::RuntimeException();
    8963         364 :         ScDocument& rDoc = pDocSh->GetDocument();
    8964         364 :         const ScRange& rRange = GetRange();
    8965             :         OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
    8966         364 :         SCROW nRow = rRange.aStart.Row();
    8967         364 :         SCTAB nTab = rRange.aStart.Tab();
    8968             : 
    8969         364 :         if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
    8970             :         {
    8971             :             // for hidden row, return original height
    8972         114 :             sal_uInt16 nHeight = rDoc.GetOriginalHeight( nRow, nTab );
    8973             :             //  property is 1/100mm, row height is twips
    8974         114 :             nHeight = (sal_uInt16) TwipsToHMM(nHeight);
    8975         114 :             rAny <<= (sal_Int32)( nHeight );
    8976             :         }
    8977         250 :         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
    8978             :         {
    8979          18 :             bool bHidden = rDoc.RowHidden(nRow, nTab);
    8980          18 :             ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
    8981             :         }
    8982         232 :         else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
    8983             :         {
    8984           0 :             bool bVis = rDoc.RowFiltered(nRow, nTab);
    8985           0 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
    8986             :         }
    8987         232 :         else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
    8988             :         {
    8989         114 :             bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
    8990         114 :             ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
    8991             :         }
    8992         118 :         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
    8993             :         {
    8994           4 :             ScBreakType nBreak = rDoc.HasRowBreak(nRow, nTab);
    8995           4 :             ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
    8996             :         }
    8997         114 :         else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
    8998             :         {
    8999         114 :             ScBreakType nBreak = (rDoc.HasRowBreak(nRow, nTab) & BREAK_MANUAL);
    9000         114 :             ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
    9001             :         }
    9002             :         else
    9003           0 :             ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
    9004             :     }
    9005         364 : }
    9006             : 
    9007         144 : const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap()
    9008             : {
    9009         144 :     return pRowPropSet->getPropertyMap();
    9010             : }
    9011             : 
    9012          54 : ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
    9013             :     pDocShell( pDocSh ),
    9014          54 :     aRanges( rR )
    9015             : {
    9016          54 :     pDocShell->GetDocument().AddUnoObject(*this);
    9017          54 : }
    9018             : 
    9019         162 : ScCellsObj::~ScCellsObj()
    9020             : {
    9021          54 :     SolarMutexGuard g;
    9022             : 
    9023          54 :     if (pDocShell)
    9024          46 :         pDocShell->GetDocument().RemoveUnoObject(*this);
    9025         108 : }
    9026             : 
    9027          16 : void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9028             : {
    9029          16 :     if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
    9030             :     {
    9031           0 :         const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint);
    9032           0 :         aRanges.UpdateReference( rRef.GetMode(), &pDocShell->GetDocument(), rRef.GetRange(),
    9033           0 :                                         rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
    9034             :     }
    9035          32 :     else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) &&
    9036          16 :             static_cast<const SfxSimpleHint&>(rHint).GetId() == SFX_HINT_DYING )
    9037             :     {
    9038           8 :         pDocShell = NULL;       // ungueltig geworden
    9039             :     }
    9040          16 : }
    9041             : 
    9042             : // XEnumerationAccess
    9043             : 
    9044          52 : uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
    9045             :                                                     throw(uno::RuntimeException, std::exception)
    9046             : {
    9047          52 :     SolarMutexGuard aGuard;
    9048          52 :     if (pDocShell)
    9049          52 :         return new ScCellsEnumeration( pDocShell, aRanges );
    9050           0 :     return NULL;
    9051             : }
    9052             : 
    9053           2 : uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException, std::exception)
    9054             : {
    9055           2 :     SolarMutexGuard aGuard;
    9056           2 :     return cppu::UnoType<table::XCell>::get();
    9057             : }
    9058             : 
    9059           2 : sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException, std::exception)
    9060             : {
    9061           2 :     SolarMutexGuard aGuard;
    9062           2 :     bool bHas = false;
    9063           2 :     if ( pDocShell )
    9064             :     {
    9065             :         //! schneller selber testen?
    9066             : 
    9067           2 :         uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
    9068           2 :         bHas = xEnum->hasMoreElements();
    9069             :     }
    9070           2 :     return bHas;
    9071             : }
    9072             : 
    9073          54 : ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
    9074             :     pDocShell( pDocSh ),
    9075             :     aRanges( rR ),
    9076             :     pMark( NULL ),
    9077          54 :     bAtEnd( false )
    9078             : {
    9079          54 :     ScDocument& rDoc = pDocShell->GetDocument();
    9080          54 :     rDoc.AddUnoObject(*this);
    9081             : 
    9082          54 :     if ( aRanges.empty() )
    9083           0 :         bAtEnd = true;
    9084             :     else
    9085             :     {
    9086          54 :         SCTAB nTab = 0;
    9087          54 :         const ScRange* pFirst = aRanges[ 0 ];
    9088          54 :         if (pFirst)
    9089          54 :             nTab = pFirst->aStart.Tab();
    9090          54 :         aPos = ScAddress(0,0,nTab);
    9091          54 :         CheckPos_Impl();                    // aPos auf erste passende Zelle setzen
    9092             :     }
    9093          54 : }
    9094             : 
    9095          54 : void ScCellsEnumeration::CheckPos_Impl()
    9096             : {
    9097          54 :     if (!pDocShell)
    9098          54 :         return;
    9099             : 
    9100          54 :     bool bFound = false;
    9101          54 :     ScDocument& rDoc = pDocShell->GetDocument();
    9102          54 :     ScRefCellValue aCell;
    9103          54 :     aCell.assign(rDoc, aPos);
    9104          54 :     if (!aCell.isEmpty())
    9105             :     {
    9106          54 :         if (!pMark)
    9107             :         {
    9108          54 :             pMark = new ScMarkData;
    9109          54 :             pMark->MarkFromRangeList(aRanges, false);
    9110          54 :             pMark->MarkToMulti();   // needed for GetNextMarkedCell
    9111             :         }
    9112          54 :         bFound = pMark->IsCellMarked(aPos.Col(), aPos.Row());
    9113             :     }
    9114          54 :     if (!bFound)
    9115          48 :         Advance_Impl();
    9116             : }
    9117             : 
    9118         162 : ScCellsEnumeration::~ScCellsEnumeration()
    9119             : {
    9120          54 :     SolarMutexGuard g;
    9121             : 
    9122          54 :     if (pDocShell)
    9123          48 :         pDocShell->GetDocument().RemoveUnoObject(*this);
    9124          54 :     delete pMark;
    9125         108 : }
    9126             : 
    9127          50 : void ScCellsEnumeration::Advance_Impl()
    9128             : {
    9129             :     OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
    9130          50 :     if (!pMark)
    9131             :     {
    9132           0 :         pMark = new ScMarkData;
    9133           0 :         pMark->MarkFromRangeList( aRanges, false );
    9134           0 :         pMark->MarkToMulti();   // needed for GetNextMarkedCell
    9135             :     }
    9136             : 
    9137          50 :     SCCOL nCol = aPos.Col();
    9138          50 :     SCROW nRow = aPos.Row();
    9139          50 :     SCTAB nTab = aPos.Tab();
    9140          50 :     bool bFound = pDocShell->GetDocument().GetNextMarkedCell( nCol, nRow, nTab, *pMark );
    9141          50 :     if (bFound)
    9142           2 :         aPos.Set( nCol, nRow, nTab );
    9143             :     else
    9144          48 :         bAtEnd = true;      // kommt nix mehr
    9145          50 : }
    9146             : 
    9147          14 : void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9148             : {
    9149          14 :     const ScUpdateRefHint* pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint);
    9150          14 :     if ( pRefHint )
    9151             :     {
    9152           0 :         if (pDocShell)
    9153             :         {
    9154           0 :             aRanges.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(),
    9155           0 :                                      pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() );
    9156             : 
    9157           0 :             delete pMark;       // aus verschobenen Bereichen neu erzeugen
    9158           0 :             pMark = NULL;
    9159             : 
    9160           0 :             if (!bAtEnd)        // aPos anpassen
    9161             :             {
    9162           0 :                 ScRangeList aNew;
    9163           0 :                 aNew.Append(ScRange(aPos));
    9164           0 :                 aNew.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(),
    9165           0 :                                       pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() );
    9166           0 :                 if (aNew.size()==1)
    9167             :                 {
    9168           0 :                     aPos = aNew[ 0 ]->aStart;
    9169           0 :                     CheckPos_Impl();
    9170           0 :                 }
    9171             :             }
    9172             :         }
    9173             :     }
    9174          28 :     else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) &&
    9175          14 :               static_cast<const SfxSimpleHint&>(rHint).GetId() == SFX_HINT_DYING )
    9176             :     {
    9177           6 :         pDocShell = NULL;       // ungueltig geworden
    9178             :     }
    9179          14 : }
    9180             : 
    9181             : // XEnumeration
    9182             : 
    9183          54 : sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
    9184             : {
    9185          54 :     SolarMutexGuard aGuard;
    9186          54 :     return !bAtEnd;
    9187             : }
    9188             : 
    9189           4 : uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
    9190             :                                         lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9191             : {
    9192           4 :     SolarMutexGuard aGuard;
    9193           4 :     if (pDocShell && !bAtEnd)
    9194             :     {
    9195             :         // Interface-Typ muss zu ScCellsObj::getElementType passen
    9196             : 
    9197           2 :         ScAddress aTempPos(aPos);
    9198           2 :         Advance_Impl();
    9199           4 :         return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
    9200             :     }
    9201             : 
    9202           2 :     throw container::NoSuchElementException();      // no more elements
    9203             : }
    9204             : 
    9205           6 : ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
    9206             :     pDocShell( pDocSh ),
    9207           6 :     aTotalRange( rRange )
    9208             : {
    9209           6 :     ScDocument& rDoc = pDocShell->GetDocument();
    9210           6 :     rDoc.AddUnoObject(*this);
    9211             : 
    9212             :     OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
    9213           6 : }
    9214             : 
    9215          18 : ScCellFormatsObj::~ScCellFormatsObj()
    9216             : {
    9217           6 :     SolarMutexGuard g;
    9218             : 
    9219           6 :     if (pDocShell)
    9220           1 :         pDocShell->GetDocument().RemoveUnoObject(*this);
    9221          12 : }
    9222             : 
    9223          15 : void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9224             : {
    9225          15 :     if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
    9226             :     {
    9227             :         //! aTotalRange...
    9228             :     }
    9229          26 :     else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) &&
    9230          15 :               static_cast<const SfxSimpleHint&>(rHint).GetId() == SFX_HINT_DYING )
    9231             :     {
    9232           5 :         pDocShell = NULL;       // ungueltig geworden
    9233             :     }
    9234          15 : }
    9235             : 
    9236          10 : ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
    9237             : {
    9238             :     //! direkt auf die AttrArrays zugreifen !!!!
    9239             : 
    9240          10 :     ScCellRangeObj* pRet = NULL;
    9241          10 :     if (pDocShell)
    9242             :     {
    9243          10 :         ScDocument& rDoc = pDocShell->GetDocument();
    9244          10 :         long nPos = 0;
    9245          10 :         ScAttrRectIterator aIter( &rDoc, aTotalRange.aStart.Tab(),
    9246          10 :                                     aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
    9247          30 :                                     aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
    9248             :         SCCOL nCol1, nCol2;
    9249             :         SCROW nRow1, nRow2;
    9250          30 :         while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9251             :         {
    9252          10 :             if ( nPos == nIndex )
    9253             :             {
    9254           8 :                 SCTAB nTab = aTotalRange.aStart.Tab();
    9255           8 :                 ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
    9256             : 
    9257           8 :                 if ( aNext.aStart == aNext.aEnd )
    9258           0 :                     pRet = new ScCellObj( pDocShell, aNext.aStart );
    9259             :                 else
    9260           8 :                     pRet = new ScCellRangeObj( pDocShell, aNext );
    9261             :             }
    9262          10 :             ++nPos;
    9263          10 :         }
    9264             :     }
    9265          10 :     return pRet;
    9266             : }
    9267             : 
    9268             : // XIndexAccess
    9269             : 
    9270           6 : sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
    9271             : {
    9272           6 :     SolarMutexGuard aGuard;
    9273             : 
    9274             :     //! direkt auf die AttrArrays zugreifen !!!!
    9275             : 
    9276           6 :     long nCount = 0;
    9277           6 :     if (pDocShell)
    9278             :     {
    9279           6 :         ScDocument& rDoc = pDocShell->GetDocument();
    9280           6 :         ScAttrRectIterator aIter( &rDoc, aTotalRange.aStart.Tab(),
    9281           6 :                                     aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
    9282          18 :                                     aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
    9283             :         SCCOL nCol1, nCol2;
    9284             :         SCROW nRow1, nRow2;
    9285          18 :         while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9286          12 :             ++nCount;
    9287             :     }
    9288           6 :     return nCount;
    9289             : }
    9290             : 
    9291          10 : uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
    9292             :                             throw(lang::IndexOutOfBoundsException,
    9293             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9294             : {
    9295          10 :     SolarMutexGuard aGuard;
    9296             : 
    9297          20 :     uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
    9298          10 :     if (xRange.is())
    9299          16 :         return uno::makeAny(xRange);
    9300             :     else
    9301          12 :         throw lang::IndexOutOfBoundsException();
    9302             : }
    9303             : 
    9304           2 : uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
    9305             : {
    9306           2 :     SolarMutexGuard aGuard;
    9307           2 :     return cppu::UnoType<table::XCellRange>::get();
    9308             : }
    9309             : 
    9310           2 : sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
    9311             : {
    9312           2 :     SolarMutexGuard aGuard;
    9313           2 :     return ( getCount() != 0 );     //! immer groesser 0 ??
    9314             : }
    9315             : 
    9316             : // XEnumerationAccess
    9317             : 
    9318           4 : uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
    9319             :                                                     throw(uno::RuntimeException, std::exception)
    9320             : {
    9321           4 :     SolarMutexGuard aGuard;
    9322           4 :     if (pDocShell)
    9323           4 :         return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
    9324           0 :     return NULL;
    9325             : }
    9326             : 
    9327           4 : ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
    9328             :     pDocShell( pDocSh ),
    9329           4 :     nTab( rRange.aStart.Tab() ),
    9330             :     pIter( NULL ),
    9331             :     bAtEnd( false ),
    9332           8 :     bDirty( false )
    9333             : {
    9334           4 :     ScDocument& rDoc = pDocShell->GetDocument();
    9335           4 :     rDoc.AddUnoObject(*this);
    9336             : 
    9337             :     OSL_ENSURE( rRange.aStart.Tab() == rRange.aEnd.Tab(),
    9338             :                 "CellFormatsEnumeration: unterschiedliche Tabellen" );
    9339             : 
    9340             :     pIter = new ScAttrRectIterator( &rDoc, nTab,
    9341           8 :                                     rRange.aStart.Col(), rRange.aStart.Row(),
    9342           8 :                                     rRange.aEnd.Col(), rRange.aEnd.Row() );
    9343           4 :     Advance_Impl();
    9344           4 : }
    9345             : 
    9346          12 : ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
    9347             : {
    9348           4 :     SolarMutexGuard g;
    9349             : 
    9350           4 :     if (pDocShell)
    9351           0 :         pDocShell->GetDocument().RemoveUnoObject(*this);
    9352           4 :     delete pIter;
    9353           8 : }
    9354             : 
    9355           6 : void ScCellFormatsEnumeration::Advance_Impl()
    9356             : {
    9357             :     OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
    9358             : 
    9359           6 :     if ( pIter )
    9360             :     {
    9361           6 :         if ( bDirty )
    9362             :         {
    9363           0 :             pIter->DataChanged();   // AttrArray-Index neu suchen
    9364           0 :             bDirty = false;
    9365             :         }
    9366             : 
    9367             :         SCCOL nCol1, nCol2;
    9368             :         SCROW nRow1, nRow2;
    9369           6 :         if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9370           4 :             aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
    9371             :         else
    9372           2 :             bAtEnd = true;      // kommt nix mehr
    9373             :     }
    9374             :     else
    9375           0 :         bAtEnd = true;          // Dok weggekommen oder so
    9376           6 : }
    9377             : 
    9378           2 : ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
    9379             : {
    9380           2 :     ScCellRangeObj* pRet = NULL;
    9381           2 :     if (pDocShell && !bAtEnd)
    9382             :     {
    9383           2 :         if ( aNext.aStart == aNext.aEnd )
    9384           0 :             pRet = new ScCellObj( pDocShell, aNext.aStart );
    9385             :         else
    9386           2 :             pRet = new ScCellRangeObj( pDocShell, aNext );
    9387           2 :         Advance_Impl();
    9388             :     }
    9389           2 :     return pRet;
    9390             : }
    9391             : 
    9392           4 : void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9393             : {
    9394           4 :     if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
    9395             :     {
    9396             :         //! und nun ???
    9397             :     }
    9398           4 :     else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
    9399             :     {
    9400           4 :         sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
    9401           4 :         if ( nId == SFX_HINT_DYING )
    9402             :         {
    9403           4 :             pDocShell = NULL;                       // ungueltig geworden
    9404           4 :             delete pIter;
    9405           4 :             pIter = NULL;
    9406             :         }
    9407           0 :         else if ( nId == SFX_HINT_DATACHANGED )
    9408             :         {
    9409           0 :             bDirty = true;          // AttrArray-Index evtl. ungueltig geworden
    9410             :         }
    9411             :     }
    9412           4 : }
    9413             : 
    9414             : // XEnumeration
    9415             : 
    9416           4 : sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
    9417             : {
    9418           4 :     SolarMutexGuard aGuard;
    9419           4 :     return !bAtEnd;
    9420             : }
    9421             : 
    9422           4 : uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
    9423             :                                         lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9424             : {
    9425           4 :     SolarMutexGuard aGuard;
    9426             : 
    9427           4 :     if ( bAtEnd || !pDocShell )
    9428           2 :         throw container::NoSuchElementException();      // no more elements
    9429             : 
    9430             :     // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
    9431             : 
    9432           2 :     return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
    9433             : }
    9434             : 
    9435          62 : ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
    9436             :     pDocShell( pDocSh ),
    9437             :     aTotalRange( rRange ),
    9438          62 :     aRangeLists()
    9439             : {
    9440          62 :     pDocShell->GetDocument().AddUnoObject(*this);
    9441             : 
    9442             :     OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
    9443             : 
    9444          62 :     GetObjects_Impl();
    9445          62 : }
    9446             : 
    9447         186 : ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
    9448             : {
    9449          62 :     SolarMutexGuard g;
    9450             : 
    9451          62 :     if (pDocShell)
    9452          56 :         pDocShell->GetDocument().RemoveUnoObject(*this);
    9453         124 : }
    9454             : 
    9455           6 : void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9456             : {
    9457           6 :     if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
    9458             :     {
    9459             :         //! aTotalRange...
    9460             :     }
    9461           6 :     else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
    9462             :     {
    9463           6 :         sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
    9464           6 :         if ( nId == SFX_HINT_DYING )
    9465           6 :             pDocShell = NULL;                       // ungueltig geworden
    9466             :     }
    9467           6 : }
    9468             : 
    9469             : //  Fill the list of formats from the document
    9470             : 
    9471             : // hash code to access the range lists by ScPatternAttr pointer
    9472             : struct ScPatternHashCode
    9473             : {
    9474         356 :     size_t operator()( const ScPatternAttr* pPattern ) const
    9475             :     {
    9476         356 :         return reinterpret_cast<size_t>(pPattern);
    9477             :     }
    9478             : };
    9479             : 
    9480             : // Hash map to find a range by its start row
    9481             : typedef ::boost::unordered_map< SCROW, ScRange > ScRowRangeHashMap;
    9482             : 
    9483             : typedef ::std::vector<ScRange> ScRangeVector;
    9484             : 
    9485             : // Hash map entry.
    9486             : // The Join method depends on the column-wise order of ScAttrRectIterator
    9487             : class ScUniqueFormatsEntry
    9488             : {
    9489             :     enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
    9490             : 
    9491             :     EntryState          eState;
    9492             :     ScRange             aSingleRange;
    9493             :     ScRowRangeHashMap   aJoinedRanges;      // "active" ranges to be merged
    9494             :     ScRangeVector       aCompletedRanges;   // ranges that will no longer be touched
    9495             :     ScRangeListRef      aReturnRanges;      // result as ScRangeList for further use
    9496             : 
    9497             : public:
    9498         174 :                         ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
    9499         174 :                         ~ScUniqueFormatsEntry() {}
    9500             : 
    9501             :     void                Join( const ScRange& rNewRange );
    9502             :     const ScRangeList&  GetRanges();
    9503         174 :     void                Clear() { aReturnRanges.Clear(); }  // aJoinedRanges and aCompletedRanges are cleared in GetRanges
    9504             : };
    9505             : 
    9506         356 : void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
    9507             : {
    9508             :     // Special-case handling for single range
    9509             : 
    9510         356 :     if ( eState == STATE_EMPTY )
    9511             :     {
    9512         174 :         aSingleRange = rNewRange;
    9513         174 :         eState = STATE_SINGLE;
    9514         374 :         return;
    9515             :     }
    9516         182 :     if ( eState == STATE_SINGLE )
    9517             :     {
    9518         156 :         if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
    9519          86 :              aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
    9520          26 :              aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
    9521             :         {
    9522          26 :             aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
    9523          26 :             return;     // still a single range
    9524             :         }
    9525             : 
    9526          34 :         SCROW nSingleRow = aSingleRange.aStart.Row();
    9527          34 :         aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
    9528          34 :         eState = STATE_COMPLEX;
    9529             :         // continue normally
    9530             :     }
    9531             : 
    9532             :     // This is called in the order of ScAttrRectIterator results.
    9533             :     // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
    9534             :     // If the old entry for the start row extends to a different end row, or ends in a different column, it
    9535             :     // can be moved to aCompletedRanges because it can't be joined with following iterator results.
    9536             :     // Everything happens within one sheet, so Tab can be ignored.
    9537             : 
    9538         156 :     SCROW nStartRow = rNewRange.aStart.Row();
    9539         156 :     ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) );       // find the active entry for the start row
    9540         156 :     if ( aIter != aJoinedRanges.end() )
    9541             :     {
    9542         116 :         ScRange& rOldRange = aIter->second;
    9543         144 :         if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
    9544          28 :              rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
    9545             :         {
    9546             :             // extend existing range
    9547           2 :             rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
    9548             :         }
    9549             :         else
    9550             :         {
    9551             :             // move old range to aCompletedRanges, keep rNewRange for joining
    9552         114 :             aCompletedRanges.push_back( rOldRange );
    9553         114 :             rOldRange = rNewRange;  // replace in hash map
    9554             :         }
    9555             :     }
    9556             :     else
    9557             :     {
    9558             :         // keep rNewRange for joining
    9559          40 :         aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
    9560             :     }
    9561             : }
    9562             : 
    9563         174 : const ScRangeList& ScUniqueFormatsEntry::GetRanges()
    9564             : {
    9565         174 :     if ( eState == STATE_SINGLE )
    9566             :     {
    9567         140 :         aReturnRanges = new ScRangeList;
    9568         140 :         aReturnRanges->Append( aSingleRange );
    9569         140 :         return *aReturnRanges;
    9570             :     }
    9571             : 
    9572             :     // move remaining entries from aJoinedRanges to aCompletedRanges
    9573             : 
    9574          34 :     ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
    9575         108 :     for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
    9576          74 :         aCompletedRanges.push_back( aJoinedIter->second );
    9577          34 :     aJoinedRanges.clear();
    9578             : 
    9579             :     // sort all ranges for a predictable API result
    9580             : 
    9581          34 :     std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
    9582             : 
    9583             :     // fill and return ScRangeList
    9584             : 
    9585          34 :     aReturnRanges = new ScRangeList;
    9586          34 :     ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
    9587         222 :     for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
    9588         188 :         aReturnRanges->Append( *aCompIter );
    9589          34 :     aCompletedRanges.clear();
    9590             : 
    9591          34 :     return *aReturnRanges;
    9592             : }
    9593             : 
    9594             : typedef ::boost::unordered_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
    9595             : 
    9596             : // function object to sort the range lists by start of first range
    9597             : struct ScUniqueFormatsOrder
    9598             : {
    9599         177 :     bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
    9600             :     {
    9601             :         // all range lists have at least one entry
    9602             :         OSL_ENSURE( rList1.size() > 0 && rList2.size() > 0, "ScUniqueFormatsOrder: empty list" );
    9603             : 
    9604             :         // compare start positions using ScAddress comparison operator
    9605         177 :         return ( rList1[ 0 ]->aStart < rList2[ 0 ]->aStart );
    9606             :     }
    9607             : };
    9608             : 
    9609          62 : void ScUniqueCellFormatsObj::GetObjects_Impl()
    9610             : {
    9611          62 :     if (pDocShell)
    9612             :     {
    9613          62 :         ScDocument& rDoc = pDocShell->GetDocument();
    9614          62 :         SCTAB nTab = aTotalRange.aStart.Tab();
    9615             :         ScAttrRectIterator aIter( &rDoc, nTab,
    9616          62 :                                     aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
    9617         124 :                                     aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
    9618             :         SCCOL nCol1, nCol2;
    9619             :         SCROW nRow1, nRow2;
    9620             : 
    9621             :         // Collect the ranges for each format in a hash map, to avoid nested loops
    9622             : 
    9623         124 :         ScUniqueFormatsHashMap aHashMap;
    9624         480 :         while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
    9625             :         {
    9626         356 :             ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
    9627         356 :             const ScPatternAttr* pPattern = rDoc.GetPattern(nCol1, nRow1, nTab);
    9628         356 :             aHashMap[pPattern].Join( aRange );
    9629             :         }
    9630             : 
    9631             :         // Fill the vector aRangeLists with the range lists from the hash map
    9632             : 
    9633          62 :         aRangeLists.reserve( aHashMap.size() );
    9634          62 :         ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
    9635          62 :         ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
    9636         298 :         while ( aMapIter != aMapEnd )
    9637             :         {
    9638         174 :             ScUniqueFormatsEntry& rEntry = aMapIter->second;
    9639         174 :             const ScRangeList& rRanges = rEntry.GetRanges();
    9640         174 :             aRangeLists.push_back( rRanges );       // copy ScRangeList
    9641         174 :             rEntry.Clear();                         // free memory, don't hold both copies of all ranges
    9642         174 :             ++aMapIter;
    9643             :         }
    9644             : 
    9645             :         // Sort the vector by first range's start position, to avoid random shuffling
    9646             :         // due to using the ScPatterAttr pointers
    9647             : 
    9648             :         ScUniqueFormatsOrder aComp;
    9649         124 :         ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
    9650             :     }
    9651          62 : }
    9652             : 
    9653             : // XIndexAccess
    9654             : 
    9655          60 : sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
    9656             : {
    9657          60 :     SolarMutexGuard aGuard;
    9658             : 
    9659          60 :     return aRangeLists.size();
    9660             : }
    9661             : 
    9662         166 : uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
    9663             :                             throw(lang::IndexOutOfBoundsException,
    9664             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9665             : {
    9666         166 :     SolarMutexGuard aGuard;
    9667             : 
    9668         166 :     if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
    9669         328 :         return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
    9670             :     else
    9671         164 :         throw lang::IndexOutOfBoundsException();
    9672             : }
    9673             : 
    9674           2 : uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
    9675             : {
    9676           2 :     SolarMutexGuard aGuard;
    9677           2 :     return cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
    9678             : }
    9679             : 
    9680           2 : sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
    9681             : {
    9682           2 :     SolarMutexGuard aGuard;
    9683           2 :     return ( aRangeLists.size() != 0 );
    9684             : }
    9685             : 
    9686             : // XEnumerationAccess
    9687             : 
    9688           4 : uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
    9689             :                                                     throw(uno::RuntimeException, std::exception)
    9690             : {
    9691           4 :     SolarMutexGuard aGuard;
    9692           4 :     if (pDocShell)
    9693           4 :         return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
    9694           0 :     return NULL;
    9695             : }
    9696             : 
    9697           4 : ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
    9698             :     aRangeLists(rRangeLists),
    9699             :     pDocShell( pDocSh ),
    9700           4 :     nCurrentPosition(0)
    9701             : {
    9702           4 :     pDocShell->GetDocument().AddUnoObject(*this);
    9703           4 : }
    9704             : 
    9705          12 : ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
    9706             : {
    9707           4 :     SolarMutexGuard g;
    9708             : 
    9709           4 :     if (pDocShell)
    9710           0 :         pDocShell->GetDocument().RemoveUnoObject(*this);
    9711           8 : }
    9712             : 
    9713           4 : void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
    9714             : {
    9715           4 :     if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
    9716             :     {
    9717             :         //! und nun ???
    9718             :     }
    9719           4 :     else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
    9720             :     {
    9721           4 :         sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
    9722           4 :         if ( nId == SFX_HINT_DYING )
    9723           4 :             pDocShell = NULL;                       // ungueltig geworden
    9724             :     }
    9725           4 : }
    9726             : 
    9727             : // XEnumeration
    9728             : 
    9729          20 : sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
    9730             : {
    9731          20 :     SolarMutexGuard aGuard;
    9732          20 :     return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
    9733             : }
    9734             : 
    9735          10 : uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
    9736             :                                         lang::WrappedTargetException, uno::RuntimeException, std::exception)
    9737             : {
    9738          10 :     SolarMutexGuard aGuard;
    9739             : 
    9740          10 :     if ( !hasMoreElements() || !pDocShell )
    9741           2 :         throw container::NoSuchElementException();      // no more elements
    9742             : 
    9743             :     // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
    9744             : 
    9745           8 :     return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));
    9746         228 : }
    9747             : 
    9748             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10