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 INCLUDED_SVX_SOURCE_TABLE_CELL_HXX
21 #define INCLUDED_SVX_SOURCE_TABLE_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"
38 class OutlinerParaObject
;
41 namespace sdr
{ namespace properties
{
47 namespace sdr
{ namespace table
{
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
, bool bDontRemoveHardAttr
);
78 SVX_DLLPRIVATE
virtual SfxStyleSheet
* GetStyleSheet() const SAL_OVERRIDE
;
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 SAL_OVERRIDE
;
83 SVX_DLLPRIVATE
void SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, 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
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
107 SVX_DLLPRIVATE
virtual void SAL_CALL
acquire() throw () SAL_OVERRIDE
;
108 SVX_DLLPRIVATE
virtual void SAL_CALL
release() throw () SAL_OVERRIDE
;
111 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
112 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< ::sal_Int8
> SAL_CALL
getImplementationId( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 SVX_DLLPRIVATE
virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
116 SVX_DLLPRIVATE
virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
117 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
120 SVX_DLLPRIVATE
virtual ::com::sun::star::awt::Size SAL_CALL
getMinimumSize()
121 throw (::com::sun::star::uno::RuntimeException
,
122 std::exception
) SAL_OVERRIDE
;
123 SVX_DLLPRIVATE
virtual ::com::sun::star::awt::Size SAL_CALL
getPreferredSize()
124 throw (::com::sun::star::uno::RuntimeException
,
125 std::exception
) SAL_OVERRIDE
;
126 SVX_DLLPRIVATE
virtual ::com::sun::star::awt::Size SAL_CALL
calcAdjustedSize( const ::com::sun::star::awt::Size
& aNewSize
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
129 SVX_DLLPRIVATE
virtual ::sal_Int32 SAL_CALL
getRowSpan() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
130 SVX_DLLPRIVATE
virtual ::sal_Int32 SAL_CALL
getColumnSpan() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
131 SVX_DLLPRIVATE
virtual sal_Bool SAL_CALL
isMerged() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
134 SVX_DLLPRIVATE
virtual OUString SAL_CALL
getFormula() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
135 SVX_DLLPRIVATE
virtual void SAL_CALL
setFormula( const OUString
& aFormula
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
136 SVX_DLLPRIVATE
virtual double SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
137 SVX_DLLPRIVATE
virtual void SAL_CALL
setValue( double nValue
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
138 SVX_DLLPRIVATE
virtual ::com::sun::star::table::CellContentType SAL_CALL
getType() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 SVX_DLLPRIVATE
virtual sal_Int32 SAL_CALL
getError() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
141 // ::com::sun::star::beans::XPropertySet
142 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
143 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
, std::exception
) SAL_OVERRIDE
;
144 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
, std::exception
) SAL_OVERRIDE
;
145 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
, std::exception
) SAL_OVERRIDE
;
146 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
, std::exception
) SAL_OVERRIDE
;
147 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
, std::exception
) SAL_OVERRIDE
;
148 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
, std::exception
) SAL_OVERRIDE
;
151 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
, std::exception
) SAL_OVERRIDE
;
152 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
, std::exception
) SAL_OVERRIDE
;
153 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
, std::exception
) SAL_OVERRIDE
;
154 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
, std::exception
) SAL_OVERRIDE
;
155 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
, std::exception
) SAL_OVERRIDE
;
157 // ::com::sun::star::beans::XPropertyState
158 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
, std::exception
) SAL_OVERRIDE
;
159 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
, std::exception
) SAL_OVERRIDE
;
160 SVX_DLLPRIVATE
virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
161 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
, std::exception
) SAL_OVERRIDE
;
163 // XMultiPropertyStates
164 SVX_DLLPRIVATE
virtual void SAL_CALL
setAllPropertiesToDefault()
165 throw (::com::sun::star::uno::RuntimeException
,
166 std::exception
) SAL_OVERRIDE
;
167 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
, std::exception
) SAL_OVERRIDE
;
168 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
, std::exception
) SAL_OVERRIDE
;
171 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
);
172 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
);
175 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
, std::exception
) SAL_OVERRIDE
;
176 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
, std::exception
) SAL_OVERRIDE
;
179 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextCursor
> SAL_CALL
createTextCursor( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
180 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
, std::exception
) SAL_OVERRIDE
;
181 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
, std::exception
) SAL_OVERRIDE
;
182 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
, std::exception
) SAL_OVERRIDE
;
185 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
> SAL_CALL
getText( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
186 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getStart( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
187 SVX_DLLPRIVATE
virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getEnd( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
188 SVX_DLLPRIVATE
virtual OUString SAL_CALL
getString( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
189 SVX_DLLPRIVATE
virtual void SAL_CALL
setString( const OUString
& aString
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
192 SVX_DLLPRIVATE
virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
194 SVX_DLLPRIVATE
virtual void SetOutlinerParaObject( OutlinerParaObject
* pTextObject
) SAL_OVERRIDE
;
196 SVX_DLLPRIVATE
void AddUndo();
198 using SvxUnoTextRangeBase::setPropertyValue
;
199 using SvxUnoTextRangeBase::getPropertyValue
;
201 SVX_DLLPRIVATE
sdr::properties::TextProperties
* CloneProperties( SdrObject
& rNewObj
, Cell
& rNewCell
);
203 SVX_DLLPRIVATE
static sdr::properties::TextProperties
* CloneProperties( sdr::properties::TextProperties
* pProperties
, SdrObject
& rNewObj
, Cell
& rNewCell
);
205 SVX_DLLPRIVATE
void notifyModified();
208 SVX_DLLPRIVATE
virtual const SfxItemSet
& GetObjectItemSet() SAL_OVERRIDE
;
209 SVX_DLLPRIVATE
virtual void SetObjectItem(const SfxPoolItem
& rItem
) SAL_OVERRIDE
;
211 SVX_DLLPRIVATE ::com::sun::star::uno::Any
GetAnyForItem( SfxItemSet
& aSet
, const SfxItemPropertySimpleEntry
* pMap
);
214 SVX_DLLPRIVATE
Cell( SdrTableObj
& rTableObj
, OutlinerParaObject
* pOutlinerParaObject
) throw();
215 SVX_DLLPRIVATE
virtual ~Cell() throw();
217 const SvxItemPropertySet
* mpPropSet
;
219 sdr::properties::TextProperties
* mpProperties
;
221 ::com::sun::star::table::CellContentType mnCellContentType
;
227 ::sal_Int32 mnRowSpan
;
228 ::sal_Int32 mnColSpan
;
230 Rectangle maCellRect
;
232 ::com::sun::star::uno::Reference
< ::com::sun::star::table::XTable
> mxTable
;
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */