1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _SVX_CELL_HXX_
21 #define _SVX_CELL_HXX_
23 #include <com/sun/star/table/XMergeableCell.hpp>
24 #include <com/sun/star/awt/XLayoutConstrains.hpp>
25 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
26 #include <com/sun/star/lang/XEventListener.hpp>
28 #include <rtl/ref.hxx>
29 #include <svl/style.hxx>
30 #include "svx/sdtaitm.hxx"
31 #include "tablemodel.hxx"
32 #include "editeng/unotext.hxx"
33 #include "svx/svdtext.hxx"
35 // -----------------------------------------------------------------------------
38 class OutlinerParaObject
;
41 namespace sdr
{ namespace properties
{
45 // -----------------------------------------------------------------------------
47 namespace sdr
{ namespace table
{
49 // -----------------------------------------------------------------------------
51 class SVX_DLLPUBLIC Cell
: public SdrText
,
52 public SvxUnoTextBase
,
53 public ::com::sun::star::table::XMergeableCell
,
54 public ::com::sun::star::awt::XLayoutConstrains
,
55 public ::com::sun::star::lang::XEventListener
,
56 public ::cppu::OWeakObject
58 friend class CellUndo
;
61 SVX_DLLPRIVATE
static rtl::Reference
< Cell
> create( SdrTableObj
& rTableObj
, OutlinerParaObject
* pOutlinerParaObject
);
64 SVX_DLLPRIVATE
void dispose();
67 bool IsTextEditActive();
68 SVX_DLLPRIVATE
bool hasText() const;
70 SVX_DLLPRIVATE
void cloneFrom( const CellRef
& rCell
);
72 SVX_DLLPRIVATE
void setCellRect( ::Rectangle
& rCellRect
) { maCellRect
= rCellRect
; }
73 SVX_DLLPRIVATE
const ::Rectangle
& getCellRect() const { return maCellRect
; }
74 SVX_DLLPRIVATE ::Rectangle
& getCellRect() { return maCellRect
; }
76 OutlinerParaObject
* GetEditOutlinerParaObject() const;
77 SVX_DLLPRIVATE
void SetStyleSheet( SfxStyleSheet
* pStyleSheet
, sal_Bool bDontRemoveHardAttr
);
78 SVX_DLLPRIVATE
virtual SfxStyleSheet
* GetStyleSheet() const;
79 SVX_DLLPRIVATE
virtual const Rectangle
& GetCurrentBoundRect() const;
80 SVX_DLLPRIVATE
virtual void TakeTextAnchorRect(Rectangle
& rAnchorRect
) const;
82 SVX_DLLPRIVATE
virtual const SfxItemSet
& GetItemSet() const;
83 SVX_DLLPRIVATE
void SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, sal_Bool bClearAllItems
);
84 void SetMergedItem(const SfxPoolItem
& rItem
);
86 SVX_DLLPRIVATE sal_Int32
getMinimumWidth();
87 SVX_DLLPRIVATE sal_Int32
getMinimumHeight();
89 SVX_DLLPRIVATE
long GetTextLeftDistance() const;
90 SVX_DLLPRIVATE
long GetTextRightDistance() const;
91 SVX_DLLPRIVATE
long GetTextUpperDistance() const;
92 SVX_DLLPRIVATE
long GetTextLowerDistance() const;
94 SVX_DLLPRIVATE SdrTextVertAdjust
GetTextVerticalAdjust() const;
95 SdrTextHorzAdjust
GetTextHorizontalAdjust() const;
97 SVX_DLLPRIVATE
virtual void SetModel(SdrModel
* pNewModel
);
99 SVX_DLLPRIVATE
void merge( sal_Int32 nColumnSpan
, sal_Int32 nRowSpan
);
100 SVX_DLLPRIVATE
void mergeContent( const CellRef
& xSourceCell
);
101 SVX_DLLPRIVATE
void replaceContentAndFormating( const CellRef
& xSourceCell
);
103 SVX_DLLPRIVATE
void setMerged();
106 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& Type
) throw (::com::sun::star::uno::RuntimeException
);
107 SVX_DLLPRIVATE
virtual void SAL_CALL
acquire() throw ();
108 SVX_DLLPRIVATE
virtual void SAL_CALL
release() throw ();
111 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw (::com::sun::star::uno::RuntimeException
);
112 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< ::sal_Int8
> SAL_CALL
getImplementationId( ) throw (::com::sun::star::uno::RuntimeException
);
115 SVX_DLLPRIVATE
virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
);
116 SVX_DLLPRIVATE
virtual ::sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
);
117 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
);
120 SVX_DLLPRIVATE
virtual ::com::sun::star::awt::Size SAL_CALL
getMinimumSize( ) throw (::com::sun::star::uno::RuntimeException
);
121 SVX_DLLPRIVATE
virtual ::com::sun::star::awt::Size SAL_CALL
getPreferredSize( ) throw (::com::sun::star::uno::RuntimeException
);
122 SVX_DLLPRIVATE
virtual ::com::sun::star::awt::Size SAL_CALL
calcAdjustedSize( const ::com::sun::star::awt::Size
& aNewSize
) throw (::com::sun::star::uno::RuntimeException
);
125 SVX_DLLPRIVATE
virtual ::sal_Int32 SAL_CALL
getRowSpan() throw (::com::sun::star::uno::RuntimeException
);
126 SVX_DLLPRIVATE
virtual ::sal_Int32 SAL_CALL
getColumnSpan() throw (::com::sun::star::uno::RuntimeException
);
127 SVX_DLLPRIVATE
virtual ::sal_Bool SAL_CALL
isMerged() throw (::com::sun::star::uno::RuntimeException
);
130 SVX_DLLPRIVATE
virtual OUString SAL_CALL
getFormula() throw (::com::sun::star::uno::RuntimeException
);
131 SVX_DLLPRIVATE
virtual void SAL_CALL
setFormula( const OUString
& aFormula
) throw (::com::sun::star::uno::RuntimeException
);
132 SVX_DLLPRIVATE
virtual double SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
133 SVX_DLLPRIVATE
virtual void SAL_CALL
setValue( double nValue
) throw (::com::sun::star::uno::RuntimeException
);
134 SVX_DLLPRIVATE
virtual ::com::sun::star::table::CellContentType SAL_CALL
getType() throw (::com::sun::star::uno::RuntimeException
);
135 SVX_DLLPRIVATE
virtual sal_Int32 SAL_CALL
getError() throw (::com::sun::star::uno::RuntimeException
);
137 // ::com::sun::star::beans::XPropertySet
138 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException
);
139 SVX_DLLPRIVATE
virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
140 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
141 SVX_DLLPRIVATE
virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
142 SVX_DLLPRIVATE
virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
143 SVX_DLLPRIVATE
virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
144 SVX_DLLPRIVATE
virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
147 SVX_DLLPRIVATE
virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aValues
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
148 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
getPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
) throw (::com::sun::star::uno::RuntimeException
);
149 SVX_DLLPRIVATE
virtual void SAL_CALL
addPropertiesChangeListener( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
150 SVX_DLLPRIVATE
virtual void SAL_CALL
removePropertiesChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
151 SVX_DLLPRIVATE
virtual void SAL_CALL
firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
153 // ::com::sun::star::beans::XPropertyState
154 SVX_DLLPRIVATE
virtual ::com::sun::star::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
155 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyState
> SAL_CALL
getPropertyStates( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
156 SVX_DLLPRIVATE
virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
157 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
159 // XMultiPropertyStates
160 SVX_DLLPRIVATE
virtual void SAL_CALL
setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException
);
161 SVX_DLLPRIVATE
virtual void SAL_CALL
setPropertiesToDefault( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
162 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
getPropertyDefaults( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
165 SVX_DLLPRIVATE
virtual void SAL_CALL
setFastPropertyValue( ::sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& aValue
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
166 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Any SAL_CALL
getFastPropertyValue( ::sal_Int32 nHandle
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
169 SVX_DLLPRIVATE
virtual void SAL_CALL
insertTextContent( const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>& xRange
, const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextContent
>& xContent
, ::sal_Bool bAbsorb
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
170 SVX_DLLPRIVATE
virtual void SAL_CALL
removeTextContent( const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextContent
>& xContent
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::uno::RuntimeException
);
173 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextCursor
> SAL_CALL
createTextCursor( ) throw (::com::sun::star::uno::RuntimeException
);
174 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextCursor
> SAL_CALL
createTextCursorByRange( const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>& aTextPosition
) throw (::com::sun::star::uno::RuntimeException
);
175 SVX_DLLPRIVATE
virtual void SAL_CALL
insertString( const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>& xRange
, const OUString
& aString
, ::sal_Bool bAbsorb
) throw (::com::sun::star::uno::RuntimeException
);
176 SVX_DLLPRIVATE
virtual void SAL_CALL
insertControlCharacter( const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>& xRange
, ::sal_Int16 nControlCharacter
, ::sal_Bool bAbsorb
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
179 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
> SAL_CALL
getText( ) throw (::com::sun::star::uno::RuntimeException
);
180 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getStart( ) throw (::com::sun::star::uno::RuntimeException
);
181 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getEnd( ) throw (::com::sun::star::uno::RuntimeException
);
182 SVX_DLLPRIVATE
virtual OUString SAL_CALL
getString( ) throw (::com::sun::star::uno::RuntimeException
);
183 SVX_DLLPRIVATE
virtual void SAL_CALL
setString( const OUString
& aString
) throw (::com::sun::star::uno::RuntimeException
);
186 SVX_DLLPRIVATE
virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
188 SVX_DLLPRIVATE
virtual void SetOutlinerParaObject( OutlinerParaObject
* pTextObject
);
190 SVX_DLLPRIVATE
void AddUndo();
192 using SvxUnoTextRangeBase::setPropertyValue
;
193 using SvxUnoTextRangeBase::getPropertyValue
;
195 SVX_DLLPRIVATE
sdr::properties::TextProperties
* CloneProperties( SdrObject
& rNewObj
, Cell
& rNewCell
);
197 SVX_DLLPRIVATE
static sdr::properties::TextProperties
* CloneProperties( sdr::properties::TextProperties
* pProperties
, SdrObject
& rNewObj
, Cell
& rNewCell
);
199 SVX_DLLPRIVATE
void notifyModified();
204 SVX_DLLPRIVATE
virtual const SfxItemSet
& GetObjectItemSet();
205 SVX_DLLPRIVATE
virtual void SetObjectItem(const SfxPoolItem
& rItem
);
207 SVX_DLLPRIVATE ::com::sun::star::uno::Any
GetAnyForItem( SfxItemSet
& aSet
, const SfxItemPropertySimpleEntry
* pMap
);
210 SVX_DLLPRIVATE
Cell( SdrTableObj
& rTableObj
, OutlinerParaObject
* pOutlinerParaObject
) throw();
211 SVX_DLLPRIVATE
virtual ~Cell() throw();
213 const SvxItemPropertySet
* mpPropSet
;
215 sdr::properties::TextProperties
* mpProperties
;
217 ::com::sun::star::table::CellContentType mnCellContentType
;
223 ::sal_Int32 mnRowSpan
;
224 ::sal_Int32 mnColSpan
;
226 Rectangle maCellRect
;
228 ::com::sun::star::uno::Reference
< ::com::sun::star::table::XTable
> mxTable
;
231 // -----------------------------------------------------------------------------
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */