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

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

Generated by: LCOV version 1.10