LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/table - cell.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 273 743 36.7 %
Date: 2013-07-09 Functions: 51 111 45.9 %
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             : 
      21             : #include <com/sun/star/drawing/BitmapMode.hpp>
      22             : #include <com/sun/star/style/XStyle.hpp>
      23             : #include <com/sun/star/text/WritingMode.hpp>
      24             : #include <com/sun/star/table/TableBorder.hpp>
      25             : #include <com/sun/star/table/BorderLine2.hpp>
      26             : 
      27             : #include <comphelper/string.hxx>
      28             : 
      29             : #include <cppuhelper/typeprovider.hxx>
      30             : #include <svl/style.hxx>
      31             : #include <svl/itemset.hxx>
      32             : 
      33             : #include <osl/mutex.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : 
      36             : #include "svx/sdr/properties/textproperties.hxx"
      37             : #include "editeng/outlobj.hxx"
      38             : #include "editeng/writingmodeitem.hxx"
      39             : #include "svx/svdotable.hxx"
      40             : #include "svx/svdoutl.hxx"
      41             : #include "svx/unoshtxt.hxx"
      42             : #include "svx/svdmodel.hxx"
      43             : 
      44             : #include "tableundo.hxx"
      45             : #include "cell.hxx"
      46             : #include "svx/unoshprp.hxx"
      47             : #include "svx/unoshape.hxx"
      48             : #include "editeng/editobj.hxx"
      49             : #include "editeng/boxitem.hxx"
      50             : #include "svx/xflbstit.hxx"
      51             : #include "svx/xflbmtit.hxx"
      52             : #include <svx/svdpool.hxx>
      53             : 
      54             : // -----------------------------------------------------------------------------
      55             : 
      56             : using ::editeng::SvxBorderLine;
      57             : using namespace ::com::sun::star::uno;
      58             : using namespace ::com::sun::star::beans;
      59             : using namespace ::com::sun::star::lang;
      60             : using namespace ::com::sun::star::text;
      61             : using namespace ::com::sun::star::table;
      62             : using namespace ::com::sun::star::drawing;
      63             : using namespace ::com::sun::star::style;
      64             : using namespace ::com::sun::star::container;
      65             : 
      66             : // -----------------------------------------------------------------------------
      67             : 
      68         407 : static const SvxItemPropertySet* ImplGetSvxCellPropertySet()
      69             : {
      70             :     // Propertymap fuer einen Outliner Text
      71             :     static const SfxItemPropertyMapEntry aSvxCellPropertyMap[] =
      72             :     {
      73          52 :         FILL_PROPERTIES
      74             : //      { MAP_CHAR_LEN("HasLevels"),                    OWN_ATTR_HASLEVELS,             &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY,      0},
      75           2 :         { MAP_CHAR_LEN("Style"),                        OWN_ATTR_STYLE,                 &::com::sun::star::style::XStyle::static_type(),                                    ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
      76           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_WRITINGMODE),      SDRATTR_TEXTDIRECTION,          &::getCppuType( (::com::sun::star::text::WritingMode*) 0 ),                         0,      0},
      77           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_HORZADJUST),       SDRATTR_TEXT_HORZADJUST,        &::getCppuType((const ::com::sun::star::drawing::TextHorizontalAdjust*)0),  0,      0}, \
      78           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_LEFTDIST),         SDRATTR_TEXT_LEFTDIST,          &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
      79           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_LOWERDIST),        SDRATTR_TEXT_LOWERDIST,         &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
      80           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_RIGHTDIST),        SDRATTR_TEXT_RIGHTDIST,         &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
      81           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_UPPERDIST),        SDRATTR_TEXT_UPPERDIST,         &::getCppuType((const sal_Int32*)0),        0,      SFX_METRIC_ITEM}, \
      82           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_VERTADJUST),       SDRATTR_TEXT_VERTADJUST,        &::getCppuType((const ::com::sun::star::drawing::TextVerticalAdjust*)0),    0,      0},\
      83           2 :         { MAP_CHAR_LEN(UNO_NAME_TEXT_WORDWRAP),         SDRATTR_TEXT_WORDWRAP,          &::getBooleanCppuType(),        0,      0}, \
      84             : 
      85           2 :         { MAP_CHAR_LEN("TableBorder"),                  OWN_ATTR_TABLEBORDER,           &::getCppuType((const TableBorder*)0), 0, 0 }, \
      86           2 :         { MAP_CHAR_LEN("TopBorder"),                    SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, TOP_BORDER }, \
      87           2 :         { MAP_CHAR_LEN("BottomBorder"),                 SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, BOTTOM_BORDER }, \
      88           2 :         { MAP_CHAR_LEN("LeftBorder"),                   SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, LEFT_BORDER }, \
      89           2 :         { MAP_CHAR_LEN("RightBorder"),                  SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, RIGHT_BORDER }, \
      90             : 
      91          10 :         SVX_UNOEDIT_OUTLINER_PROPERTIES,
      92          92 :         SVX_UNOEDIT_CHAR_PROPERTIES,
      93          28 :         SVX_UNOEDIT_PARA_PROPERTIES,
      94             :         {0,0,0,0,0,0}
      95         617 :     };
      96             : 
      97         407 :     static SvxItemPropertySet aSvxCellPropertySet( aSvxCellPropertyMap, SdrObject::GetGlobalDrawObjectItemPool() );
      98         407 :     return &aSvxCellPropertySet;
      99             : }
     100             : 
     101             : namespace
     102             : {
     103             : 
     104             : class CellTextProvider : public svx::ITextProvider
     105             : {
     106             : public:
     107             :     explicit CellTextProvider(const sdr::table::CellRef xCell);
     108             :     virtual ~CellTextProvider();
     109             : 
     110             : private:
     111             :     virtual sal_Int32 getTextCount() const;
     112             :     virtual SdrText* getText(sal_Int32 nIndex) const;
     113             : 
     114             : private:
     115             :     const sdr::table::CellRef m_xCell;
     116             : };
     117             : 
     118         407 : CellTextProvider::CellTextProvider(const sdr::table::CellRef xCell)
     119         407 :     : m_xCell(xCell)
     120             : {
     121         407 : }
     122             : 
     123         407 : CellTextProvider::~CellTextProvider()
     124             : {
     125         407 : }
     126             : 
     127          16 : sal_Int32 CellTextProvider::getTextCount() const
     128             : {
     129          16 :     return 1;
     130             : }
     131             : 
     132          16 : SdrText* CellTextProvider::getText(sal_Int32 nIndex) const
     133             : {
     134             :     (void) nIndex;
     135             :     assert(nIndex == 0);
     136          16 :     return m_xCell.get();
     137             : }
     138             : 
     139             : }
     140             : 
     141             : namespace sdr
     142             : {
     143             :     namespace properties
     144             :     {
     145             :         class CellProperties : public TextProperties
     146             :         {
     147             :         protected:
     148             :             // create a new itemset
     149             :             SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool);
     150             : 
     151             :             const svx::ITextProvider& getTextProvider() const;
     152             : 
     153             :         public:
     154             :             // basic constructor
     155             :             CellProperties(SdrObject& rObj, sdr::table::Cell* pCell );
     156             : 
     157             :             // constructor for copying, but using new object
     158             :             CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell);
     159             : 
     160             :             // destructor
     161             :             ~CellProperties();
     162             : 
     163             :             // Clone() operator, normally just calls the local copy constructor
     164             :             BaseProperties& Clone(SdrObject& rObj) const;
     165             : 
     166             :             void ForceDefaultAttributes();
     167             : 
     168             :             void ItemSetChanged(const SfxItemSet& rSet);
     169             : 
     170             :             void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem);
     171             : 
     172             :             void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr);
     173             : 
     174             :             sdr::table::CellRef mxCell;
     175             : 
     176             :         private:
     177             :             const CellTextProvider maTextProvider;
     178             :         };
     179             : 
     180             :         // create a new itemset
     181         407 :         SfxItemSet& CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
     182             :         {
     183             :             return *(new SfxItemSet(rPool,
     184             : 
     185             :                 // range from SdrAttrObj
     186             :                 SDRATTR_START, SDRATTR_SHADOW_LAST,
     187             :                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
     188             :                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
     189             : 
     190             :                 // range for SdrTableObj
     191             :                 SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
     192             : 
     193             :                 // range from SdrTextObj
     194             :                 EE_ITEMS_START, EE_ITEMS_END,
     195             : 
     196             :                 // end
     197         407 :                 0, 0));
     198             :         }
     199             : 
     200          16 :         const svx::ITextProvider& CellProperties::getTextProvider() const
     201             :         {
     202          16 :             return maTextProvider;
     203             :         }
     204             : 
     205         407 :         CellProperties::CellProperties(SdrObject& rObj, sdr::table::Cell* pCell)
     206             :         :   TextProperties(rObj)
     207             :         ,   mxCell(pCell)
     208         407 :         ,   maTextProvider(mxCell)
     209             :         {
     210         407 :         }
     211             : 
     212           0 :         CellProperties::CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell)
     213             :         :   TextProperties(rProps, rObj)
     214             :         ,   mxCell( pCell )
     215           0 :         ,   maTextProvider(mxCell)
     216             :         {
     217           0 :         }
     218             : 
     219         814 :         CellProperties::~CellProperties()
     220             :         {
     221         814 :         }
     222             : 
     223           0 :         BaseProperties& CellProperties::Clone(SdrObject& rObj) const
     224             :         {
     225             :             OSL_FAIL("CellProperties::Clone(), does not work yet!");
     226           0 :             return *(new CellProperties(*this, rObj,0));
     227             :         }
     228             : 
     229         407 :         void CellProperties::ForceDefaultAttributes()
     230             :         {
     231         407 :         }
     232             : 
     233        4568 :         void CellProperties::ItemSetChanged(const SfxItemSet& rSet )
     234             :         {
     235        4568 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
     236             : 
     237        4568 :             if( mxCell.is() )
     238             :             {
     239        4568 :                 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
     240             : 
     241        4568 :                 bool bOwnParaObj = pParaObj != 0;
     242             : 
     243        4568 :                 if( pParaObj == 0 )
     244        4568 :                     pParaObj = mxCell->GetOutlinerParaObject();
     245             : 
     246        4568 :                 if(pParaObj)
     247             :                 {
     248             :                     // handle outliner attributes
     249        4568 :                     Outliner* pOutliner = 0;
     250             : 
     251        4568 :                     if(mxCell->IsTextEditActive())
     252             :                     {
     253           0 :                         pOutliner = rObj.GetTextEditOutliner();
     254             :                     }
     255             :                     else
     256             :                     {
     257        4568 :                         pOutliner = &rObj.ImpGetDrawOutliner();
     258        4568 :                         pOutliner->SetText(*pParaObj);
     259             :                     }
     260             : 
     261        4568 :                     sal_Int32 nParaCount(pOutliner->GetParagraphCount());
     262             : 
     263        9136 :                     for(sal_Int32 nPara = 0; nPara < nParaCount; nPara++)
     264             :                     {
     265        4568 :                         SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
     266        4568 :                         aSet.Put(rSet);
     267        4568 :                         pOutliner->SetParaAttribs(nPara, aSet);
     268        4568 :                     }
     269             : 
     270        4568 :                     if(!mxCell->IsTextEditActive())
     271             :                     {
     272        4568 :                         if(nParaCount)
     273             :                         {
     274             :                             // force ItemSet
     275        4568 :                             GetObjectItemSet();
     276             : 
     277        4568 :                             SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
     278        4568 :                             mpItemSet->Put(aNewSet);
     279             :                         }
     280             : 
     281        4568 :                         OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount);
     282        4568 :                         pOutliner->Clear();
     283             : 
     284        4568 :                         mxCell->SetOutlinerParaObject(pTemp);
     285             :                     }
     286             : 
     287        4568 :                     if( bOwnParaObj )
     288           0 :                         delete pParaObj;
     289             :                 }
     290             :             }
     291             : 
     292             :             // call parent
     293        4568 :             AttributeProperties::ItemSetChanged(rSet);
     294             : 
     295        4568 :             if( mxCell.is() )
     296        4568 :                 mxCell->notifyModified();
     297        4568 :         }
     298             : 
     299        4568 :         void CellProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
     300             :         {
     301        4568 :             if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
     302             :             {
     303           0 :                 sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
     304             : 
     305           0 :                 sdr::table::SdrTableObj& rObj = (sdr::table::SdrTableObj&)GetSdrObject();
     306           0 :                 if( rObj.IsVerticalWriting() != bVertical )
     307           0 :                     rObj.SetVerticalWriting(bVertical);
     308             : 
     309             :                 // Set a cell vertical property
     310           0 :                 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
     311           0 :                 if( pParaObj == 0 )
     312           0 :                     pParaObj = mxCell->GetOutlinerParaObject();
     313           0 :                 if(pParaObj)
     314             :                 {
     315           0 :                     pParaObj->SetVertical(bVertical);
     316             :                 }
     317             : 
     318             :             }
     319             : 
     320             :             // call parent
     321        4568 :             AttributeProperties::ItemChange( nWhich, pNewItem );
     322        4568 :         }
     323             : 
     324          16 :         void CellProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
     325             :         {
     326          16 :             TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
     327          16 :         }
     328             :     } // end of namespace properties
     329             : } // end of namespace sdr
     330             : 
     331             : namespace sdr { namespace table {
     332             : 
     333             : // -----------------------------------------------------------------------------
     334             : // Cell
     335             : // -----------------------------------------------------------------------------
     336             : 
     337         407 : rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject )
     338             : {
     339         407 :     rtl::Reference< Cell > xCell( new Cell( rTableObj, pOutlinerParaObject ) );
     340         407 :     if( xCell->mxTable.is() )
     341             :     {
     342         407 :         Reference< XEventListener > xListener( xCell.get() );
     343         407 :         xCell->mxTable->addEventListener( xListener );
     344             :     }
     345         407 :     return xCell;
     346             : }
     347             : 
     348             : // -----------------------------------------------------------------------------
     349             : 
     350         407 : Cell::Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw()
     351             : : SdrText( rTableObj, pOutlinerParaObject )
     352             : , SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
     353         407 : , mpPropSet( ImplGetSvxCellPropertySet() )
     354         407 : , mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
     355             : , mnCellContentType( CellContentType_EMPTY )
     356             : , mfValue( 0.0 )
     357             : , mnError( 0 )
     358             : , mbMerged( sal_False )
     359             : , mnRowSpan( 1 )
     360             : , mnColSpan( 1 )
     361        1221 : , mxTable( rTableObj.getTable() )
     362             : {
     363         407 :     if( rTableObj.GetModel() )
     364         407 :         SetModel( rTableObj.GetModel() );
     365         407 : }
     366             : 
     367             : // -----------------------------------------------------------------------------
     368             : 
     369        1221 : Cell::~Cell() throw()
     370             : {
     371         407 :     dispose();
     372         814 : }
     373             : 
     374             : // -----------------------------------------------------------------------------
     375             : 
     376        1221 : void Cell::dispose()
     377             : {
     378        1221 :     if( mxTable.is() )
     379             :     {
     380             :         try
     381             :         {
     382           0 :             Reference< XEventListener > xThis( this );
     383           0 :             mxTable->removeEventListener( xThis );
     384             :         }
     385           0 :         catch( Exception& )
     386             :         {
     387             :             OSL_FAIL("Cell::dispose(), exception caught!");
     388             :         }
     389           0 :         mxTable.clear();
     390             :     }
     391             : 
     392        1221 :     if( mpProperties )
     393             :     {
     394         407 :         delete mpProperties;
     395         407 :         mpProperties = 0;
     396             :     }
     397        1221 :     SetOutlinerParaObject( 0 );
     398        1221 : }
     399             : 
     400             : // -----------------------------------------------------------------------------
     401             : 
     402         407 : void Cell::SetModel(SdrModel* pNewModel)
     403             : {
     404         407 :     SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() );
     405         407 :     if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) )
     406             :     {
     407         407 :         if( mpProperties )
     408             :         {
     409         407 :             SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool();
     410             : 
     411             :             // test for correct pool in ItemSet; move to new pool if necessary
     412         407 :             if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool())
     413           0 :                 mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel);
     414             :         }
     415             : 
     416         407 :         if( pTextEditSource )
     417             :         {
     418           0 :             pTextEditSource->ChangeModel( pNewModel );
     419             :         }
     420             :         else
     421             :         {
     422         407 :             SetEditSource( new SvxTextEditSource( &GetObject(), this, static_cast< XWeak * >( this ) ) );
     423             :         }
     424             : 
     425         407 :         SetStyleSheet( 0, sal_True );
     426         407 :         SdrText::SetModel( pNewModel );
     427         407 :         ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
     428             :     }
     429         407 : }
     430             : 
     431             : // -----------------------------------------------------------------------------
     432             : 
     433           8 : void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan )
     434             : {
     435           8 :     if( (mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || (mbMerged != sal_False) )
     436             :     {
     437           8 :         mnColSpan = nColumnSpan;
     438           8 :         mnRowSpan = nRowSpan;
     439           8 :         mbMerged = sal_False;
     440           8 :         notifyModified();
     441             :     }
     442           8 : }
     443             : 
     444             : // -----------------------------------------------------------------------------
     445             : 
     446          11 : void Cell::mergeContent( const CellRef& xSourceCell )
     447             : {
     448          11 :     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
     449             : 
     450          11 :     if( xSourceCell->hasText() )
     451             :     {
     452           0 :         SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner();
     453           0 :         rOutliner.SetUpdateMode(sal_True);
     454             : 
     455           0 :         if( hasText() )
     456             :         {
     457           0 :             rOutliner.SetText(*GetOutlinerParaObject());
     458           0 :             rOutliner.AddText(*xSourceCell->GetOutlinerParaObject());
     459             :         }
     460             :         else
     461             :         {
     462           0 :             rOutliner.SetText(*xSourceCell->GetOutlinerParaObject());
     463             :         }
     464             : 
     465           0 :         SetOutlinerParaObject( rOutliner.CreateParaObject() );
     466           0 :         rOutliner.Clear();
     467           0 :         xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject());
     468           0 :         rOutliner.Clear();
     469           0 :         SetStyleSheet( GetStyleSheet(), sal_True );
     470             :     }
     471          11 : }
     472             : 
     473             : // -----------------------------------------------------------------------------
     474             : 
     475           0 : void Cell::cloneFrom( const CellRef& xCell )
     476             : {
     477           0 :     if( xCell.is() )
     478             :     {
     479           0 :         replaceContentAndFormating( xCell );
     480             : 
     481           0 :         mnCellContentType = xCell->mnCellContentType;
     482             : 
     483           0 :         msFormula = xCell->msFormula;
     484           0 :         mfValue = xCell->mfValue;
     485           0 :         mnError = xCell->mnError;
     486             : 
     487           0 :         mbMerged = xCell->mbMerged;
     488           0 :         mnRowSpan = xCell->mnRowSpan;
     489           0 :         mnColSpan = xCell->mnColSpan;
     490             : 
     491             :     }
     492           0 :     notifyModified();
     493           0 : }
     494             : 
     495           0 : void Cell::replaceContentAndFormating( const CellRef& xSourceCell )
     496             : {
     497           0 :     if( xSourceCell.is() && mpProperties )
     498             :     {
     499           0 :         mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
     500           0 :         SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) );
     501             : 
     502           0 :         SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
     503           0 :         SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
     504             : 
     505           0 :         if(rSourceTableObj.GetModel() != rTableObj.GetModel())
     506             :         {
     507           0 :             SetStyleSheet( 0, sal_True );
     508             :         }
     509             :     }
     510           0 : }
     511             : 
     512             : // -----------------------------------------------------------------------------
     513             : 
     514          11 : void Cell::setMerged()
     515             : {
     516          11 :     if( !mbMerged )
     517             :     {
     518          11 :         mbMerged = sal_True;
     519          11 :         notifyModified();
     520             :     }
     521          11 : }
     522             : 
     523             : // -----------------------------------------------------------------------------
     524             : 
     525        4587 : void Cell::notifyModified()
     526             : {
     527        4587 :     if( mxTable.is() )
     528        4587 :         mxTable->setModified( sal_True );
     529        4587 : }
     530             : 
     531             : // -----------------------------------------------------------------------------
     532             : // SdrTextShape proxy
     533             : // -----------------------------------------------------------------------------
     534             : 
     535        9136 : bool Cell::IsTextEditActive()
     536             : {
     537        9136 :     bool isActive = false;
     538        9136 :     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
     539        9136 :     if(rTableObj.getActiveCell().get() == this )
     540             :     {
     541         806 :         OutlinerParaObject* pParaObj = rTableObj.GetEditOutlinerParaObject();
     542         806 :         if( pParaObj != 0 )
     543             :         {
     544           0 :             isActive = true;
     545           0 :             delete pParaObj;
     546             :         }
     547             :     }
     548        9136 :     return isActive;
     549             : }
     550             : 
     551             : // -----------------------------------------------------------------------------
     552             : 
     553          11 : bool Cell::hasText() const
     554             : {
     555          11 :     OutlinerParaObject* pParaObj = GetOutlinerParaObject();
     556          11 :     if( pParaObj )
     557             :     {
     558          11 :         const EditTextObject& rTextObj = pParaObj->GetTextObject();
     559          11 :         if( rTextObj.GetParagraphCount() >= 1 )
     560             :         {
     561          11 :             if( rTextObj.GetParagraphCount() == 1 )
     562             :             {
     563          11 :                 if( rTextObj.GetText(0).Len() == 0 )
     564          11 :                     return false;
     565             :             }
     566           0 :             return true;
     567             :         }
     568             :     }
     569             : 
     570           0 :     return false;
     571             : }
     572             : 
     573             : // -----------------------------------------------------------------------------
     574             : 
     575        4568 : OutlinerParaObject* Cell::GetEditOutlinerParaObject() const
     576             : {
     577        4568 :     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
     578        4568 :     if( rTableObj.getActiveCell().get() == this )
     579         403 :         return rTableObj.GetEditOutlinerParaObject();
     580        4165 :     return 0;
     581             : }
     582             : 
     583             : // -----------------------------------------------------------------------------
     584             : 
     585         423 : void Cell::SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr )
     586             : {
     587             :     // only allow cell styles for cells
     588         423 :     if( pStyleSheet && pStyleSheet->GetFamily() != SFX_STYLE_FAMILY_FRAME )
     589         423 :         return;
     590             : 
     591         423 :     if( mpProperties && (mpProperties->GetStyleSheet() != pStyleSheet) )
     592             :     {
     593          16 :         mpProperties->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr );
     594             :     }
     595             : }
     596             : 
     597             : // -----------------------------------------------------------------------------
     598             : 
     599           0 : const SfxItemSet& Cell::GetObjectItemSet()
     600             : {
     601           0 :     if( mpProperties )
     602             :     {
     603           0 :         return mpProperties->GetObjectItemSet();
     604             :     }
     605             :     else
     606             :     {
     607             :         OSL_FAIL("Cell::GetObjectItemSet(), called without properties!");
     608           0 :         return GetObject().GetObjectItemSet();
     609             :     }
     610             : }
     611             : 
     612           0 : void Cell::SetObjectItem(const SfxPoolItem& rItem)
     613             : {
     614           0 :     if( mpProperties )
     615             :     {
     616           0 :         mpProperties->SetObjectItem( rItem );
     617           0 :         notifyModified();
     618             :     }
     619           0 : }
     620             : 
     621           0 : void Cell::SetMergedItem(const SfxPoolItem& rItem)
     622             : {
     623           0 :     SetObjectItem(rItem);
     624           0 : }
     625             : 
     626        1674 : SfxStyleSheet* Cell::GetStyleSheet() const
     627             : {
     628        1674 :     if( mpProperties )
     629         453 :         return mpProperties->GetStyleSheet();
     630             :     else
     631        1221 :         return 0;
     632             : }
     633             : 
     634             : // -----------------------------------------------------------------------------
     635             : 
     636           0 : const Rectangle& Cell::GetCurrentBoundRect() const
     637             : {
     638           0 :     return maCellRect;
     639             : }
     640             : 
     641             : // -----------------------------------------------------------------------------
     642             : 
     643      135000 : void Cell::TakeTextAnchorRect(Rectangle& rAnchorRect) const
     644             : {
     645      135000 :     rAnchorRect.Left() = maCellRect.Left() + GetTextLeftDistance();
     646      135000 :     rAnchorRect.Right() = maCellRect.Right() - GetTextRightDistance();
     647      135000 :     rAnchorRect.Top() = maCellRect.Top() + GetTextUpperDistance();
     648      135000 :     rAnchorRect.Bottom() = maCellRect.Bottom() - GetTextLowerDistance();
     649      135000 : }
     650             : 
     651             : // -----------------------------------------------------------------------------
     652             : 
     653     1149201 : const SfxItemSet& Cell::GetItemSet() const
     654             : {
     655     1149201 :     return mpProperties->GetObjectItemSet();
     656             : }
     657             : 
     658             : // -----------------------------------------------------------------------------
     659             : 
     660           0 : void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
     661             : {
     662           0 :     if( mpProperties )
     663             :     {
     664           0 :         mpProperties->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
     665           0 :         notifyModified();
     666             :     }
     667           0 : }
     668             : 
     669             : // -----------------------------------------------------------------------------
     670             : 
     671      135000 : sal_Int32 Cell::getMinimumWidth()
     672             : {
     673      135000 :     return GetTextLeftDistance() + GetTextRightDistance() + 100;
     674             : }
     675             : 
     676             : // -----------------------------------------------------------------------------
     677             : 
     678      135000 : sal_Int32 Cell::getMinimumHeight()
     679             : {
     680      135000 :     if( !mpProperties )
     681           0 :         return 0;
     682             : 
     683      135000 :     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
     684      135000 :     sal_Int32 nMinimumHeight = 0;
     685             : 
     686      135000 :     Rectangle aTextRect;
     687      135000 :     TakeTextAnchorRect( aTextRect );
     688      135000 :     Size aSize( aTextRect.GetSize() );
     689      135000 :     aSize.Height()=0x0FFFFFFF;
     690             : 
     691      135000 :     SdrOutliner* pEditOutliner = rTableObj.GetCellTextEditOutliner( *this );
     692      135000 :     if(pEditOutliner)
     693             :     {
     694           0 :         pEditOutliner->SetMaxAutoPaperSize(aSize);
     695           0 :         nMinimumHeight = pEditOutliner->GetTextHeight()+1;
     696             :     }
     697             :     else /*if ( hasText() )*/
     698             :     {
     699      135000 :         Outliner& rOutliner=rTableObj.ImpGetDrawOutliner();
     700      135000 :         rOutliner.SetPaperSize(aSize);
     701      135000 :         rOutliner.SetUpdateMode(sal_True);
     702      135000 :         ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
     703             : 
     704      135000 :         if( GetOutlinerParaObject() )
     705             :         {
     706      135000 :             rOutliner.SetText(*GetOutlinerParaObject());
     707             :         }
     708      135000 :         nMinimumHeight=rOutliner.GetTextHeight()+1;
     709      135000 :         rOutliner.Clear();
     710             :     }
     711             : 
     712      135000 :     nMinimumHeight += GetTextUpperDistance() + GetTextLowerDistance();
     713      135000 :     return nMinimumHeight;
     714             : }
     715             : 
     716             : // -----------------------------------------------------------------------------
     717             : 
     718      270000 : long Cell::GetTextLeftDistance() const
     719             : {
     720      270000 :     return ((SdrTextLeftDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
     721             : }
     722             : 
     723             : // -----------------------------------------------------------------------------
     724             : 
     725      270000 : long Cell::GetTextRightDistance() const
     726             : {
     727      270000 :     return ((SdrTextRightDistItem&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
     728             : }
     729             : 
     730             : // -----------------------------------------------------------------------------
     731             : 
     732      270000 : long Cell::GetTextUpperDistance() const
     733             : {
     734      270000 :     return ((SdrTextUpperDistItem&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
     735             : }
     736             : 
     737             : // -----------------------------------------------------------------------------
     738             : 
     739      270000 : long Cell::GetTextLowerDistance() const
     740             : {
     741      270000 :     return ((SdrTextLowerDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
     742             : }
     743             : 
     744             : // -----------------------------------------------------------------------------
     745             : 
     746           0 : SdrTextVertAdjust Cell::GetTextVerticalAdjust() const
     747             : {
     748           0 :     return ((SdrTextVertAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
     749             : }
     750             : 
     751             : // -----------------------------------------------------------------------------
     752             : 
     753           0 : SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const
     754             : {
     755           0 :     return ((SdrTextHorzAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
     756             : }
     757             : 
     758             : // -----------------------------------------------------------------------------
     759             : 
     760        7833 : void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
     761             : {
     762        7833 :     SdrText::SetOutlinerParaObject( pTextObject );
     763        7833 :     maSelection.nStartPara = EE_PARA_MAX_COUNT;
     764             : 
     765        7833 :     if( pTextObject == 0 )
     766        1221 :         ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
     767        7833 : }
     768             : 
     769             : // -----------------------------------------------------------------------------
     770             : 
     771           0 : void Cell::AddUndo()
     772             : {
     773           0 :     SdrObject& rObj = GetObject();
     774           0 :     if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
     775             :     {
     776           0 :         CellRef xCell( this );
     777           0 :         GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
     778             :     }
     779           0 : }
     780             : 
     781             : // -----------------------------------------------------------------------------
     782             : 
     783           0 : sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell )
     784             : {
     785           0 :     if( pProperties )
     786           0 :         return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(pProperties), rNewObj, &rNewCell );
     787             :     else
     788           0 :         return 0;
     789             : }
     790             : 
     791             : // -----------------------------------------------------------------------------
     792             : 
     793           0 : sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell )
     794             : {
     795           0 :     return CloneProperties(mpProperties,rNewObj,rNewCell);
     796             : }
     797             : 
     798             : // -----------------------------------------------------------------------------
     799             : // XInterface
     800             : // -----------------------------------------------------------------------------
     801             : 
     802        2420 : Any SAL_CALL Cell::queryInterface( const Type & rType ) throw(RuntimeException)
     803             : {
     804        2420 :     if( rType == XMergeableCell::static_type() )
     805          65 :         return Any( Reference< XMergeableCell >( this ) );
     806             : 
     807        2355 :     if( rType == XCell::static_type() )
     808           0 :         return Any( Reference< XCell >( this ) );
     809             : 
     810        2355 :     if( rType == XLayoutConstrains::static_type() )
     811           0 :         return Any( Reference< XLayoutConstrains >( this ) );
     812             : 
     813        2355 :     if( rType == XEventListener::static_type() )
     814         407 :         return Any( Reference< XEventListener >( this ) );
     815             : 
     816        1948 :     Any aRet( SvxUnoTextBase::queryAggregation( rType ) );
     817        1948 :     if( aRet.hasValue() )
     818        1932 :         return aRet;
     819             : 
     820          16 :     return ::cppu::OWeakObject::queryInterface( rType );
     821             : }
     822             : 
     823             : // -----------------------------------------------------------------------------
     824             : 
     825     2282250 : void SAL_CALL Cell::acquire() throw ()
     826             : {
     827     2282250 :     ::cppu::OWeakObject::acquire();
     828     2282250 : }
     829             : 
     830             : // -----------------------------------------------------------------------------
     831             : 
     832     2282250 : void SAL_CALL Cell::release() throw ()
     833             : {
     834     2282250 :     ::cppu::OWeakObject::release();
     835     2282250 : }
     836             : 
     837             : // -----------------------------------------------------------------------------
     838             : // XTypeProvider
     839             : // -----------------------------------------------------------------------------
     840             : 
     841           0 : Sequence< Type > SAL_CALL Cell::getTypes(  ) throw (RuntimeException)
     842             : {
     843           0 :     Sequence< Type > aTypes( SvxUnoTextBase::getTypes() );
     844             : 
     845           0 :     sal_Int32 nLen = aTypes.getLength();
     846           0 :     aTypes.realloc(nLen + 2);
     847           0 :     aTypes[nLen++] = XMergeableCell::static_type();
     848           0 :     aTypes[nLen++] = XLayoutConstrains::static_type();
     849             : 
     850           0 :     return aTypes;
     851             : }
     852             : 
     853             : // -----------------------------------------------------------------------------
     854             : 
     855           0 : Sequence< sal_Int8 > SAL_CALL Cell::getImplementationId(  ) throw (RuntimeException)
     856             : {
     857             :     static ::cppu::OImplementationId* pId = 0;
     858           0 :     if (! pId)
     859             :     {
     860           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     861           0 :         if (! pId)
     862             :         {
     863           0 :             static ::cppu::OImplementationId aId;
     864           0 :             pId = &aId;
     865           0 :         }
     866             :     }
     867           0 :     return pId->getImplementationId();
     868             : }
     869             : 
     870             : // -----------------------------------------------------------------------------
     871             : // XServiceInfo
     872             : // -----------------------------------------------------------------------------
     873             : 
     874           0 : OUString SAL_CALL Cell::getImplementationName(  ) throw (RuntimeException)
     875             : {
     876           0 :     return OUString( "com.sun.star.comp.svx.table.Cell" );
     877             : }
     878             : 
     879             : // -----------------------------------------------------------------------------
     880             : 
     881           0 : sal_Bool SAL_CALL Cell::supportsService( const OUString& ServiceName ) throw (RuntimeException)
     882             : {
     883           0 :     if( ServiceName == "com.sun.star.table.cell" )
     884           0 :         return sal_True;
     885             : 
     886           0 :     if( ServiceName == "com.sun.star.drawing.cell" )
     887           0 :         return sal_True;
     888             : 
     889           0 :     return SvxUnoTextBase::supportsService( ServiceName );
     890             : }
     891             : 
     892             : // -----------------------------------------------------------------------------
     893             : 
     894           0 : Sequence< OUString > SAL_CALL Cell::getSupportedServiceNames(  ) throw (RuntimeException)
     895             : {
     896           0 :     Sequence< OUString > aSeq( SvxUnoTextBase::getSupportedServiceNames() );
     897           0 :     sal_Int32 nIndex = aSeq.getLength();
     898           0 :     aSeq.realloc( nIndex + 2 );
     899           0 :     aSeq[nIndex++] = OUString( "com.sun.star.table.cell" );
     900           0 :     aSeq[nIndex++] = OUString( "com.sun.star.drawing.cell" );
     901           0 :     return aSeq;
     902             : }
     903             : 
     904             : // -----------------------------------------------------------------------------
     905             : // XLayoutConstrains
     906             : // -----------------------------------------------------------------------------
     907             : 
     908      135000 : ::com::sun::star::awt::Size SAL_CALL Cell::getMinimumSize(  ) throw (RuntimeException)
     909             : {
     910      135000 :     return ::com::sun::star::awt::Size( getMinimumWidth(),  getMinimumHeight() );
     911             : }
     912             : 
     913             : // -----------------------------------------------------------------------------
     914             : 
     915           0 : ::com::sun::star::awt::Size SAL_CALL Cell::getPreferredSize(  ) throw (RuntimeException)
     916             : {
     917           0 :     return getMinimumSize();
     918             : }
     919             : 
     920             : // -----------------------------------------------------------------------------
     921             : 
     922           0 : ::com::sun::star::awt::Size SAL_CALL Cell::calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (RuntimeException)
     923             : {
     924           0 :     return aNewSize;
     925             : }
     926             : 
     927             : // -----------------------------------------------------------------------------
     928             : // XMergeableCell
     929             : // -----------------------------------------------------------------------------
     930             : 
     931      272830 : sal_Int32 SAL_CALL Cell::getRowSpan() throw (RuntimeException)
     932             : {
     933      272830 :     return mnRowSpan;
     934             : }
     935             : 
     936             : // -----------------------------------------------------------------------------
     937             : 
     938      271772 : sal_Int32 SAL_CALL Cell::getColumnSpan() throw (RuntimeException)
     939             : {
     940      271772 :     return mnColSpan;
     941             : }
     942             : 
     943             : // -----------------------------------------------------------------------------
     944             : 
     945      412071 : sal_Bool SAL_CALL Cell::isMerged() throw (RuntimeException)
     946             : {
     947      412071 :     return mbMerged;
     948             : }
     949             : 
     950             : // -----------------------------------------------------------------------------
     951             : // XCell
     952             : // -----------------------------------------------------------------------------
     953             : 
     954           0 : OUString SAL_CALL Cell::getFormula(  ) throw (RuntimeException)
     955             : {
     956           0 :     return msFormula;
     957             : }
     958             : 
     959             : // -----------------------------------------------------------------------------
     960             : 
     961           0 : void SAL_CALL Cell::setFormula( const OUString& aFormula ) throw (RuntimeException)
     962             : {
     963           0 :     if( msFormula != aFormula )
     964             :     {
     965           0 :         msFormula = aFormula;
     966             :     }
     967           0 : }
     968             : 
     969             : // -----------------------------------------------------------------------------
     970             : 
     971           0 : double SAL_CALL Cell::getValue(  ) throw (RuntimeException)
     972             : {
     973           0 :     return mfValue;
     974             : }
     975             : 
     976             : // -----------------------------------------------------------------------------
     977             : 
     978           0 : void SAL_CALL Cell::setValue( double nValue ) throw (RuntimeException)
     979             : {
     980           0 :     if( mfValue != nValue )
     981             :     {
     982           0 :         mfValue = nValue;
     983           0 :         mnCellContentType = CellContentType_VALUE;
     984             :     }
     985           0 : }
     986             : 
     987             : // -----------------------------------------------------------------------------
     988             : 
     989           0 : CellContentType SAL_CALL Cell::getType() throw (RuntimeException)
     990             : {
     991           0 :     return mnCellContentType;
     992             : }
     993             : 
     994             : // -----------------------------------------------------------------------------
     995             : 
     996           0 : sal_Int32 SAL_CALL Cell::getError(  ) throw (RuntimeException)
     997             : {
     998           0 :     return mnError;
     999             : }
    1000             : 
    1001             : // -----------------------------------------------------------------------------
    1002             : // XPropertySet
    1003             : // -----------------------------------------------------------------------------
    1004             : 
    1005           0 : Any Cell::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap )
    1006             : {
    1007           0 :     Any aAny( SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ) );
    1008             : 
    1009           0 :     if( *pMap->pType != aAny.getValueType() )
    1010             :     {
    1011             :         // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
    1012           0 :         if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
    1013             :         {
    1014           0 :             sal_Int32 nValue = 0;
    1015           0 :             aAny >>= nValue;
    1016           0 :             aAny <<= (sal_Int16)nValue;
    1017             :         }
    1018             :         else
    1019             :         {
    1020             :             OSL_FAIL("GetAnyForItem() Returnvalue has wrong Type!" );
    1021             :         }
    1022             :     }
    1023             : 
    1024           0 :     return aAny;
    1025             : }
    1026             : 
    1027          16 : Reference< XPropertySetInfo > SAL_CALL Cell::getPropertySetInfo() throw(RuntimeException)
    1028             : {
    1029          16 :     return mpPropSet->getPropertySetInfo();
    1030             : }
    1031             : 
    1032             : // -----------------------------------------------------------------------------
    1033             : 
    1034        4552 : void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
    1035             : {
    1036        4552 :     ::SolarMutexGuard aGuard;
    1037             : 
    1038        4552 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1039           0 :         throw DisposedException();
    1040             : 
    1041        4552 :     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
    1042        4552 :     if( pMap )
    1043             :     {
    1044        4552 :         if( (pMap->nFlags & PropertyAttribute::READONLY ) != 0 )
    1045           0 :             throw PropertyVetoException();
    1046             : 
    1047        4552 :         switch( pMap->nWID )
    1048             :         {
    1049             :         case OWN_ATTR_STYLE:
    1050             :         {
    1051           0 :             Reference< XStyle > xStyle;
    1052           0 :             if( !( rValue >>= xStyle ) )
    1053           0 :                 throw IllegalArgumentException();
    1054             : 
    1055           0 :             SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle);
    1056           0 :             SetStyleSheet( pStyle, sal_True );
    1057           0 :             return;
    1058             :         }
    1059             :         case OWN_ATTR_TABLEBORDER:
    1060             :         {
    1061           0 :             if(rValue.getValueType() != ::getCppuType((const TableBorder*)0) )
    1062           0 :                 break;
    1063             : 
    1064           0 :             const TableBorder* pBorder = (const TableBorder* )rValue.getValue();
    1065           0 :             if( pBorder == NULL )
    1066           0 :                 break;
    1067             : 
    1068           0 :             SvxBoxItem aBox( SDRATTR_TABLE_BORDER );
    1069           0 :             SvxBoxInfoItem aBoxInfo( SDRATTR_TABLE_BORDER_INNER );
    1070           0 :             SvxBorderLine aLine;
    1071             : 
    1072           0 :             sal_Bool bSet = SvxBoxItem::LineToSvxLine(pBorder->TopLine, aLine, false);
    1073           0 :             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_TOP);
    1074           0 :             aBoxInfo.SetValid(VALID_TOP, pBorder->IsTopLineValid);
    1075             : 
    1076           0 :             bSet = SvxBoxItem::LineToSvxLine(pBorder->BottomLine, aLine, false);
    1077           0 :             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM);
    1078           0 :             aBoxInfo.SetValid(VALID_BOTTOM, pBorder->IsBottomLineValid);
    1079             : 
    1080           0 :             bSet = SvxBoxItem::LineToSvxLine(pBorder->LeftLine, aLine, false);
    1081           0 :             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT);
    1082           0 :             aBoxInfo.SetValid(VALID_LEFT, pBorder->IsLeftLineValid);
    1083             : 
    1084           0 :             bSet = SvxBoxItem::LineToSvxLine(pBorder->RightLine, aLine, false);
    1085           0 :             aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT);
    1086           0 :             aBoxInfo.SetValid(VALID_RIGHT, pBorder->IsRightLineValid);
    1087             : 
    1088           0 :             bSet = SvxBoxItem::LineToSvxLine(pBorder->HorizontalLine, aLine, false);
    1089           0 :             aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_HORI);
    1090           0 :             aBoxInfo.SetValid(VALID_HORI, pBorder->IsHorizontalLineValid);
    1091             : 
    1092           0 :             bSet = SvxBoxItem::LineToSvxLine(pBorder->VerticalLine, aLine, false);
    1093           0 :             aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_VERT);
    1094           0 :             aBoxInfo.SetValid(VALID_VERT, pBorder->IsVerticalLineValid);
    1095             : 
    1096           0 :             aBox.SetDistance(pBorder->Distance, false);
    1097           0 :             aBoxInfo.SetValid(VALID_DISTANCE, pBorder->IsDistanceValid);
    1098             : 
    1099           0 :             mpProperties->SetObjectItem(aBox);
    1100           0 :             mpProperties->SetObjectItem(aBoxInfo);
    1101           0 :             return;
    1102             :         }
    1103             :         case OWN_ATTR_FILLBMP_MODE:
    1104             :         {
    1105             :             BitmapMode eMode;
    1106          16 :             if(!(rValue >>= eMode) )
    1107             :             {
    1108           0 :                 sal_Int32 nMode = 0;
    1109           0 :                 if(!(rValue >>= nMode))
    1110           0 :                     throw IllegalArgumentException();
    1111             : 
    1112           0 :                 eMode = (BitmapMode)nMode;
    1113             :             }
    1114             : 
    1115          16 :             mpProperties->SetObjectItem( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
    1116          16 :             mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
    1117          16 :             return;
    1118             :         }
    1119             :         default:
    1120             :         {
    1121        4536 :             SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
    1122        4536 :             aSet.Put(mpProperties->GetItem(pMap->nWID));
    1123             : 
    1124        4536 :             bool bSpecial = false;
    1125             : 
    1126        4536 :             switch( pMap->nWID )
    1127             :             {
    1128             :                 case XATTR_FILLBITMAP:
    1129             :                 case XATTR_FILLGRADIENT:
    1130             :                 case XATTR_FILLHATCH:
    1131             :                 case XATTR_FILLFLOATTRANSPARENCE:
    1132             :                 case XATTR_LINEEND:
    1133             :                 case XATTR_LINESTART:
    1134             :                 case XATTR_LINEDASH:
    1135             :                 {
    1136           0 :                     if( pMap->nMemberId == MID_NAME )
    1137             :                     {
    1138           0 :                         OUString aApiName;
    1139           0 :                         if( rValue >>= aApiName )
    1140             :                         {
    1141           0 :                             if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) )
    1142           0 :                                 bSpecial = true;
    1143           0 :                         }
    1144             :                     }
    1145             :                 }
    1146           0 :                 break;
    1147             :             }
    1148             : 
    1149        4536 :             if( !bSpecial )
    1150             :             {
    1151             : 
    1152        4536 :                 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pMap, rValue, aSet ))
    1153             :                 {
    1154        4536 :                     if( aSet.GetItemState( pMap->nWID ) != SFX_ITEM_SET )
    1155             :                     {
    1156             :                         // Default aus ItemPool holen
    1157           0 :                         if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
    1158           0 :                             aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
    1159             :                     }
    1160             : 
    1161        4536 :                     if( aSet.GetItemState( pMap->nWID ) == SFX_ITEM_SET )
    1162             :                     {
    1163        4536 :                         SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rValue, aSet );
    1164             :                     }
    1165             :                 }
    1166             :             }
    1167             : 
    1168        4536 :             GetModel()->SetChanged();
    1169        4536 :             mpProperties->SetMergedItemSetAndBroadcast( aSet );
    1170        4536 :             return;
    1171             :         }
    1172             :         }
    1173             :     }
    1174           0 :     throw UnknownPropertyException();
    1175             : }
    1176             : 
    1177             : // -----------------------------------------------------------------------------
    1178             : 
    1179           0 : Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1180             : {
    1181           0 :     ::SolarMutexGuard aGuard;
    1182             : 
    1183           0 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1184           0 :         throw DisposedException();
    1185             : 
    1186           0 :     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
    1187           0 :     if( pMap )
    1188             :     {
    1189           0 :         switch( pMap->nWID )
    1190             :         {
    1191             :         case OWN_ATTR_STYLE:
    1192             :         {
    1193           0 :             return Any( Reference< XStyle >( dynamic_cast< SfxUnoStyleSheet* >( GetStyleSheet() ) ) );
    1194             :         }
    1195             :         case OWN_ATTR_TABLEBORDER:
    1196             :         {
    1197           0 :             const SvxBoxInfoItem& rBoxInfoItem = static_cast<const SvxBoxInfoItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER));
    1198           0 :             const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER));
    1199             : 
    1200           0 :              TableBorder aTableBorder;
    1201           0 :             aTableBorder.TopLine                = SvxBoxItem::SvxLineToLine(rBox.GetTop(), false);
    1202           0 :             aTableBorder.IsTopLineValid         = rBoxInfoItem.IsValid(VALID_TOP);
    1203           0 :             aTableBorder.BottomLine             = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), false);
    1204           0 :             aTableBorder.IsBottomLineValid      = rBoxInfoItem.IsValid(VALID_BOTTOM);
    1205           0 :             aTableBorder.LeftLine               = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), false);
    1206           0 :             aTableBorder.IsLeftLineValid        = rBoxInfoItem.IsValid(VALID_LEFT);
    1207           0 :             aTableBorder.RightLine              = SvxBoxItem::SvxLineToLine(rBox.GetRight(), false);
    1208           0 :             aTableBorder.IsRightLineValid       = rBoxInfoItem.IsValid(VALID_RIGHT );
    1209           0 :             aTableBorder.HorizontalLine         = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), false);
    1210           0 :             aTableBorder.IsHorizontalLineValid  = rBoxInfoItem.IsValid(VALID_HORI);
    1211           0 :             aTableBorder.VerticalLine           = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), false);
    1212           0 :             aTableBorder.IsVerticalLineValid    = rBoxInfoItem.IsValid(VALID_VERT);
    1213           0 :             aTableBorder.Distance               = rBox.GetDistance();
    1214           0 :             aTableBorder.IsDistanceValid        = rBoxInfoItem.IsValid(VALID_DISTANCE);
    1215             : 
    1216           0 :             return Any( aTableBorder );
    1217             :         }
    1218             :         case OWN_ATTR_FILLBMP_MODE:
    1219             :         {
    1220           0 :             const XFillBmpStretchItem& rStretchItem = static_cast<const XFillBmpStretchItem&>(mpProperties->GetItem(XATTR_FILLBMP_STRETCH));
    1221           0 :             const XFillBmpTileItem& rTileItem = static_cast<const XFillBmpTileItem&>(mpProperties->GetItem(XATTR_FILLBMP_TILE));
    1222           0 :             if( rTileItem.GetValue() )
    1223             :             {
    1224           0 :                 return Any( BitmapMode_REPEAT );
    1225             :             }
    1226           0 :             else if( rStretchItem.GetValue() )
    1227             :             {
    1228           0 :                 return Any(  BitmapMode_STRETCH );
    1229             :             }
    1230             :             else
    1231             :             {
    1232           0 :                 return Any(  BitmapMode_NO_REPEAT );
    1233             :             }
    1234             :         }
    1235             :         default:
    1236             :         {
    1237           0 :             SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
    1238           0 :             aSet.Put(mpProperties->GetItem(pMap->nWID));
    1239             : 
    1240           0 :             Any aAny;
    1241           0 :             if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
    1242             :             {
    1243           0 :                 if(!aSet.Count())
    1244             :                 {
    1245             :                     // Default aus ItemPool holen
    1246           0 :                     if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
    1247           0 :                         aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
    1248             :                 }
    1249             : 
    1250           0 :                 if( aSet.Count() )
    1251           0 :                     aAny = GetAnyForItem( aSet, pMap );
    1252             :             }
    1253             : 
    1254           0 :             return aAny;
    1255             :         }
    1256             :         }
    1257             :     }
    1258           0 :     throw UnknownPropertyException();
    1259             : }
    1260             : 
    1261             : // -----------------------------------------------------------------------------
    1262             : 
    1263           0 : void SAL_CALL Cell::addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1264             : {
    1265           0 : }
    1266             : 
    1267             : // -----------------------------------------------------------------------------
    1268             : 
    1269           0 : void SAL_CALL Cell::removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1270             : {
    1271           0 : }
    1272             : 
    1273             : // -----------------------------------------------------------------------------
    1274             : 
    1275           0 : void SAL_CALL Cell::addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1276             : {
    1277           0 : }
    1278             : 
    1279             : // -----------------------------------------------------------------------------
    1280             : 
    1281           0 : void SAL_CALL Cell::removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1282             : {
    1283           0 : }
    1284             : 
    1285             : // -----------------------------------------------------------------------------
    1286             : // XMultiPropertySet
    1287             : // -----------------------------------------------------------------------------
    1288             : 
    1289          16 : void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
    1290             : {
    1291          16 :     ::SolarMutexGuard aSolarGuard;
    1292             : 
    1293          16 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1294           0 :         throw DisposedException();
    1295             : 
    1296          16 :     const sal_Int32 nCount = aPropertyNames.getLength();
    1297             : 
    1298          16 :     const OUString* pNames = aPropertyNames.getConstArray();
    1299          16 :     const Any* pValues = aValues.getConstArray();
    1300             : 
    1301          32 :     for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
    1302             :     {
    1303             :         try
    1304             :         {
    1305          16 :             setPropertyValue( *pNames, *pValues );
    1306             :         }
    1307           0 :         catch( UnknownPropertyException& )
    1308             :         {
    1309             :             OSL_FAIL("svx::Cell::setPropertyValues(), unknown property!" );
    1310             :         }
    1311           0 :         catch( Exception& )
    1312             :         {
    1313             :             OSL_FAIL("svx::Cell::setPropertyValues(), Exception caught!" );
    1314             :         }
    1315          16 :     }
    1316          16 : }
    1317             : 
    1318             : // -----------------------------------------------------------------------------
    1319             : 
    1320           0 : Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
    1321             : {
    1322           0 :     ::SolarMutexGuard aSolarGuard;
    1323             : 
    1324           0 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1325           0 :         throw DisposedException();
    1326             : 
    1327           0 :     const sal_Int32 nCount = aPropertyNames.getLength();
    1328           0 :     const OUString* pNames = aPropertyNames.getConstArray();
    1329             : 
    1330           0 :     Sequence< Any > aRet( nCount );
    1331           0 :     Any* pValue = aRet.getArray();
    1332             : 
    1333           0 :     for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
    1334             :     {
    1335             :         try
    1336             :         {
    1337           0 :             *pValue = getPropertyValue( *pNames );
    1338             :         }
    1339           0 :         catch( UnknownPropertyException& )
    1340             :         {
    1341             :             OSL_FAIL("svx::Cell::setPropertyValues(), unknown property!" );
    1342             :         }
    1343           0 :         catch( Exception& )
    1344             :         {
    1345             :             OSL_FAIL( "svx::Cell::getPropertyValues(), Exception caught!" );
    1346             :         }
    1347             :     }
    1348             : 
    1349           0 :     return aRet;
    1350             : }
    1351             : 
    1352             : // -----------------------------------------------------------------------------
    1353             : 
    1354           0 : void SAL_CALL Cell::addPropertiesChangeListener( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
    1355             : {
    1356           0 : }
    1357             : 
    1358             : // -----------------------------------------------------------------------------
    1359             : 
    1360           0 : void SAL_CALL Cell::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
    1361             : {
    1362           0 : }
    1363             : 
    1364             : // -----------------------------------------------------------------------------
    1365             : 
    1366           0 : void SAL_CALL Cell::firePropertiesChangeEvent( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
    1367             : {
    1368           0 : }
    1369             : 
    1370             : // -----------------------------------------------------------------------------
    1371             : // XPropertyState
    1372             : // -----------------------------------------------------------------------------
    1373             : 
    1374           0 : PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
    1375             : {
    1376           0 :     ::SolarMutexGuard aGuard;
    1377             : 
    1378           0 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1379           0 :         throw DisposedException();
    1380             : 
    1381           0 :     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
    1382             : 
    1383           0 :     if( pMap )
    1384             :     {
    1385             :         PropertyState eState;
    1386           0 :         switch( pMap->nWID )
    1387             :         {
    1388             :         case OWN_ATTR_FILLBMP_MODE:
    1389             :         {
    1390           0 :             const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
    1391             : 
    1392           0 :             const bool bStretch = rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET;
    1393           0 :             const bool bTile = rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET;
    1394           0 :             if( bStretch || bTile )
    1395             :             {
    1396           0 :                 eState = PropertyState_DIRECT_VALUE;
    1397             :             }
    1398             :             else
    1399             :             {
    1400           0 :                 eState = PropertyState_DEFAULT_VALUE;
    1401             :             }
    1402             :         }
    1403             :         case OWN_ATTR_STYLE:
    1404             :         {
    1405           0 :             return PropertyState_DIRECT_VALUE;
    1406             :         }
    1407             :         case OWN_ATTR_TABLEBORDER:
    1408             :         {
    1409           0 :             const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
    1410           0 :             if( (rSet.GetItemState( SDRATTR_TABLE_BORDER_INNER, sal_False ) == SFX_ITEM_DEFAULT) && (rSet.GetItemState( SDRATTR_TABLE_BORDER, sal_False ) == SFX_ITEM_DEFAULT) )
    1411           0 :                 return PropertyState_DEFAULT_VALUE;
    1412             : 
    1413           0 :             return PropertyState_DIRECT_VALUE;
    1414             :         }
    1415             :         default:
    1416             :         {
    1417           0 :             const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
    1418             : 
    1419           0 :             switch( rSet.GetItemState( pMap->nWID, sal_False ) )
    1420             :             {
    1421             :             case SFX_ITEM_READONLY:
    1422             :             case SFX_ITEM_SET:
    1423           0 :                 eState = PropertyState_DIRECT_VALUE;
    1424           0 :                 break;
    1425             :             case SFX_ITEM_DEFAULT:
    1426           0 :                 eState = PropertyState_DEFAULT_VALUE;
    1427           0 :                 break;
    1428             :             default:
    1429           0 :                 eState = PropertyState_AMBIGUOUS_VALUE;
    1430           0 :                 break;
    1431             :             }
    1432             : 
    1433             :             // if a item is set, this doesn't mean we want it :)
    1434           0 :             if( ( PropertyState_DIRECT_VALUE == eState ) )
    1435             :             {
    1436           0 :                 switch( pMap->nWID )
    1437             :                 {
    1438             :                 // the following items are disabled by changing the
    1439             :                 // fill style or the line style. so there is no need
    1440             :                 // to export items without names which should be empty
    1441             :                 case XATTR_FILLBITMAP:
    1442             :                 case XATTR_FILLGRADIENT:
    1443             :                 case XATTR_FILLHATCH:
    1444             :                 case XATTR_LINEDASH:
    1445             :                     {
    1446           0 :                         NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
    1447           0 :                         if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
    1448           0 :                             eState = PropertyState_DEFAULT_VALUE;
    1449             :                     }
    1450           0 :                     break;
    1451             : 
    1452             :                 // #i36115#
    1453             :                 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
    1454             :                 // may be a hard attribute covering the set LineStart of the parent (Style).
    1455             :                 // #i37644#
    1456             :                 // same is for fill float transparency
    1457             :                 case XATTR_LINEEND:
    1458             :                 case XATTR_LINESTART:
    1459             :                 case XATTR_FILLFLOATTRANSPARENCE:
    1460             :                     {
    1461           0 :                         NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
    1462           0 :                         if( pItem == NULL )
    1463           0 :                             eState = PropertyState_DEFAULT_VALUE;
    1464             :                     }
    1465           0 :                     break;
    1466             :                 }
    1467             :             }
    1468             :         }
    1469             :         }
    1470           0 :         return eState;
    1471             :     }
    1472           0 :     throw UnknownPropertyException();
    1473             : }
    1474             : 
    1475             : // -----------------------------------------------------------------------------
    1476             : 
    1477           0 : Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException)
    1478             : {
    1479           0 :     ::SolarMutexGuard aGuard;
    1480             : 
    1481           0 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1482           0 :         throw DisposedException();
    1483             : 
    1484           0 :     const sal_Int32 nCount = aPropertyName.getLength();
    1485             : 
    1486           0 :     Sequence< PropertyState > aRet( nCount );
    1487             : 
    1488           0 :     const OUString* pNames = aPropertyName.getConstArray();
    1489           0 :     PropertyState* pState = aRet.getArray();
    1490             : 
    1491           0 :     for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pState++ )
    1492             :     {
    1493             :         try
    1494             :         {
    1495           0 :             *pState = getPropertyState( *pNames );
    1496             :         }
    1497           0 :         catch( Exception& )
    1498             :         {
    1499           0 :             *pState = PropertyState_AMBIGUOUS_VALUE;
    1500             :         }
    1501             :     }
    1502             : 
    1503           0 :     return aRet;
    1504             : }
    1505             : 
    1506             : // -----------------------------------------------------------------------------
    1507             : 
    1508           0 : void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
    1509             : {
    1510           0 :     ::SolarMutexGuard aGuard;
    1511             : 
    1512           0 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1513           0 :         throw DisposedException();
    1514             : 
    1515           0 :     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
    1516           0 :     if( pMap )
    1517             :     {
    1518           0 :         switch( pMap->nWID )
    1519             :         {
    1520             :         case OWN_ATTR_FILLBMP_MODE:
    1521             :         {
    1522           0 :             mpProperties->ClearObjectItem( XATTR_FILLBMP_STRETCH );
    1523           0 :             mpProperties->ClearObjectItem( XATTR_FILLBMP_TILE );
    1524           0 :             break;
    1525             :         }
    1526             :         case OWN_ATTR_STYLE:
    1527           0 :             break;
    1528             : 
    1529             :         case OWN_ATTR_TABLEBORDER:
    1530             :         {
    1531           0 :             mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER );
    1532           0 :             mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER );
    1533           0 :             break;
    1534             :         }
    1535             : 
    1536             :         default:
    1537             :         {
    1538           0 :             mpProperties->ClearObjectItem( pMap->nWID );
    1539             :         }
    1540             :         }
    1541             : 
    1542           0 :         GetModel()->SetChanged();
    1543           0 :         return;
    1544             :     }
    1545           0 :     throw UnknownPropertyException();
    1546             : }
    1547             : 
    1548             : // -----------------------------------------------------------------------------
    1549             : 
    1550           0 : Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1551             : {
    1552           0 :     ::SolarMutexGuard aGuard;
    1553             : 
    1554           0 :     if( (mpProperties == 0) || (GetModel() == 0) )
    1555           0 :         throw DisposedException();
    1556             : 
    1557           0 :     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
    1558           0 :     if( pMap )
    1559             :     {
    1560           0 :         switch( pMap->nWID )
    1561             :         {
    1562             :         case OWN_ATTR_FILLBMP_MODE:
    1563           0 :             return Any(  BitmapMode_NO_REPEAT );
    1564             : 
    1565             :         case OWN_ATTR_STYLE:
    1566             :         {
    1567           0 :             Reference< XStyle > xStyle;
    1568           0 :             return Any( xStyle );
    1569             :         }
    1570             : 
    1571             :         case OWN_ATTR_TABLEBORDER:
    1572             :         {
    1573           0 :             TableBorder aBorder;
    1574           0 :             return Any( aBorder );
    1575             :         }
    1576             : 
    1577             :         default:
    1578             :         {
    1579           0 :             if(  GetModel()->GetItemPool().IsWhich(pMap->nWID) )
    1580             :             {
    1581           0 :                 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
    1582           0 :                 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
    1583           0 :                 return GetAnyForItem( aSet, pMap );
    1584             :             }
    1585             :         }
    1586             :         }
    1587             :     }
    1588           0 :     throw UnknownPropertyException();
    1589             : }
    1590             : 
    1591             : // -----------------------------------------------------------------------------
    1592             : // XMultiPropertyStates
    1593             : // -----------------------------------------------------------------------------
    1594             : 
    1595           0 : void SAL_CALL Cell::setAllPropertiesToDefault(  ) throw (RuntimeException)
    1596             : {
    1597           0 :     delete mpProperties;
    1598           0 :     mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this );
    1599             : 
    1600           0 :     SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner();
    1601             : 
    1602           0 :     OutlinerParaObject* pParaObj = GetOutlinerParaObject();
    1603           0 :     if( pParaObj )
    1604             :     {
    1605           0 :         rOutliner.SetText(*pParaObj);
    1606           0 :         sal_Int32 nParaCount(rOutliner.GetParagraphCount());
    1607             : 
    1608           0 :         if(nParaCount)
    1609             :         {
    1610           0 :             ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL);
    1611           0 :             rOutliner.RemoveAttribs(aSelection, sal_True, 0);
    1612             : 
    1613           0 :             OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount);
    1614           0 :             rOutliner.Clear();
    1615             : 
    1616           0 :             SetOutlinerParaObject(pTemp);
    1617             :         }
    1618             :     }
    1619           0 : }
    1620             : 
    1621             : // -----------------------------------------------------------------------------
    1622             : 
    1623           0 : void SAL_CALL Cell::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, RuntimeException)
    1624             : {
    1625           0 :     sal_Int32 nCount = aPropertyNames.getLength();
    1626           0 :     const OUString* pName = aPropertyNames.getConstArray();
    1627             : 
    1628           0 :     while(nCount--)
    1629           0 :         setPropertyToDefault( *pName++ );
    1630           0 : }
    1631             : 
    1632             : // -----------------------------------------------------------------------------
    1633             : 
    1634           0 : Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
    1635             : {
    1636           0 :     sal_Int32 nCount = aPropertyNames.getLength();
    1637           0 :     Sequence< Any > aDefaults( nCount );
    1638           0 :     Any* pDefaults = aDefaults.getArray();
    1639           0 :     const OUString* pName = aPropertyNames.getConstArray();
    1640             : 
    1641           0 :     while(nCount--)
    1642           0 :         *pDefaults++ = getPropertyDefault( *pName++ );
    1643             : 
    1644           0 :     return aDefaults;
    1645             : }
    1646             : 
    1647             : // -----------------------------------------------------------------------------
    1648             : // XFastPropertySet
    1649             : // -----------------------------------------------------------------------------
    1650             : 
    1651           0 : void SAL_CALL Cell::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
    1652             : {
    1653             :     (void)aValue;
    1654             :     (void)nHandle;
    1655           0 :     throw UnknownPropertyException();
    1656             : }
    1657             : 
    1658             : // -----------------------------------------------------------------------------
    1659             : // TODO: Refactor this method!
    1660           0 : Any SAL_CALL Cell::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
    1661             : {
    1662             :     (void)nHandle;
    1663           0 :     throw UnknownPropertyException();
    1664             : }
    1665             : 
    1666             : // -----------------------------------------------------------------------------
    1667             : // XText
    1668             : // -----------------------------------------------------------------------------
    1669             : 
    1670           0 : void SAL_CALL Cell::insertTextContent( const Reference< XTextRange >& xRange, const Reference< XTextContent >& xContent, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException)
    1671             : {
    1672           0 :     SvxUnoTextBase::insertTextContent( xRange, xContent, bAbsorb );
    1673           0 :     notifyModified();
    1674           0 : }
    1675             : 
    1676             : // -----------------------------------------------------------------------------
    1677             : 
    1678           0 : void SAL_CALL Cell::removeTextContent( const Reference< XTextContent >& xContent ) throw (NoSuchElementException, RuntimeException)
    1679             : {
    1680           0 :     SvxUnoTextBase::removeTextContent( xContent );
    1681           0 :     notifyModified();
    1682           0 : }
    1683             : 
    1684             : // -----------------------------------------------------------------------------
    1685             : // XSimpleText
    1686             : // -----------------------------------------------------------------------------
    1687             : 
    1688           0 : Reference< XTextCursor > SAL_CALL Cell::createTextCursor(  ) throw (RuntimeException)
    1689             : {
    1690           0 :     return SvxUnoTextBase::createTextCursor();
    1691             : }
    1692             : 
    1693             : // -----------------------------------------------------------------------------
    1694             : 
    1695           0 : Reference< XTextCursor > SAL_CALL Cell::createTextCursorByRange( const Reference< XTextRange >& aTextPosition ) throw (RuntimeException)
    1696             : {
    1697           0 :     return SvxUnoTextBase::createTextCursorByRange( aTextPosition );
    1698             : }
    1699             : 
    1700             : // -----------------------------------------------------------------------------
    1701             : 
    1702           0 : void SAL_CALL Cell::insertString( const Reference< XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) throw (RuntimeException)
    1703             : {
    1704           0 :     SvxUnoTextBase::insertString( xRange, aString, bAbsorb );
    1705           0 :     notifyModified();
    1706           0 : }
    1707             : 
    1708             : // -----------------------------------------------------------------------------
    1709             : 
    1710           0 : void SAL_CALL Cell::insertControlCharacter( const Reference< XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException)
    1711             : {
    1712           0 :     SvxUnoTextBase::insertControlCharacter( xRange, nControlCharacter, bAbsorb );
    1713           0 :     notifyModified();
    1714           0 : }
    1715             : 
    1716             : // -----------------------------------------------------------------------------
    1717             : // XTextRange
    1718             : // -----------------------------------------------------------------------------
    1719             : 
    1720           0 : Reference< XText > SAL_CALL Cell::getText(  ) throw (RuntimeException)
    1721             : {
    1722           0 :     return SvxUnoTextBase::getText();
    1723             : }
    1724             : 
    1725             : // -----------------------------------------------------------------------------
    1726             : 
    1727           0 : Reference< XTextRange > SAL_CALL Cell::getStart(  ) throw (RuntimeException)
    1728             : {
    1729           0 :     return SvxUnoTextBase::getStart();
    1730             : }
    1731             : 
    1732             : // -----------------------------------------------------------------------------
    1733             : 
    1734           0 : Reference< XTextRange > SAL_CALL Cell::getEnd(  ) throw (RuntimeException)
    1735             : {
    1736           0 :     return SvxUnoTextBase::getEnd();
    1737             : }
    1738             : 
    1739             : // -----------------------------------------------------------------------------
    1740             : 
    1741           0 : OUString SAL_CALL Cell::getString(  ) throw (RuntimeException)
    1742             : {
    1743           0 :     maSelection.nStartPara = EE_PARA_MAX_COUNT;
    1744           0 :     return SvxUnoTextBase::getString();
    1745             : }
    1746             : 
    1747             : // -----------------------------------------------------------------------------
    1748             : 
    1749           0 : void SAL_CALL Cell::setString( const OUString& aString ) throw (RuntimeException)
    1750             : {
    1751           0 :     SvxUnoTextBase::setString( aString );
    1752           0 :     notifyModified();
    1753           0 : }
    1754             : 
    1755             : // XEventListener
    1756         407 : void SAL_CALL Cell::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
    1757             : {
    1758         407 :     mxTable.clear();
    1759         407 :     dispose();
    1760         407 : }
    1761             : 
    1762           0 : static OUString getCellName( sal_Int32 nCol, sal_Int32 nRow )
    1763             : {
    1764           0 :     OUStringBuffer aBuf;
    1765             : 
    1766           0 :     if (nCol < 26*26)
    1767             :     {
    1768           0 :         if (nCol < 26)
    1769             :             aBuf.append( static_cast<sal_Unicode>( 'A' +
    1770           0 :                         static_cast<sal_uInt16>(nCol)));
    1771             :         else
    1772             :         {
    1773             :             aBuf.append( static_cast<sal_Unicode>( 'A' +
    1774           0 :                         (static_cast<sal_uInt16>(nCol) / 26) - 1));
    1775             :             aBuf.append( static_cast<sal_Unicode>( 'A' +
    1776           0 :                         (static_cast<sal_uInt16>(nCol) % 26)));
    1777             :         }
    1778             :     }
    1779             :     else
    1780             :     {
    1781           0 :         String aStr;
    1782           0 :         while (nCol >= 26)
    1783             :         {
    1784           0 :             sal_Int32 nC = nCol % 26;
    1785           0 :             aStr += static_cast<sal_Unicode>( 'A' +
    1786           0 :                     static_cast<sal_uInt16>(nC));
    1787           0 :             nCol = nCol - nC;
    1788           0 :             nCol = nCol / 26 - 1;
    1789             :         }
    1790           0 :         aStr += static_cast<sal_Unicode>( 'A' +
    1791           0 :                 static_cast<sal_uInt16>(nCol));
    1792           0 :         aBuf.append(comphelper::string::reverseString(aStr));
    1793             :     }
    1794           0 :     aBuf.append( OUString::valueOf(nRow+1) );
    1795           0 :     return aBuf.makeStringAndClear();
    1796             : }
    1797             : 
    1798           0 : OUString Cell::getName()
    1799             : {
    1800             :     // todo: optimize!
    1801           0 :     OUString sName;
    1802           0 :     if( mxTable.is() ) try
    1803             :     {
    1804           0 :         Reference< XCell > xThis( static_cast< XCell* >( this ) );
    1805             : 
    1806           0 :         sal_Int32 nRowCount = mxTable->getRowCount();
    1807           0 :         sal_Int32 nColCount = mxTable->getColumnCount();
    1808           0 :         for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
    1809             :         {
    1810           0 :             for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
    1811             :             {
    1812           0 :                 Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) );
    1813           0 :                 if( xCell == xThis )
    1814             :                 {
    1815           0 :                     return getCellName( nCol, nRow );
    1816             :                 }
    1817           0 :             }
    1818           0 :         }
    1819             :     }
    1820           0 :     catch( Exception& )
    1821             :     {
    1822             :     }
    1823             : 
    1824           0 :     return sName;
    1825             : }
    1826             : 
    1827         258 : } }
    1828             : 
    1829             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10