1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "scitems.hxx"
28cdf0e10cSrcweir #include <editeng/eeitem.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <memory>
32cdf0e10cSrcweir #include "AccessibleText.hxx"
33cdf0e10cSrcweir #include "AccessibleCell.hxx"
34cdf0e10cSrcweir #include "tabvwsh.hxx"
35cdf0e10cSrcweir #include "editutil.hxx"
36cdf0e10cSrcweir #include "document.hxx"
37cdf0e10cSrcweir #include "scmod.hxx"
38cdf0e10cSrcweir #include "prevwsh.hxx"
39cdf0e10cSrcweir #include "docsh.hxx"
40cdf0e10cSrcweir #include "prevloc.hxx"
41cdf0e10cSrcweir #include "unoguard.hxx"
42cdf0e10cSrcweir #include "patattr.hxx"
43cdf0e10cSrcweir #include "inputwin.hxx"
44cdf0e10cSrcweir #include <editeng/unofored.hxx>
45cdf0e10cSrcweir #include <editeng/editview.hxx>
46cdf0e10cSrcweir #include <editeng/unoedhlp.hxx>
47cdf0e10cSrcweir #include <vcl/virdev.hxx>
48cdf0e10cSrcweir #include <editeng/editobj.hxx>
49cdf0e10cSrcweir #include <editeng/adjitem.hxx>
50cdf0e10cSrcweir #include <svx/svdmodel.hxx>
51cdf0e10cSrcweir #include <svx/algitem.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // ============================================================================
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class ScViewForwarder : public SvxViewForwarder
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	ScTabViewShell*		mpViewShell;
59cdf0e10cSrcweir 	ScAddress			maCellPos;
60cdf0e10cSrcweir 	ScSplitPos			meSplitPos;
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir 						ScViewForwarder(ScTabViewShell* pViewShell, ScSplitPos eSplitPos, const ScAddress& rCell);
63cdf0e10cSrcweir 	virtual				~ScViewForwarder();
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	virtual sal_Bool		IsValid() const;
66cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
67cdf0e10cSrcweir     virtual Point		LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
68cdf0e10cSrcweir     virtual Point		PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     void                SetInvalid();
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
ScViewForwarder(ScTabViewShell * pViewShell,ScSplitPos eSplitPos,const ScAddress & rCell)73cdf0e10cSrcweir ScViewForwarder::ScViewForwarder(ScTabViewShell* pViewShell, ScSplitPos eSplitPos, const ScAddress& rCell)
74cdf0e10cSrcweir 	:
75cdf0e10cSrcweir 	mpViewShell(pViewShell),
76cdf0e10cSrcweir 	maCellPos(rCell),
77cdf0e10cSrcweir 	meSplitPos(eSplitPos)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
~ScViewForwarder()81cdf0e10cSrcweir ScViewForwarder::~ScViewForwarder()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
IsValid() const85cdf0e10cSrcweir sal_Bool ScViewForwarder::IsValid() const
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	return mpViewShell != NULL;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
GetVisArea() const90cdf0e10cSrcweir Rectangle ScViewForwarder::GetVisArea() const
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	Rectangle aVisArea;
93cdf0e10cSrcweir 	if (mpViewShell)
94cdf0e10cSrcweir 	{
95cdf0e10cSrcweir 		Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
96cdf0e10cSrcweir 		if (pWindow)
97cdf0e10cSrcweir 		{
98cdf0e10cSrcweir 			aVisArea.SetSize(pWindow->GetSizePixel());
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 			ScHSplitPos eWhichH = ((meSplitPos == SC_SPLIT_TOPLEFT) || (meSplitPos == SC_SPLIT_BOTTOMLEFT)) ?
101cdf0e10cSrcweir 									SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
102cdf0e10cSrcweir 			ScVSplitPos eWhichV = ((meSplitPos == SC_SPLIT_TOPLEFT) || (meSplitPos == SC_SPLIT_TOPRIGHT)) ?
103cdf0e10cSrcweir 									SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 			Point aBaseCellPos(mpViewShell->GetViewData()->GetScrPos(mpViewShell->GetViewData()->GetPosX(eWhichH),
106cdf0e10cSrcweir 				mpViewShell->GetViewData()->GetPosY(eWhichV), meSplitPos, sal_True));
107cdf0e10cSrcweir 			Point aCellPos(mpViewShell->GetViewData()->GetScrPos(maCellPos.Col(), maCellPos.Row(), meSplitPos, sal_True));
108cdf0e10cSrcweir 			aVisArea.SetPos(aCellPos - aBaseCellPos);
109cdf0e10cSrcweir 		}
110cdf0e10cSrcweir 	}
111cdf0e10cSrcweir 	else
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
114cdf0e10cSrcweir 	}
115cdf0e10cSrcweir 	return aVisArea;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
LogicToPixel(const Point & rPoint,const MapMode & rMapMode) const118cdf0e10cSrcweir Point ScViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	if (mpViewShell)
121cdf0e10cSrcweir 	{
122cdf0e10cSrcweir 		Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
123cdf0e10cSrcweir 		if (pWindow)
124cdf0e10cSrcweir 			return pWindow->LogicToPixel( rPoint, rMapMode );
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 	else
127cdf0e10cSrcweir 	{
128cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
129cdf0e10cSrcweir 	}
130cdf0e10cSrcweir 	return Point();
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
PixelToLogic(const Point & rPoint,const MapMode & rMapMode) const133cdf0e10cSrcweir Point ScViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	if (mpViewShell)
136cdf0e10cSrcweir 	{
137cdf0e10cSrcweir 		Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
138cdf0e10cSrcweir 		if (pWindow)
139cdf0e10cSrcweir 			return pWindow->PixelToLogic( rPoint, rMapMode );
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	else
142cdf0e10cSrcweir 	{
143cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
144cdf0e10cSrcweir 	}
145cdf0e10cSrcweir 	return Point();
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
SetInvalid()148cdf0e10cSrcweir void ScViewForwarder::SetInvalid()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     mpViewShell = NULL;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir // ============================================================================
154cdf0e10cSrcweir 
155cdf0e10cSrcweir class ScEditObjectViewForwarder : public SvxViewForwarder
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     Window*             mpWindow;
158cdf0e10cSrcweir     // --> OD 2005-12-21 #i49561#
159cdf0e10cSrcweir     // - EditView needed for access to its visible area.
160cdf0e10cSrcweir     const EditView* mpEditView;
161cdf0e10cSrcweir     // <--
162cdf0e10cSrcweir public:
163cdf0e10cSrcweir                         // --> OD 2005-12-21 #i49561#
164cdf0e10cSrcweir                         ScEditObjectViewForwarder( Window* pWindow,
165cdf0e10cSrcweir                                                    const EditView* _pEditView);
166cdf0e10cSrcweir                         // <--
167cdf0e10cSrcweir 	virtual				~ScEditObjectViewForwarder();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	virtual sal_Bool		IsValid() const;
170cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
171cdf0e10cSrcweir     virtual Point		LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
172cdf0e10cSrcweir     virtual Point		PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     void                SetInvalid();
175cdf0e10cSrcweir };
176cdf0e10cSrcweir 
177cdf0e10cSrcweir // --> OD 2005-12-21 #i49561#
ScEditObjectViewForwarder(Window * pWindow,const EditView * _pEditView)178cdf0e10cSrcweir ScEditObjectViewForwarder::ScEditObjectViewForwarder( Window* pWindow,
179cdf0e10cSrcweir                                                       const EditView* _pEditView )
180cdf0e10cSrcweir 	:
181cdf0e10cSrcweir     mpWindow(pWindow),
182cdf0e10cSrcweir     mpEditView( _pEditView )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir }
185cdf0e10cSrcweir // <--
186cdf0e10cSrcweir 
~ScEditObjectViewForwarder()187cdf0e10cSrcweir ScEditObjectViewForwarder::~ScEditObjectViewForwarder()
188cdf0e10cSrcweir {
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
IsValid() const191cdf0e10cSrcweir sal_Bool ScEditObjectViewForwarder::IsValid() const
192cdf0e10cSrcweir {
193cdf0e10cSrcweir 	return (mpWindow != NULL);
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
GetVisArea() const196cdf0e10cSrcweir Rectangle ScEditObjectViewForwarder::GetVisArea() const
197cdf0e10cSrcweir {
198cdf0e10cSrcweir 	Rectangle aVisArea;
199cdf0e10cSrcweir 	if (mpWindow)
200cdf0e10cSrcweir 	{
201cdf0e10cSrcweir         Rectangle aVisRect(mpWindow->GetWindowExtentsRelative(mpWindow->GetAccessibleParentWindow()));
202cdf0e10cSrcweir 
203cdf0e10cSrcweir         aVisRect.SetPos(Point(0, 0));
204cdf0e10cSrcweir 
205cdf0e10cSrcweir         aVisArea = aVisRect;
206cdf0e10cSrcweir 	}
207cdf0e10cSrcweir 	else
208cdf0e10cSrcweir 	{
209cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
210cdf0e10cSrcweir 	}
211cdf0e10cSrcweir 	return aVisArea;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
LogicToPixel(const Point & rPoint,const MapMode & rMapMode) const214cdf0e10cSrcweir Point ScEditObjectViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     if (mpWindow)
217cdf0e10cSrcweir     {
218cdf0e10cSrcweir         // --> OD 2005-12-21 #i49561# - consider offset of the visible area
219cdf0e10cSrcweir         // of the EditView before converting point to pixel.
220cdf0e10cSrcweir         Point aPoint( rPoint );
221cdf0e10cSrcweir         if ( mpEditView )
222cdf0e10cSrcweir         {
223cdf0e10cSrcweir             Rectangle aEditViewVisArea( mpEditView->GetVisArea() );
224cdf0e10cSrcweir             aPoint += aEditViewVisArea.TopLeft();
225cdf0e10cSrcweir         }
226cdf0e10cSrcweir         return mpWindow->LogicToPixel( aPoint, rMapMode );
227cdf0e10cSrcweir         // <--
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir 	else
230cdf0e10cSrcweir 	{
231cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 	return Point();
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
PixelToLogic(const Point & rPoint,const MapMode & rMapMode) const236cdf0e10cSrcweir Point ScEditObjectViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
237cdf0e10cSrcweir {
238cdf0e10cSrcweir 	if (mpWindow)
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         // --> OD 2005-12-21 #i49561# - consider offset of the visible area
241cdf0e10cSrcweir         // of the EditView after converting point to logic.
242cdf0e10cSrcweir         Point aPoint( mpWindow->PixelToLogic( rPoint, rMapMode ) );
243cdf0e10cSrcweir         if ( mpEditView )
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir             Rectangle aEditViewVisArea( mpEditView->GetVisArea() );
246cdf0e10cSrcweir             aPoint -= aEditViewVisArea.TopLeft();
247cdf0e10cSrcweir         }
248cdf0e10cSrcweir         return aPoint;
249cdf0e10cSrcweir         // <--
250cdf0e10cSrcweir     }
251cdf0e10cSrcweir 	else
252cdf0e10cSrcweir 	{
253cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 	return Point();
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
SetInvalid()258cdf0e10cSrcweir void ScEditObjectViewForwarder::SetInvalid()
259cdf0e10cSrcweir {
260cdf0e10cSrcweir     mpWindow = NULL;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir // ============================================================================
264cdf0e10cSrcweir 
265cdf0e10cSrcweir class ScPreviewViewForwarder : public SvxViewForwarder
266cdf0e10cSrcweir {
267cdf0e10cSrcweir protected:
268cdf0e10cSrcweir 	ScPreviewShell*		mpViewShell;
269cdf0e10cSrcweir 	mutable ScPreviewTableInfo*	mpTableInfo;
270cdf0e10cSrcweir public:
271cdf0e10cSrcweir 						ScPreviewViewForwarder(ScPreviewShell* pViewShell);
272cdf0e10cSrcweir 	virtual				~ScPreviewViewForwarder();
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 	virtual sal_Bool		IsValid() const;
275cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
276cdf0e10cSrcweir     virtual Point		LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
277cdf0e10cSrcweir     virtual Point		PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     void                SetInvalid();
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     Rectangle GetVisRect() const;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     // clips the VisArea and calculates with the negativ coordinates
284cdf0e10cSrcweir     Rectangle CorrectVisArea(const Rectangle& rVisArea) const;
285cdf0e10cSrcweir };
286cdf0e10cSrcweir 
ScPreviewViewForwarder(ScPreviewShell * pViewShell)287cdf0e10cSrcweir ScPreviewViewForwarder::ScPreviewViewForwarder(ScPreviewShell* pViewShell)
288cdf0e10cSrcweir 	:
289cdf0e10cSrcweir 	mpViewShell(pViewShell),
290cdf0e10cSrcweir 	mpTableInfo(NULL)
291cdf0e10cSrcweir {
292cdf0e10cSrcweir }
293cdf0e10cSrcweir 
~ScPreviewViewForwarder()294cdf0e10cSrcweir ScPreviewViewForwarder::~ScPreviewViewForwarder()
295cdf0e10cSrcweir {
296cdf0e10cSrcweir 	delete mpTableInfo;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
IsValid() const299cdf0e10cSrcweir sal_Bool ScPreviewViewForwarder::IsValid() const
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	return mpViewShell != NULL;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
GetVisArea() const304cdf0e10cSrcweir Rectangle ScPreviewViewForwarder::GetVisArea() const
305cdf0e10cSrcweir {
306cdf0e10cSrcweir 	Rectangle aVisArea;
307cdf0e10cSrcweir 	DBG_ERROR("should be implemented in an abrevated class");
308cdf0e10cSrcweir 	return aVisArea;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
LogicToPixel(const Point & rPoint,const MapMode & rMapMode) const311cdf0e10cSrcweir Point ScPreviewViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	if (mpViewShell)
314cdf0e10cSrcweir 	{
315cdf0e10cSrcweir 		Window* pWindow = mpViewShell->GetWindow();
316cdf0e10cSrcweir 		if (pWindow)
317cdf0e10cSrcweir         {
318cdf0e10cSrcweir             MapMode aMapMode(pWindow->GetMapMode().GetMapUnit());
319cdf0e10cSrcweir             Point aPoint2( OutputDevice::LogicToLogic( rPoint, rMapMode, aMapMode) );
320cdf0e10cSrcweir             return pWindow->LogicToPixel(aPoint2);
321cdf0e10cSrcweir         }
322cdf0e10cSrcweir 	}
323cdf0e10cSrcweir 	else
324cdf0e10cSrcweir 	{
325cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
326cdf0e10cSrcweir 	}
327cdf0e10cSrcweir 	return Point();
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
PixelToLogic(const Point & rPoint,const MapMode & rMapMode) const330cdf0e10cSrcweir Point ScPreviewViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
331cdf0e10cSrcweir {
332cdf0e10cSrcweir 	if (mpViewShell)
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 		Window* pWindow = mpViewShell->GetWindow();
335cdf0e10cSrcweir 		if (pWindow)
336cdf0e10cSrcweir         {
337cdf0e10cSrcweir             MapMode aMapMode(pWindow->GetMapMode());
338cdf0e10cSrcweir             aMapMode.SetOrigin(Point());
339cdf0e10cSrcweir             Point aPoint1( pWindow->PixelToLogic( rPoint ) );
340cdf0e10cSrcweir             Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
341cdf0e10cSrcweir                                                        aMapMode.GetMapUnit(),
342cdf0e10cSrcweir                                                        rMapMode ) );
343cdf0e10cSrcweir             return aPoint2;
344cdf0e10cSrcweir         }
345cdf0e10cSrcweir 	}
346cdf0e10cSrcweir 	else
347cdf0e10cSrcweir 	{
348cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir 	return Point();
351cdf0e10cSrcweir }
352cdf0e10cSrcweir 
SetInvalid()353cdf0e10cSrcweir void ScPreviewViewForwarder::SetInvalid()
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     mpViewShell = NULL;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
GetVisRect() const358cdf0e10cSrcweir Rectangle ScPreviewViewForwarder::GetVisRect() const
359cdf0e10cSrcweir {
360cdf0e10cSrcweir 	if ( mpViewShell )
361cdf0e10cSrcweir 	{
362cdf0e10cSrcweir 		Size aOutputSize;
363cdf0e10cSrcweir 		Window* pWindow = mpViewShell->GetWindow();
364cdf0e10cSrcweir 		if ( pWindow )
365cdf0e10cSrcweir 			aOutputSize = pWindow->GetOutputSizePixel();
366cdf0e10cSrcweir         Point aPoint;
367cdf0e10cSrcweir 		Rectangle aVisRect( aPoint, aOutputSize );
368cdf0e10cSrcweir         return aVisRect;
369cdf0e10cSrcweir     }
370cdf0e10cSrcweir     return Rectangle();
371cdf0e10cSrcweir }
372cdf0e10cSrcweir 
CorrectVisArea(const Rectangle & rVisArea) const373cdf0e10cSrcweir Rectangle ScPreviewViewForwarder::CorrectVisArea(const Rectangle& rVisArea) const
374cdf0e10cSrcweir {
375cdf0e10cSrcweir     Rectangle aVisArea(rVisArea);
376cdf0e10cSrcweir     Point aPos = aVisArea.TopLeft(); // get first the position to remember negative positions after clipping
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     Window* pWin = mpViewShell->GetWindow();
379cdf0e10cSrcweir     if (pWin)
380cdf0e10cSrcweir         aVisArea = pWin->GetWindowExtentsRelative(pWin).GetIntersection(aVisArea);
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     sal_Int32 nX(aPos.getX());
383cdf0e10cSrcweir     sal_Int32 nY(aPos.getY());
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     if (nX > 0)
386cdf0e10cSrcweir         nX = 0;
387cdf0e10cSrcweir     else if (nX < 0)
388cdf0e10cSrcweir         nX = -nX;
389cdf0e10cSrcweir     if (nY > 0)
390cdf0e10cSrcweir         nY = 0;
391cdf0e10cSrcweir     else if (nY < 0)
392cdf0e10cSrcweir         nY = -nY;
393cdf0e10cSrcweir     aVisArea.SetPos(Point(nX, nY));
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     return aVisArea;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir 
398cdf0e10cSrcweir // ============================================================================
399cdf0e10cSrcweir 
400cdf0e10cSrcweir class ScPreviewHeaderFooterViewForwarder : public ScPreviewViewForwarder
401cdf0e10cSrcweir {
402cdf0e10cSrcweir     sal_Bool            mbHeader;
403cdf0e10cSrcweir public:
404cdf0e10cSrcweir 						ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, sal_Bool bHeader);
405cdf0e10cSrcweir 	virtual				~ScPreviewHeaderFooterViewForwarder();
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
408cdf0e10cSrcweir };
409cdf0e10cSrcweir 
ScPreviewHeaderFooterViewForwarder(ScPreviewShell * pViewShell,sal_Bool bHeader)410cdf0e10cSrcweir ScPreviewHeaderFooterViewForwarder::ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, sal_Bool bHeader)
411cdf0e10cSrcweir 	:
412cdf0e10cSrcweir 	ScPreviewViewForwarder(pViewShell),
413cdf0e10cSrcweir     mbHeader(bHeader)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
~ScPreviewHeaderFooterViewForwarder()417cdf0e10cSrcweir ScPreviewHeaderFooterViewForwarder::~ScPreviewHeaderFooterViewForwarder()
418cdf0e10cSrcweir {
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
GetVisArea() const421cdf0e10cSrcweir Rectangle ScPreviewHeaderFooterViewForwarder::GetVisArea() const
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	Rectangle aVisArea;
424cdf0e10cSrcweir 	if (mpViewShell)
425cdf0e10cSrcweir 	{
426cdf0e10cSrcweir 		const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
427cdf0e10cSrcweir 		if ( mbHeader )
428cdf0e10cSrcweir 			rData.GetHeaderPosition( aVisArea );
429cdf0e10cSrcweir 		else
430cdf0e10cSrcweir 			rData.GetFooterPosition( aVisArea );
431cdf0e10cSrcweir 
432cdf0e10cSrcweir         aVisArea = CorrectVisArea(aVisArea);
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 	else
435cdf0e10cSrcweir 	{
436cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
437cdf0e10cSrcweir 	}
438cdf0e10cSrcweir 	return aVisArea;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir // ============================================================================
442cdf0e10cSrcweir 
443cdf0e10cSrcweir class ScPreviewCellViewForwarder : public ScPreviewViewForwarder
444cdf0e10cSrcweir {
445cdf0e10cSrcweir     ScAddress           maCellPos;
446cdf0e10cSrcweir public:
447cdf0e10cSrcweir 						ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
448cdf0e10cSrcweir                             ScAddress aCellPos);
449cdf0e10cSrcweir 	virtual				~ScPreviewCellViewForwarder();
450cdf0e10cSrcweir 
451cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
452cdf0e10cSrcweir };
453cdf0e10cSrcweir 
ScPreviewCellViewForwarder(ScPreviewShell * pViewShell,ScAddress aCellPos)454cdf0e10cSrcweir ScPreviewCellViewForwarder::ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
455cdf0e10cSrcweir                                                        ScAddress aCellPos)
456cdf0e10cSrcweir 	:
457cdf0e10cSrcweir 	ScPreviewViewForwarder(pViewShell),
458cdf0e10cSrcweir     maCellPos(aCellPos)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
~ScPreviewCellViewForwarder()462cdf0e10cSrcweir ScPreviewCellViewForwarder::~ScPreviewCellViewForwarder()
463cdf0e10cSrcweir {
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
GetVisArea() const466cdf0e10cSrcweir Rectangle ScPreviewCellViewForwarder::GetVisArea() const
467cdf0e10cSrcweir {
468cdf0e10cSrcweir 	Rectangle aVisArea;
469cdf0e10cSrcweir 	if (mpViewShell)
470cdf0e10cSrcweir 	{
471cdf0e10cSrcweir 		const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
472cdf0e10cSrcweir         aVisArea = rData.GetCellOutputRect(maCellPos);
473cdf0e10cSrcweir 
474cdf0e10cSrcweir         aVisArea = CorrectVisArea(aVisArea);
475cdf0e10cSrcweir 	}
476cdf0e10cSrcweir 	else
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
479cdf0e10cSrcweir 	}
480cdf0e10cSrcweir 	return aVisArea;
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir // ============================================================================
484cdf0e10cSrcweir 
485cdf0e10cSrcweir class ScPreviewHeaderCellViewForwarder : public ScPreviewViewForwarder
486cdf0e10cSrcweir {
487cdf0e10cSrcweir     ScAddress           maCellPos;
488cdf0e10cSrcweir     sal_Bool            mbColHeader;
489cdf0e10cSrcweir     sal_Bool            mbRowHeader;
490cdf0e10cSrcweir public:
491cdf0e10cSrcweir 						ScPreviewHeaderCellViewForwarder(ScPreviewShell* pViewShell,
492cdf0e10cSrcweir                             ScAddress aCellPos,
493cdf0e10cSrcweir                             sal_Bool bColHeader, sal_Bool bRowHeader);
494cdf0e10cSrcweir 	virtual				~ScPreviewHeaderCellViewForwarder();
495cdf0e10cSrcweir 
496cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
497cdf0e10cSrcweir };
498cdf0e10cSrcweir 
ScPreviewHeaderCellViewForwarder(ScPreviewShell * pViewShell,ScAddress aCellPos,sal_Bool bColHeader,sal_Bool bRowHeader)499cdf0e10cSrcweir ScPreviewHeaderCellViewForwarder::ScPreviewHeaderCellViewForwarder(ScPreviewShell* pViewShell,
500cdf0e10cSrcweir                                                                    ScAddress aCellPos,
501cdf0e10cSrcweir                                                                    sal_Bool bColHeader, sal_Bool bRowHeader)
502cdf0e10cSrcweir 	:
503cdf0e10cSrcweir 	ScPreviewViewForwarder(pViewShell),
504cdf0e10cSrcweir     maCellPos(aCellPos),
505cdf0e10cSrcweir     mbColHeader(bColHeader),
506cdf0e10cSrcweir     mbRowHeader(bRowHeader)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir }
509cdf0e10cSrcweir 
~ScPreviewHeaderCellViewForwarder()510cdf0e10cSrcweir ScPreviewHeaderCellViewForwarder::~ScPreviewHeaderCellViewForwarder()
511cdf0e10cSrcweir {
512cdf0e10cSrcweir }
513cdf0e10cSrcweir 
GetVisArea() const514cdf0e10cSrcweir Rectangle ScPreviewHeaderCellViewForwarder::GetVisArea() const
515cdf0e10cSrcweir {
516cdf0e10cSrcweir 	Rectangle aVisArea;
517cdf0e10cSrcweir 	if (mpViewShell)
518cdf0e10cSrcweir 	{
519cdf0e10cSrcweir 		const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
520cdf0e10cSrcweir         aVisArea = rData.GetHeaderCellOutputRect(GetVisRect(), maCellPos, mbColHeader);
521cdf0e10cSrcweir 
522cdf0e10cSrcweir         aVisArea = CorrectVisArea(aVisArea);
523cdf0e10cSrcweir     }
524cdf0e10cSrcweir 	else
525cdf0e10cSrcweir 	{
526cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
527cdf0e10cSrcweir 	}
528cdf0e10cSrcweir 	return aVisArea;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
531cdf0e10cSrcweir // ============================================================================
532cdf0e10cSrcweir 
533cdf0e10cSrcweir class ScPreviewNoteViewForwarder : public ScPreviewViewForwarder
534cdf0e10cSrcweir {
535cdf0e10cSrcweir     ScAddress           maCellPos;
536cdf0e10cSrcweir     sal_Bool            mbNoteMark;
537cdf0e10cSrcweir public:
538cdf0e10cSrcweir 						ScPreviewNoteViewForwarder(ScPreviewShell* pViewShell,
539cdf0e10cSrcweir                             ScAddress aCellPos,
540cdf0e10cSrcweir                             sal_Bool bNoteMark);
541cdf0e10cSrcweir 	virtual				~ScPreviewNoteViewForwarder();
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
544cdf0e10cSrcweir };
545cdf0e10cSrcweir 
ScPreviewNoteViewForwarder(ScPreviewShell * pViewShell,ScAddress aCellPos,sal_Bool bNoteMark)546cdf0e10cSrcweir ScPreviewNoteViewForwarder::ScPreviewNoteViewForwarder(ScPreviewShell* pViewShell,
547cdf0e10cSrcweir                                                                    ScAddress aCellPos,
548cdf0e10cSrcweir                                                                    sal_Bool bNoteMark)
549cdf0e10cSrcweir 	:
550cdf0e10cSrcweir 	ScPreviewViewForwarder(pViewShell),
551cdf0e10cSrcweir     maCellPos(aCellPos),
552cdf0e10cSrcweir     mbNoteMark(bNoteMark)
553cdf0e10cSrcweir {
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
~ScPreviewNoteViewForwarder()556cdf0e10cSrcweir ScPreviewNoteViewForwarder::~ScPreviewNoteViewForwarder()
557cdf0e10cSrcweir {
558cdf0e10cSrcweir }
559cdf0e10cSrcweir 
GetVisArea() const560cdf0e10cSrcweir Rectangle ScPreviewNoteViewForwarder::GetVisArea() const
561cdf0e10cSrcweir {
562cdf0e10cSrcweir 	Rectangle aVisArea;
563cdf0e10cSrcweir 	if (mpViewShell)
564cdf0e10cSrcweir 	{
565cdf0e10cSrcweir 		const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
566cdf0e10cSrcweir         aVisArea = rData.GetNoteInRangeOutputRect(GetVisRect(), mbNoteMark, maCellPos);
567cdf0e10cSrcweir 
568cdf0e10cSrcweir         aVisArea = CorrectVisArea(aVisArea);
569cdf0e10cSrcweir     }
570cdf0e10cSrcweir 	else
571cdf0e10cSrcweir 	{
572cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
573cdf0e10cSrcweir 	}
574cdf0e10cSrcweir 	return aVisArea;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir // ============================================================================
578cdf0e10cSrcweir 
579cdf0e10cSrcweir class ScEditViewForwarder : public SvxEditViewForwarder
580cdf0e10cSrcweir {
581cdf0e10cSrcweir     EditView*           mpEditView;
582cdf0e10cSrcweir     Window*             mpWindow;
583cdf0e10cSrcweir public:
584cdf0e10cSrcweir 						ScEditViewForwarder(EditView* pEditView, Window* pWin);
585cdf0e10cSrcweir 	virtual				~ScEditViewForwarder();
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 	virtual sal_Bool		IsValid() const;
588cdf0e10cSrcweir     virtual Rectangle	GetVisArea() const;
589cdf0e10cSrcweir     virtual Point		LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
590cdf0e10cSrcweir     virtual Point		PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
591cdf0e10cSrcweir     virtual sal_Bool	GetSelection( ESelection& rSelection ) const;
592cdf0e10cSrcweir     virtual sal_Bool	SetSelection( const ESelection& rSelection );
593cdf0e10cSrcweir     virtual sal_Bool	Copy();
594cdf0e10cSrcweir     virtual sal_Bool	Cut();
595cdf0e10cSrcweir     virtual sal_Bool	Paste();
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	void				GrabFocus();
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     void                SetInvalid();
600cdf0e10cSrcweir };
601cdf0e10cSrcweir 
ScEditViewForwarder(EditView * pEditView,Window * pWin)602cdf0e10cSrcweir ScEditViewForwarder::ScEditViewForwarder(EditView* pEditView, Window* pWin)
603cdf0e10cSrcweir 	: mpEditView(pEditView),
604cdf0e10cSrcweir     mpWindow(pWin)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir 	GrabFocus();
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
~ScEditViewForwarder()609cdf0e10cSrcweir ScEditViewForwarder::~ScEditViewForwarder()
610cdf0e10cSrcweir {
611cdf0e10cSrcweir }
612cdf0e10cSrcweir 
IsValid() const613cdf0e10cSrcweir sal_Bool ScEditViewForwarder::IsValid() const
614cdf0e10cSrcweir {
615cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
616cdf0e10cSrcweir 	if (mpWindow && mpEditView)
617cdf0e10cSrcweir 	{
618cdf0e10cSrcweir 		bResult = sal_True;
619cdf0e10cSrcweir 	}
620cdf0e10cSrcweir 	return bResult;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
GetVisArea() const623cdf0e10cSrcweir Rectangle ScEditViewForwarder::GetVisArea() const
624cdf0e10cSrcweir {
625cdf0e10cSrcweir 	Rectangle aVisArea;
626cdf0e10cSrcweir 	if (IsValid() && mpEditView->GetEditEngine())
627cdf0e10cSrcweir 	{
628cdf0e10cSrcweir 		MapMode aMapMode(mpEditView->GetEditEngine()->GetRefMapMode());
629cdf0e10cSrcweir 
630cdf0e10cSrcweir         aVisArea = mpWindow->LogicToPixel( mpEditView->GetVisArea(), aMapMode );
631cdf0e10cSrcweir 	}
632cdf0e10cSrcweir 	else
633cdf0e10cSrcweir 	{
634cdf0e10cSrcweir 		DBG_ERROR("this EditViewForwarder is no longer valid");
635cdf0e10cSrcweir 	}
636cdf0e10cSrcweir 	return aVisArea;
637cdf0e10cSrcweir }
638cdf0e10cSrcweir 
LogicToPixel(const Point & rPoint,const MapMode & rMapMode) const639cdf0e10cSrcweir Point ScEditViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
640cdf0e10cSrcweir {
641cdf0e10cSrcweir 	if (mpWindow)
642cdf0e10cSrcweir 		return mpWindow->LogicToPixel( rPoint, rMapMode );
643cdf0e10cSrcweir 	else
644cdf0e10cSrcweir 	{
645cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
646cdf0e10cSrcweir 	}
647cdf0e10cSrcweir 	return Point();
648cdf0e10cSrcweir }
649cdf0e10cSrcweir 
PixelToLogic(const Point & rPoint,const MapMode & rMapMode) const650cdf0e10cSrcweir Point ScEditViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
651cdf0e10cSrcweir {
652cdf0e10cSrcweir 	if (mpWindow)
653cdf0e10cSrcweir 		return mpWindow->PixelToLogic( rPoint, rMapMode );
654cdf0e10cSrcweir 	else
655cdf0e10cSrcweir 	{
656cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
657cdf0e10cSrcweir 	}
658cdf0e10cSrcweir 	return Point();
659cdf0e10cSrcweir }
660cdf0e10cSrcweir 
GetSelection(ESelection & rSelection) const661cdf0e10cSrcweir sal_Bool ScEditViewForwarder::GetSelection( ESelection& rSelection ) const
662cdf0e10cSrcweir {
663cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
664cdf0e10cSrcweir 	if (IsValid())
665cdf0e10cSrcweir 	{
666cdf0e10cSrcweir 		rSelection = mpEditView->GetSelection();
667cdf0e10cSrcweir 		bResult = sal_True;
668cdf0e10cSrcweir 	}
669cdf0e10cSrcweir 	else
670cdf0e10cSrcweir 	{
671cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir 	return bResult;
674cdf0e10cSrcweir }
675cdf0e10cSrcweir 
SetSelection(const ESelection & rSelection)676cdf0e10cSrcweir sal_Bool ScEditViewForwarder::SetSelection( const ESelection& rSelection )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
679cdf0e10cSrcweir 	if (IsValid())
680cdf0e10cSrcweir 	{
681cdf0e10cSrcweir 		mpEditView->SetSelection(rSelection);
682cdf0e10cSrcweir 		bResult = sal_True;
683cdf0e10cSrcweir 	}
684cdf0e10cSrcweir 	else
685cdf0e10cSrcweir 	{
686cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
687cdf0e10cSrcweir 	}
688cdf0e10cSrcweir 	return bResult;
689cdf0e10cSrcweir }
690cdf0e10cSrcweir 
Copy()691cdf0e10cSrcweir sal_Bool ScEditViewForwarder::Copy()
692cdf0e10cSrcweir {
693cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
694cdf0e10cSrcweir 	if (IsValid())
695cdf0e10cSrcweir 	{
696cdf0e10cSrcweir 		mpEditView->Copy();
697cdf0e10cSrcweir 		bResult = sal_True;
698cdf0e10cSrcweir 	}
699cdf0e10cSrcweir 	else
700cdf0e10cSrcweir 	{
701cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
702cdf0e10cSrcweir 	}
703cdf0e10cSrcweir 	return bResult;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir 
Cut()706cdf0e10cSrcweir sal_Bool ScEditViewForwarder::Cut()
707cdf0e10cSrcweir {
708cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
709cdf0e10cSrcweir 	if (IsValid())
710cdf0e10cSrcweir 	{
711cdf0e10cSrcweir 		mpEditView->Cut();
712cdf0e10cSrcweir 		bResult = sal_True;
713cdf0e10cSrcweir 	}
714cdf0e10cSrcweir 	else
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
717cdf0e10cSrcweir 	}
718cdf0e10cSrcweir 	return bResult;
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
Paste()721cdf0e10cSrcweir sal_Bool ScEditViewForwarder::Paste()
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
724cdf0e10cSrcweir 	if (IsValid())
725cdf0e10cSrcweir 	{
726cdf0e10cSrcweir 		mpEditView->Paste();
727cdf0e10cSrcweir 		bResult = sal_True;
728cdf0e10cSrcweir 	}
729cdf0e10cSrcweir 	else
730cdf0e10cSrcweir 	{
731cdf0e10cSrcweir 		DBG_ERROR("this ViewForwarder is not valid");
732cdf0e10cSrcweir 	}
733cdf0e10cSrcweir 	return bResult;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir 
GrabFocus()736cdf0e10cSrcweir void ScEditViewForwarder::GrabFocus()
737cdf0e10cSrcweir {
738cdf0e10cSrcweir }
739cdf0e10cSrcweir 
SetInvalid()740cdf0e10cSrcweir void ScEditViewForwarder::SetInvalid()
741cdf0e10cSrcweir {
742cdf0e10cSrcweir     mpWindow = NULL;
743cdf0e10cSrcweir     mpEditView = NULL;
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir // ============================================================================
747cdf0e10cSrcweir 
748cdf0e10cSrcweir //	ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
749cdf0e10cSrcweir 
ScAccessibleCellTextData(ScTabViewShell * pViewShell,const ScAddress & rP,ScSplitPos eSplitPos,ScAccessibleCell * pAccCell)750cdf0e10cSrcweir ScAccessibleCellTextData::ScAccessibleCellTextData(ScTabViewShell* pViewShell,
751cdf0e10cSrcweir         const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell)
752cdf0e10cSrcweir 	: ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
753cdf0e10cSrcweir 	mpViewForwarder(NULL),
754cdf0e10cSrcweir 	mpEditViewForwarder(NULL),
755cdf0e10cSrcweir 	mpViewShell(pViewShell),
756cdf0e10cSrcweir 	meSplitPos(eSplitPos),
757cdf0e10cSrcweir     mbViewEditEngine(sal_False),
758cdf0e10cSrcweir     mpAccessibleCell( pAccCell )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir }
761cdf0e10cSrcweir 
~ScAccessibleCellTextData()762cdf0e10cSrcweir ScAccessibleCellTextData::~ScAccessibleCellTextData()
763cdf0e10cSrcweir {
764cdf0e10cSrcweir     if (pEditEngine)
765cdf0e10cSrcweir         pEditEngine->SetNotifyHdl(Link());
766cdf0e10cSrcweir 	if (mpViewForwarder)
767cdf0e10cSrcweir 		delete mpViewForwarder;
768cdf0e10cSrcweir 	if (mpEditViewForwarder)
769cdf0e10cSrcweir 		delete mpEditViewForwarder;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)772cdf0e10cSrcweir void ScAccessibleCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
773cdf0e10cSrcweir {
774cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) )
775cdf0e10cSrcweir 	{
776cdf0e10cSrcweir 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
777cdf0e10cSrcweir 		if ( nId == SFX_HINT_DYING )
778cdf0e10cSrcweir 		{
779cdf0e10cSrcweir 			mpViewShell = NULL;						// invalid now
780cdf0e10cSrcweir             if (mpViewForwarder)
781cdf0e10cSrcweir                 mpViewForwarder->SetInvalid();
782cdf0e10cSrcweir             if (mpEditViewForwarder)
783cdf0e10cSrcweir                 mpEditViewForwarder->SetInvalid();
784cdf0e10cSrcweir 		}
785cdf0e10cSrcweir 	}
786cdf0e10cSrcweir 	ScAccessibleCellBaseTextData::Notify(rBC, rHint);
787cdf0e10cSrcweir }
788cdf0e10cSrcweir 
Clone() const789cdf0e10cSrcweir ScAccessibleTextData* ScAccessibleCellTextData::Clone() const
790cdf0e10cSrcweir {
791cdf0e10cSrcweir     return new ScAccessibleCellTextData( mpViewShell, aCellPos, meSplitPos, mpAccessibleCell );
792cdf0e10cSrcweir }
793cdf0e10cSrcweir 
GetCellText(const ScAddress & rCellPos,String & rText)794cdf0e10cSrcweir void ScAccessibleCellTextData::GetCellText(const ScAddress& rCellPos, String& rText)
795cdf0e10cSrcweir {
796cdf0e10cSrcweir //  #104893#; don't use the input string
797cdf0e10cSrcweir //    ScCellTextData::GetCellText(rCellPos, rText);
798cdf0e10cSrcweir     ScDocument* pDoc = pDocShell->GetDocument();
799cdf0e10cSrcweir     if (pDoc)
800cdf0e10cSrcweir     {
801cdf0e10cSrcweir         //  #104893#; use the displayed string
802cdf0e10cSrcweir         pDoc->GetString(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText);
803cdf0e10cSrcweir         if (mpViewShell)
804cdf0e10cSrcweir         {
805cdf0e10cSrcweir             const ScViewOptions& aOptions = mpViewShell->GetViewData()->GetOptions();
806cdf0e10cSrcweir             CellType aCellType;
807cdf0e10cSrcweir             pDoc->GetCellType(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), aCellType);
808cdf0e10cSrcweir             if (aCellType == CELLTYPE_FORMULA && aOptions.GetOption( VOPT_FORMULAS ))
809cdf0e10cSrcweir             {
810cdf0e10cSrcweir                 pDoc->GetFormula( rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText);
811cdf0e10cSrcweir             }
812cdf0e10cSrcweir             else if (!aOptions.GetOption( VOPT_NULLVALS ))
813cdf0e10cSrcweir             {
814cdf0e10cSrcweir                 if ((aCellType == CELLTYPE_VALUE || aCellType == CELLTYPE_FORMULA) && pDoc->GetValue(rCellPos) == 0.0)
815cdf0e10cSrcweir                     rText.Erase();
816cdf0e10cSrcweir             }
817cdf0e10cSrcweir         }
818cdf0e10cSrcweir     }
819cdf0e10cSrcweir }
820cdf0e10cSrcweir 
GetTextForwarder()821cdf0e10cSrcweir SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
822cdf0e10cSrcweir {
823cdf0e10cSrcweir /*	sal_Bool bHasForwarder(sal_False);
824cdf0e10cSrcweir 	if (mpViewShell && mpViewShell->GetViewData() &&
825cdf0e10cSrcweir 		(mpViewShell->GetViewData()->GetCurPos() == aCellPos) &&
826cdf0e10cSrcweir 		(mpViewShell->GetViewData()->HasEditView(meSplitPos)) &&
827cdf0e10cSrcweir 		(mpViewShell->GetViewData()->GetEditViewCol() == aCellPos.Col()) &&
828cdf0e10cSrcweir 		(mpViewShell->GetViewData()->GetEditViewRow() == aCellPos.Row()))
829cdf0e10cSrcweir 	{
830cdf0e10cSrcweir 		if (!mbViewEditEngine)
831cdf0e10cSrcweir 		{
832cdf0e10cSrcweir 			if (pForwarder)
833cdf0e10cSrcweir 				DELETEZ( pForwarder );
834cdf0e10cSrcweir 			if (pEditEngine)
835cdf0e10cSrcweir 				DELETEZ( pEditEngine );
836cdf0e10cSrcweir 
837cdf0e10cSrcweir                 SCCOL nCol;
838cdf0e10cSrcweir                 SCROW nRow;
839cdf0e10cSrcweir                 EditView* pEditView;
840cdf0e10cSrcweir 			mpViewShell->GetViewData()->GetEditView( meSplitPos, pEditView, nCol, nRow );
841cdf0e10cSrcweir 			if (pEditView)
842cdf0e10cSrcweir 			{
843cdf0e10cSrcweir                 pEditEngine = (ScFieldEditEngine*)pEditView->GetEditEngine();
844cdf0e10cSrcweir 				pForwarder = new SvxEditEngineForwarder(*pEditEngine);
845cdf0e10cSrcweir 				bHasForwarder = sal_True;
846cdf0e10cSrcweir 			}
847cdf0e10cSrcweir 		}
848cdf0e10cSrcweir 		else
849cdf0e10cSrcweir 			bHasForwarder = sal_True;
850cdf0e10cSrcweir 	}
851cdf0e10cSrcweir 	else if (mbViewEditEngine)
852cdf0e10cSrcweir 	{
853cdf0e10cSrcweir 		// remove Forwarder created with EditEngine from EditView
854cdf0e10cSrcweir 		if (pForwarder)
855cdf0e10cSrcweir 			DELETEZ( pForwarder );
856cdf0e10cSrcweir         pEditEngine->SetNotifyHdl(Link());
857cdf0e10cSrcweir 		// don't delete, because it is the EditEngine of the EditView
858cdf0e10cSrcweir 		pEditEngine = NULL;
859cdf0e10cSrcweir         mbViewEditEngine = sal_False;
860cdf0e10cSrcweir 	}
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 	if (!bHasForwarder)*/
863cdf0e10cSrcweir 		ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
864cdf0e10cSrcweir 
865cdf0e10cSrcweir     ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL );
866cdf0e10cSrcweir     if ( pDoc && pEditEngine && mpViewShell )
867cdf0e10cSrcweir 	{
868cdf0e10cSrcweir 		long nSizeX, nSizeY;
869cdf0e10cSrcweir 		mpViewShell->GetViewData()->GetMergeSizePixel(
870cdf0e10cSrcweir 			aCellPos.Col(), aCellPos.Row(), nSizeX, nSizeY);
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 		Size aSize(nSizeX, nSizeY);
873cdf0e10cSrcweir 
874cdf0e10cSrcweir         // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
875cdf0e10cSrcweir         long nIndent = 0;
876cdf0e10cSrcweir         const SvxHorJustifyItem* pHorJustifyItem = static_cast< const SvxHorJustifyItem* >(
877cdf0e10cSrcweir             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_HOR_JUSTIFY ) );
878cdf0e10cSrcweir         SvxCellHorJustify eHorJust = ( pHorJustifyItem ? static_cast< SvxCellHorJustify >( pHorJustifyItem->GetValue() ) : SVX_HOR_JUSTIFY_STANDARD );
879cdf0e10cSrcweir         if ( eHorJust == SVX_HOR_JUSTIFY_LEFT )
880cdf0e10cSrcweir         {
881cdf0e10cSrcweir             const SfxUInt16Item* pIndentItem = static_cast< const SfxUInt16Item* >(
882cdf0e10cSrcweir                 pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_INDENT ) );
883cdf0e10cSrcweir             if ( pIndentItem )
884cdf0e10cSrcweir             {
885cdf0e10cSrcweir                 nIndent = static_cast< long >( pIndentItem->GetValue() );
886cdf0e10cSrcweir             }
887cdf0e10cSrcweir         }
888cdf0e10cSrcweir 
889cdf0e10cSrcweir         const SvxMarginItem* pMarginItem = static_cast< const SvxMarginItem* >(
890cdf0e10cSrcweir             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_MARGIN ) );
891cdf0e10cSrcweir         ScViewData* pViewData = mpViewShell->GetViewData();
892cdf0e10cSrcweir         double nPPTX = ( pViewData ? pViewData->GetPPTX() : 0 );
893cdf0e10cSrcweir         double nPPTY = ( pViewData ? pViewData->GetPPTY() : 0 );
894cdf0e10cSrcweir         long nLeftM = ( pMarginItem ? static_cast< long >( ( pMarginItem->GetLeftMargin() + nIndent ) * nPPTX ) : 0 );
895cdf0e10cSrcweir         long nTopM = ( pMarginItem ? static_cast< long >( pMarginItem->GetTopMargin() * nPPTY ) : 0 );
896cdf0e10cSrcweir         long nRightM = ( pMarginItem ? static_cast< long >( pMarginItem->GetRightMargin() * nPPTX ) : 0 );
897cdf0e10cSrcweir         long nBottomM = ( pMarginItem ? static_cast< long >( pMarginItem->GetBottomMargin() * nPPTY ) : 0 );
898cdf0e10cSrcweir         long nWidth = aSize.getWidth() - nLeftM - nRightM;
899cdf0e10cSrcweir         aSize.setWidth( nWidth );
900cdf0e10cSrcweir         aSize.setHeight( aSize.getHeight() - nTopM - nBottomM );
901cdf0e10cSrcweir 
902cdf0e10cSrcweir         Window* pWin = mpViewShell->GetWindowByPos( meSplitPos );
903cdf0e10cSrcweir         if ( pWin )
904cdf0e10cSrcweir         {
905cdf0e10cSrcweir             aSize = pWin->PixelToLogic( aSize, pEditEngine->GetRefMapMode() );
906cdf0e10cSrcweir         }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir         /*  #i19430# Gnopernicus reads text partly if it sticks out of the cell
909cdf0e10cSrcweir             boundaries. This leads to wrong results in cases where the cell text
910cdf0e10cSrcweir             is rotated, because rotation is not taken into account when calcu-
911cdf0e10cSrcweir             lating the visible part of the text. In these cases we will expand
912cdf0e10cSrcweir             the cell size passed as paper size to the edit engine. The function
913cdf0e10cSrcweir             accessibility::AccessibleStaticTextBase::GetParagraphBoundingBox()
914cdf0e10cSrcweir             (see svx/source/accessibility/AccessibleStaticTextBase.cxx) will
915cdf0e10cSrcweir             return the size of the complete text then, which is used to expand
916cdf0e10cSrcweir             the cell bounding box in ScAccessibleCell::GetBoundingBox()
917cdf0e10cSrcweir             (see sc/source/ui/Accessibility/AccessibleCell.cxx). */
918cdf0e10cSrcweir         const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >(
919cdf0e10cSrcweir             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_ROTATE_VALUE ) );
920cdf0e10cSrcweir         if( pItem && (pItem->GetValue() != 0) )
921cdf0e10cSrcweir         {
922cdf0e10cSrcweir             pEditEngine->SetPaperSize( Size( LONG_MAX, aSize.getHeight() ) );
923cdf0e10cSrcweir             long nTxtWidth = static_cast< long >( pEditEngine->CalcTextWidth() );
924cdf0e10cSrcweir             aSize.setWidth( std::max( aSize.getWidth(), nTxtWidth + 2 ) );
925cdf0e10cSrcweir         }
926cdf0e10cSrcweir         else
927cdf0e10cSrcweir         {
928cdf0e10cSrcweir             // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
929cdf0e10cSrcweir             const SfxBoolItem* pLineBreakItem = static_cast< const SfxBoolItem* >(
930cdf0e10cSrcweir                 pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_LINEBREAK ) );
931cdf0e10cSrcweir             bool bLineBreak = ( pLineBreakItem && pLineBreakItem->GetValue() );
932cdf0e10cSrcweir             if ( !bLineBreak )
933cdf0e10cSrcweir             {
934cdf0e10cSrcweir                 long nTxtWidth = static_cast< long >( pEditEngine->CalcTextWidth() );
935cdf0e10cSrcweir                 aSize.setWidth( ::std::max( aSize.getWidth(), nTxtWidth ) );
936cdf0e10cSrcweir             }
937cdf0e10cSrcweir         }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir         pEditEngine->SetPaperSize( aSize );
940cdf0e10cSrcweir 
941cdf0e10cSrcweir         // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
942cdf0e10cSrcweir         if ( eHorJust == SVX_HOR_JUSTIFY_STANDARD && pDoc->HasValueData( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab() ) )
943cdf0e10cSrcweir         {
944cdf0e10cSrcweir             pEditEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
945cdf0e10cSrcweir         }
946cdf0e10cSrcweir 
947cdf0e10cSrcweir         Size aTextSize;
948cdf0e10cSrcweir         if ( pWin )
949cdf0e10cSrcweir         {
950cdf0e10cSrcweir             aTextSize = pWin->LogicToPixel( Size( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() ), pEditEngine->GetRefMapMode() );
951cdf0e10cSrcweir         }
952cdf0e10cSrcweir         long nTextWidth = aTextSize.Width();
953cdf0e10cSrcweir         long nTextHeight = aTextSize.Height();
954cdf0e10cSrcweir 
955cdf0e10cSrcweir         long nOffsetX = nLeftM;
956cdf0e10cSrcweir         long nDiffX = nTextWidth - nWidth;
957cdf0e10cSrcweir         if ( nDiffX > 0 )
958cdf0e10cSrcweir         {
959cdf0e10cSrcweir             switch ( eHorJust )
960cdf0e10cSrcweir             {
961cdf0e10cSrcweir                 case SVX_HOR_JUSTIFY_RIGHT:
962cdf0e10cSrcweir                     {
963cdf0e10cSrcweir                         nOffsetX -= nDiffX;
964cdf0e10cSrcweir                     }
965cdf0e10cSrcweir                     break;
966cdf0e10cSrcweir                 case SVX_HOR_JUSTIFY_CENTER:
967cdf0e10cSrcweir                     {
968cdf0e10cSrcweir                         nOffsetX -= nDiffX / 2;
969cdf0e10cSrcweir                     }
970cdf0e10cSrcweir                     break;
971cdf0e10cSrcweir                 default:
972cdf0e10cSrcweir                     {
973cdf0e10cSrcweir                     }
974cdf0e10cSrcweir                     break;
975cdf0e10cSrcweir             }
976cdf0e10cSrcweir         }
977cdf0e10cSrcweir 
978cdf0e10cSrcweir         long nOffsetY = 0;
979cdf0e10cSrcweir         const SvxVerJustifyItem* pVerJustifyItem = static_cast< const SvxVerJustifyItem* >(
980cdf0e10cSrcweir             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_VER_JUSTIFY ) );
981cdf0e10cSrcweir         SvxCellVerJustify eVerJust = ( pVerJustifyItem ? static_cast< SvxCellVerJustify >( pVerJustifyItem->GetValue() ) : SVX_VER_JUSTIFY_STANDARD );
982cdf0e10cSrcweir         switch ( eVerJust )
983cdf0e10cSrcweir         {
984cdf0e10cSrcweir             case SVX_VER_JUSTIFY_STANDARD:
985cdf0e10cSrcweir             case SVX_VER_JUSTIFY_BOTTOM:
986cdf0e10cSrcweir                 {
987cdf0e10cSrcweir                     nOffsetY = nSizeY - nBottomM - nTextHeight;
988cdf0e10cSrcweir                 }
989cdf0e10cSrcweir                 break;
990cdf0e10cSrcweir             case SVX_VER_JUSTIFY_CENTER:
991cdf0e10cSrcweir                 {
992cdf0e10cSrcweir                     nOffsetY = ( nSizeY - nTopM - nBottomM - nTextHeight ) / 2 + nTopM;
993cdf0e10cSrcweir                 }
994cdf0e10cSrcweir                 break;
995cdf0e10cSrcweir             default:
996cdf0e10cSrcweir                 {
997cdf0e10cSrcweir                     nOffsetY = nTopM;
998cdf0e10cSrcweir                 }
999cdf0e10cSrcweir                 break;
1000cdf0e10cSrcweir         }
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir         if ( mpAccessibleCell )
1003cdf0e10cSrcweir         {
1004cdf0e10cSrcweir             mpAccessibleCell->SetOffset( Point( nOffsetX, nOffsetY ) );
1005cdf0e10cSrcweir         }
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir 		pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
1008cdf0e10cSrcweir 	}
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir 	return pForwarder;
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir 
GetViewForwarder()1013cdf0e10cSrcweir SvxViewForwarder* ScAccessibleCellTextData::GetViewForwarder()
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir 	if (!mpViewForwarder)
1016cdf0e10cSrcweir 		mpViewForwarder = new ScViewForwarder(mpViewShell, meSplitPos, aCellPos);
1017cdf0e10cSrcweir 	return mpViewForwarder;
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
GetEditViewForwarder(sal_Bool)1020cdf0e10cSrcweir SvxEditViewForwarder* ScAccessibleCellTextData::GetEditViewForwarder( sal_Bool /* bCreate */ )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir     //#102219#; there should no EditViewForwarder be, because the cell is now readonly in this interface
1023cdf0e10cSrcweir /*	if (!mpEditViewForwarder)
1024cdf0e10cSrcweir     {
1025cdf0e10cSrcweir         SCCOL nCol;
1026cdf0e10cSrcweir         SCROW nRow;
1027cdf0e10cSrcweir         EditView* pEditView;
1028cdf0e10cSrcweir 		mpViewShell->GetViewData()->GetEditView( meSplitPos, pEditView, nCol, nRow );
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir 		mpEditViewForwarder = new ScEditViewForwarder(pEditView, mpViewShell->GetWindowByPos(meSplitPos));
1031cdf0e10cSrcweir     }
1032cdf0e10cSrcweir 	else if (bCreate)
1033cdf0e10cSrcweir 		mpEditViewForwarder->GrabFocus();
1034cdf0e10cSrcweir 	return mpEditViewForwarder;*/
1035cdf0e10cSrcweir     return NULL;
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir 
IMPL_LINK(ScAccessibleCellTextData,NotifyHdl,EENotify *,aNotify)1038cdf0e10cSrcweir IMPL_LINK(ScAccessibleCellTextData, NotifyHdl, EENotify*, aNotify)
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir     if( aNotify )
1041cdf0e10cSrcweir     {
1042cdf0e10cSrcweir         ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir         if( aHint.get() )
1045cdf0e10cSrcweir             GetBroadcaster().Broadcast( *aHint.get() );
1046cdf0e10cSrcweir     }
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir     return 0;
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir 
GetDocShell(ScTabViewShell * pViewShell)1051cdf0e10cSrcweir ScDocShell* ScAccessibleCellTextData::GetDocShell(ScTabViewShell* pViewShell)
1052cdf0e10cSrcweir {
1053cdf0e10cSrcweir 	ScDocShell* pDocSh = NULL;
1054cdf0e10cSrcweir 	if (pViewShell)
1055cdf0e10cSrcweir 		pDocSh = pViewShell->GetViewData()->GetDocShell();
1056cdf0e10cSrcweir 	return pDocSh;
1057cdf0e10cSrcweir }
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir // ============================================================================
ScAccessibleEditObjectTextData(EditView * pEditView,Window * pWin,sal_Bool isClone)10610deba7fbSSteve Yin ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin, sal_Bool isClone)
1062cdf0e10cSrcweir 	:
1063cdf0e10cSrcweir 	mpViewForwarder(NULL),
1064cdf0e10cSrcweir 	mpEditViewForwarder(NULL),
1065cdf0e10cSrcweir     mpEditView(pEditView),
1066cdf0e10cSrcweir     mpEditEngine(pEditView ? pEditView->GetEditEngine() : 0),
1067cdf0e10cSrcweir     mpForwarder(NULL),
1068cdf0e10cSrcweir     mpWindow(pWin)
1069cdf0e10cSrcweir {
10700deba7fbSSteve Yin 	// Solution: If the object is cloned, do NOT add notify hdl.
10710deba7fbSSteve Yin 	mbIsCloned = isClone;
10720deba7fbSSteve Yin     if (mpEditEngine && !mbIsCloned)
1073cdf0e10cSrcweir         mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir 
~ScAccessibleEditObjectTextData()1076cdf0e10cSrcweir ScAccessibleEditObjectTextData::~ScAccessibleEditObjectTextData()
1077cdf0e10cSrcweir {
10780deba7fbSSteve Yin 	// Solution: If the object is cloned, do NOT set notify hdl.
10790deba7fbSSteve Yin     if (mpEditEngine && !mbIsCloned)
1080cdf0e10cSrcweir         mpEditEngine->SetNotifyHdl(Link());
1081cdf0e10cSrcweir 	if (mpViewForwarder)
1082cdf0e10cSrcweir 		delete mpViewForwarder;
1083cdf0e10cSrcweir 	if (mpEditViewForwarder)
1084cdf0e10cSrcweir 		delete mpEditViewForwarder;
1085cdf0e10cSrcweir     if (mpForwarder)
1086cdf0e10cSrcweir         delete mpForwarder;
1087cdf0e10cSrcweir }
1088cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1089cdf0e10cSrcweir void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) )
1092cdf0e10cSrcweir 	{
1093cdf0e10cSrcweir 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1094cdf0e10cSrcweir 		if ( nId == SFX_HINT_DYING )
1095cdf0e10cSrcweir 		{
1096cdf0e10cSrcweir             mpWindow = NULL;
1097cdf0e10cSrcweir             mpEditView = NULL;
1098cdf0e10cSrcweir             mpEditEngine = NULL;
1099cdf0e10cSrcweir             DELETEZ(mpForwarder);
1100cdf0e10cSrcweir         	if (mpViewForwarder)
1101cdf0e10cSrcweir             	mpViewForwarder->SetInvalid();
1102cdf0e10cSrcweir 	        if (mpEditViewForwarder)
1103cdf0e10cSrcweir             	mpEditViewForwarder->SetInvalid();
1104cdf0e10cSrcweir 		}
1105cdf0e10cSrcweir 	}
1106cdf0e10cSrcweir 	ScAccessibleTextData::Notify(rBC, rHint);
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir 
Clone() const1109cdf0e10cSrcweir ScAccessibleTextData* ScAccessibleEditObjectTextData::Clone() const
1110cdf0e10cSrcweir {
11110deba7fbSSteve Yin 	// Solution: Add para to indicate the object is cloned
11120deba7fbSSteve Yin 	//return new ScAccessibleEditObjectTextData(mpEditView, mpWindow);
11130deba7fbSSteve Yin 	return new ScAccessibleEditObjectTextData(mpEditView, mpWindow,sal_True);
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir 
GetTextForwarder()1116cdf0e10cSrcweir SvxTextForwarder* ScAccessibleEditObjectTextData::GetTextForwarder()
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir 	if ((!mpForwarder && mpEditView) || (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()))
1119cdf0e10cSrcweir 	{
1120cdf0e10cSrcweir         if (!mpEditEngine)
1121cdf0e10cSrcweir             mpEditEngine = mpEditView->GetEditEngine();
11220deba7fbSSteve Yin 			// Solution: If the object is cloned, do NOT add notify hdl.
11230deba7fbSSteve Yin 	if (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()&&!mbIsCloned)
1124cdf0e10cSrcweir             mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1125cdf0e10cSrcweir         if(!mpForwarder)
1126cdf0e10cSrcweir             mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1127cdf0e10cSrcweir 	}
1128cdf0e10cSrcweir 	return mpForwarder;
1129cdf0e10cSrcweir }
1130cdf0e10cSrcweir 
GetViewForwarder()1131cdf0e10cSrcweir SvxViewForwarder* ScAccessibleEditObjectTextData::GetViewForwarder()
1132cdf0e10cSrcweir {
1133cdf0e10cSrcweir 	if (!mpViewForwarder)
1134cdf0e10cSrcweir     {
1135cdf0e10cSrcweir         // --> OD 2005-12-21 #i49561#
1136cdf0e10cSrcweir         mpViewForwarder = new ScEditObjectViewForwarder( mpWindow, mpEditView );
1137cdf0e10cSrcweir         // <--
1138cdf0e10cSrcweir     }
1139cdf0e10cSrcweir 	return mpViewForwarder;
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir 
GetEditViewForwarder(sal_Bool bCreate)1142cdf0e10cSrcweir SvxEditViewForwarder* ScAccessibleEditObjectTextData::GetEditViewForwarder( sal_Bool bCreate )
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir     if (!mpEditViewForwarder && mpEditView)
1145cdf0e10cSrcweir 		mpEditViewForwarder = new ScEditViewForwarder(mpEditView, mpWindow);
1146cdf0e10cSrcweir 	if (bCreate)
1147cdf0e10cSrcweir 	{
1148cdf0e10cSrcweir         if (!mpEditView && mpEditViewForwarder)
1149cdf0e10cSrcweir         {
1150cdf0e10cSrcweir             DELETEZ(mpEditViewForwarder);
1151cdf0e10cSrcweir         }
1152cdf0e10cSrcweir 		else if (mpEditViewForwarder)
1153cdf0e10cSrcweir 			mpEditViewForwarder->GrabFocus();
1154cdf0e10cSrcweir 	}
1155cdf0e10cSrcweir 	return mpEditViewForwarder;
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir 
IMPL_LINK(ScAccessibleEditObjectTextData,NotifyHdl,EENotify *,aNotify)1158cdf0e10cSrcweir IMPL_LINK(ScAccessibleEditObjectTextData, NotifyHdl, EENotify*, aNotify)
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir     if( aNotify )
1161cdf0e10cSrcweir     {
1162cdf0e10cSrcweir         ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir         if( aHint.get() )
1165cdf0e10cSrcweir             GetBroadcaster().Broadcast( *aHint.get() );
1166cdf0e10cSrcweir     }
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir     return 0;
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir // ============================================================================
1173cdf0e10cSrcweir 
ScAccessibleEditLineTextData(EditView * pEditView,Window * pWin)1174cdf0e10cSrcweir ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin)
1175cdf0e10cSrcweir     :
1176cdf0e10cSrcweir     ScAccessibleEditObjectTextData(pEditView, pWin),
1177cdf0e10cSrcweir     mbEditEngineCreated(sal_False)
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir     ScTextWnd* pTxtWnd = (ScTextWnd*)pWin;
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir     if (pTxtWnd)
1182cdf0e10cSrcweir         pTxtWnd->InsertAccessibleTextData( *this );
1183cdf0e10cSrcweir }
1184cdf0e10cSrcweir 
~ScAccessibleEditLineTextData()1185cdf0e10cSrcweir ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir     if (pTxtWnd)
1190cdf0e10cSrcweir         pTxtWnd->RemoveAccessibleTextData( *this );
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir     if (mbEditEngineCreated && mpEditEngine)
1193cdf0e10cSrcweir     {
1194cdf0e10cSrcweir         delete mpEditEngine;
1195cdf0e10cSrcweir         mpEditEngine = NULL;    // #103346# don't access in ScAccessibleEditObjectTextData dtor!
1196cdf0e10cSrcweir     }
1197cdf0e10cSrcweir     else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
1198cdf0e10cSrcweir     {
1199cdf0e10cSrcweir         //  #103346# the NotifyHdl also has to be removed from the ScTextWnd's EditEngine
1200cdf0e10cSrcweir         //  (it's set in ScAccessibleEditLineTextData::GetTextForwarder, and mpEditEngine
1201cdf0e10cSrcweir         //  is reset there)
1202cdf0e10cSrcweir         pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
1203cdf0e10cSrcweir     }
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir 
Dispose()1206cdf0e10cSrcweir void ScAccessibleEditLineTextData::Dispose()
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir     if (pTxtWnd)
1211cdf0e10cSrcweir         pTxtWnd->RemoveAccessibleTextData( *this );
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir     ResetEditMode();
1214cdf0e10cSrcweir     mpWindow = NULL;
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir 
Clone() const1217cdf0e10cSrcweir ScAccessibleTextData* ScAccessibleEditLineTextData::Clone() const
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir     return new ScAccessibleEditLineTextData(mpEditView, mpWindow);
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir 
GetTextForwarder()1222cdf0e10cSrcweir SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder()
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir     if (pTxtWnd)
1227cdf0e10cSrcweir     {
1228cdf0e10cSrcweir         mpEditView = pTxtWnd->GetEditView();
1229cdf0e10cSrcweir         if (mpEditView)
1230cdf0e10cSrcweir         {
1231cdf0e10cSrcweir             if (mbEditEngineCreated && mpEditEngine)
1232cdf0e10cSrcweir                 ResetEditMode();
1233cdf0e10cSrcweir             mbEditEngineCreated = sal_False;
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir             mpEditView = pTxtWnd->GetEditView();
1236cdf0e10cSrcweir             ScAccessibleEditObjectTextData::GetTextForwarder(); // fill the mpForwarder
1237cdf0e10cSrcweir             mpEditEngine = NULL;
1238cdf0e10cSrcweir         }
1239cdf0e10cSrcweir         else
1240cdf0e10cSrcweir         {
1241cdf0e10cSrcweir             if (mpEditEngine && !mbEditEngineCreated)
1242cdf0e10cSrcweir                 ResetEditMode();
1243cdf0e10cSrcweir 	        if (!mpEditEngine)
1244cdf0e10cSrcweir 	        {
1245cdf0e10cSrcweir 			    SfxItemPool* pEnginePool = EditEngine::CreatePool();
1246cdf0e10cSrcweir 			    pEnginePool->FreezeIdRanges();
1247cdf0e10cSrcweir 			    mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
1248cdf0e10cSrcweir                 mbEditEngineCreated = sal_True;
1249cdf0e10cSrcweir 		        //	currently, GetPortions doesn't work if UpdateMode is sal_False,
1250cdf0e10cSrcweir 		        //	this will be fixed (in EditEngine) by src600
1251cdf0e10cSrcweir         //		pEditEngine->SetUpdateMode( sal_False );
1252cdf0e10cSrcweir 		        mpEditEngine->EnableUndo( sal_False );
1253cdf0e10cSrcweir 			    mpEditEngine->SetRefMapMode( MAP_100TH_MM );
1254cdf0e10cSrcweir 		        mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir                 mpEditEngine->SetText(pTxtWnd->GetTextString());
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir 		        Size aSize(pTxtWnd->GetSizePixel());
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir 			    aSize = pTxtWnd->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir 		        mpEditEngine->SetPaperSize(aSize);
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir 		        mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1265cdf0e10cSrcweir             }
1266cdf0e10cSrcweir         }
1267cdf0e10cSrcweir     }
1268cdf0e10cSrcweir     return mpForwarder;
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir 
GetEditViewForwarder(sal_Bool bCreate)1271cdf0e10cSrcweir SvxEditViewForwarder* ScAccessibleEditLineTextData::GetEditViewForwarder( sal_Bool bCreate )
1272cdf0e10cSrcweir {
1273cdf0e10cSrcweir     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir     if (pTxtWnd)
1276cdf0e10cSrcweir     {
1277cdf0e10cSrcweir         mpEditView = pTxtWnd->GetEditView();
1278cdf0e10cSrcweir         if (!mpEditView && bCreate)
1279cdf0e10cSrcweir         {
1280cdf0e10cSrcweir 	        if ( !pTxtWnd->IsInputActive() )
1281cdf0e10cSrcweir 	        {
1282cdf0e10cSrcweir 		        pTxtWnd->StartEditEngine();
1283cdf0e10cSrcweir 		        pTxtWnd->GrabFocus();
1284cdf0e10cSrcweir //		        pTxtWnd->SetTextString( rText );
1285cdf0e10cSrcweir //		        pTxtWnd->GetEditView()->SetSelection( rSel );
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir                 mpEditView = pTxtWnd->GetEditView();
1288cdf0e10cSrcweir 	        }
1289cdf0e10cSrcweir         }
1290cdf0e10cSrcweir     }
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir     return ScAccessibleEditObjectTextData::GetEditViewForwarder(bCreate);
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir 
ResetEditMode()1295cdf0e10cSrcweir void ScAccessibleEditLineTextData::ResetEditMode()
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir     if (mbEditEngineCreated && mpEditEngine)
1300cdf0e10cSrcweir         delete mpEditEngine;
1301cdf0e10cSrcweir     else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
1302cdf0e10cSrcweir         pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
1303cdf0e10cSrcweir     mpEditEngine = NULL;
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir     DELETEZ(mpForwarder);
1306cdf0e10cSrcweir     DELETEZ(mpEditViewForwarder);
1307cdf0e10cSrcweir     DELETEZ(mpViewForwarder);
1308cdf0e10cSrcweir     mbEditEngineCreated = sal_False;
1309cdf0e10cSrcweir }
1310cdf0e10cSrcweir 
TextChanged()1311cdf0e10cSrcweir void ScAccessibleEditLineTextData::TextChanged()
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir     if (mbEditEngineCreated && mpEditEngine)
1314cdf0e10cSrcweir     {
1315cdf0e10cSrcweir         ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir         if (pTxtWnd)
1318cdf0e10cSrcweir             mpEditEngine->SetText(pTxtWnd->GetTextString());
1319cdf0e10cSrcweir     }
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir 
StartEdit()1322cdf0e10cSrcweir void ScAccessibleEditLineTextData::StartEdit()
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir     ResetEditMode();
1325cdf0e10cSrcweir     mpEditView = NULL;
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir     // send HINT_BEGEDIT
1328cdf0e10cSrcweir     SdrHint aHint(HINT_BEGEDIT);
1329cdf0e10cSrcweir 	GetBroadcaster().Broadcast( aHint );
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir 
EndEdit()1332cdf0e10cSrcweir void ScAccessibleEditLineTextData::EndEdit()
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir     // send HINT_ENDEDIT
1335cdf0e10cSrcweir     SdrHint aHint(HINT_ENDEDIT);
1336cdf0e10cSrcweir 	GetBroadcaster().Broadcast( aHint );
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir     ResetEditMode();
1339cdf0e10cSrcweir     mpEditView = NULL;
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir // ============================================================================
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir //	ScAccessiblePreviewCellTextData: shared data between sub objects of a accessible cell text object
1346cdf0e10cSrcweir 
ScAccessiblePreviewCellTextData(ScPreviewShell * pViewShell,const ScAddress & rP)1347cdf0e10cSrcweir ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
1348cdf0e10cSrcweir 							const ScAddress& rP)
1349cdf0e10cSrcweir 	: ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
1350cdf0e10cSrcweir 	mpViewForwarder(NULL),
1351cdf0e10cSrcweir 	mpViewShell(pViewShell)
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir 
~ScAccessiblePreviewCellTextData()1355cdf0e10cSrcweir ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData()
1356cdf0e10cSrcweir {
1357cdf0e10cSrcweir     if (pEditEngine)
1358cdf0e10cSrcweir         pEditEngine->SetNotifyHdl(Link());
1359cdf0e10cSrcweir 	if (mpViewForwarder)
1360cdf0e10cSrcweir 		delete mpViewForwarder;
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1363cdf0e10cSrcweir void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1364cdf0e10cSrcweir {
1365cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) )
1366cdf0e10cSrcweir 	{
1367cdf0e10cSrcweir 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1368cdf0e10cSrcweir 		if ( nId == SFX_HINT_DYING )
1369cdf0e10cSrcweir 		{
1370cdf0e10cSrcweir 			mpViewShell = NULL;						// invalid now
1371cdf0e10cSrcweir             if (mpViewForwarder)
1372cdf0e10cSrcweir                 mpViewForwarder->SetInvalid();
1373cdf0e10cSrcweir 		}
1374cdf0e10cSrcweir 	}
1375cdf0e10cSrcweir 	ScAccessibleCellBaseTextData::Notify(rBC, rHint);
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir 
Clone() const1378cdf0e10cSrcweir ScAccessibleTextData* ScAccessiblePreviewCellTextData::Clone() const
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir 	return new ScAccessiblePreviewCellTextData(mpViewShell, aCellPos);
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir 
GetTextForwarder()1383cdf0e10cSrcweir SvxTextForwarder* ScAccessiblePreviewCellTextData::GetTextForwarder()
1384cdf0e10cSrcweir {
1385cdf0e10cSrcweir 	sal_Bool bEditEngineBefore(pEditEngine != NULL);
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir 	ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir 	if (!bEditEngineBefore && pEditEngine)
1390cdf0e10cSrcweir 	{
1391cdf0e10cSrcweir 		Size aSize(mpViewShell->GetLocationData().GetCellOutputRect(aCellPos).GetSize());
1392cdf0e10cSrcweir 		Window* pWin = mpViewShell->GetWindow();
1393cdf0e10cSrcweir 		if (pWin)
1394cdf0e10cSrcweir 			aSize = pWin->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
1395cdf0e10cSrcweir 		pEditEngine->SetPaperSize(aSize);
1396cdf0e10cSrcweir 	}
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir 	if (pEditEngine)
1399cdf0e10cSrcweir 		pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir 	return pForwarder;
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir 
GetViewForwarder()1404cdf0e10cSrcweir SvxViewForwarder* ScAccessiblePreviewCellTextData::GetViewForwarder()
1405cdf0e10cSrcweir {
1406cdf0e10cSrcweir 	if (!mpViewForwarder)
1407cdf0e10cSrcweir 		mpViewForwarder = new ScPreviewCellViewForwarder(mpViewShell, aCellPos);
1408cdf0e10cSrcweir 	return mpViewForwarder;
1409cdf0e10cSrcweir }
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir //UNUSED2008-05  IMPL_LINK(ScAccessiblePreviewCellTextData, NotifyHdl, EENotify*, aNotify)
1412cdf0e10cSrcweir //UNUSED2008-05  {
1413cdf0e10cSrcweir //UNUSED2008-05      if( aNotify )
1414cdf0e10cSrcweir //UNUSED2008-05      {
1415cdf0e10cSrcweir //UNUSED2008-05          ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify);
1416cdf0e10cSrcweir //UNUSED2008-05
1417cdf0e10cSrcweir //UNUSED2008-05          if( aHint.get() )
1418cdf0e10cSrcweir //UNUSED2008-05              GetBroadcaster().Broadcast( *aHint.get() );
1419cdf0e10cSrcweir //UNUSED2008-05      }
1420cdf0e10cSrcweir //UNUSED2008-05
1421cdf0e10cSrcweir //UNUSED2008-05      return 0;
1422cdf0e10cSrcweir //UNUSED2008-05  }
1423cdf0e10cSrcweir 
GetDocShell(ScPreviewShell * pViewShell)1424cdf0e10cSrcweir ScDocShell* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell* pViewShell)
1425cdf0e10cSrcweir {
1426cdf0e10cSrcweir 	ScDocShell* pDocSh = NULL;
1427cdf0e10cSrcweir 	if (pViewShell && pViewShell->GetDocument())
1428cdf0e10cSrcweir 		pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1429cdf0e10cSrcweir 	return pDocSh;
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir // ============================================================================
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir //	ScAccessiblePreviewHeaderCellTextData: shared data between sub objects of a accessible cell text object
1436cdf0e10cSrcweir 
ScAccessiblePreviewHeaderCellTextData(ScPreviewShell * pViewShell,const String & rText,const ScAddress & rP,sal_Bool bColHeader,sal_Bool bRowHeader)1437cdf0e10cSrcweir ScAccessiblePreviewHeaderCellTextData::ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
1438cdf0e10cSrcweir 			const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader)
1439cdf0e10cSrcweir 	: ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
1440cdf0e10cSrcweir 	mpViewForwarder(NULL),
1441cdf0e10cSrcweir 	mpViewShell(pViewShell),
1442cdf0e10cSrcweir 	maText(rText),
1443cdf0e10cSrcweir 	mbColHeader(bColHeader),
1444cdf0e10cSrcweir 	mbRowHeader(bRowHeader)
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir }
1447cdf0e10cSrcweir 
~ScAccessiblePreviewHeaderCellTextData()1448cdf0e10cSrcweir ScAccessiblePreviewHeaderCellTextData::~ScAccessiblePreviewHeaderCellTextData()
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir     if (pEditEngine)
1451cdf0e10cSrcweir         pEditEngine->SetNotifyHdl(Link());
1452cdf0e10cSrcweir 	if (mpViewForwarder)
1453cdf0e10cSrcweir 		delete mpViewForwarder;
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1456cdf0e10cSrcweir void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) )
1459cdf0e10cSrcweir 	{
1460cdf0e10cSrcweir 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1461cdf0e10cSrcweir 		if ( nId == SFX_HINT_DYING )
1462cdf0e10cSrcweir 		{
1463cdf0e10cSrcweir 			mpViewShell = NULL;						// invalid now
1464cdf0e10cSrcweir             if (mpViewForwarder)
1465cdf0e10cSrcweir                 mpViewForwarder->SetInvalid();
1466cdf0e10cSrcweir 		}
1467cdf0e10cSrcweir 	}
1468cdf0e10cSrcweir 	ScAccessibleCellBaseTextData::Notify(rBC, rHint);
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir 
Clone() const1471cdf0e10cSrcweir ScAccessibleTextData* ScAccessiblePreviewHeaderCellTextData::Clone() const
1472cdf0e10cSrcweir {
1473cdf0e10cSrcweir 	return new ScAccessiblePreviewHeaderCellTextData(mpViewShell, maText, aCellPos, mbColHeader, mbRowHeader);
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir 
GetTextForwarder()1476cdf0e10cSrcweir SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir 	if (!pEditEngine)
1479cdf0e10cSrcweir 	{
1480cdf0e10cSrcweir 		if ( pDocShell )
1481cdf0e10cSrcweir 		{
1482cdf0e10cSrcweir 			ScDocument* pDoc = pDocShell->GetDocument();
1483cdf0e10cSrcweir 			pEditEngine = pDoc->CreateFieldEditEngine();
1484cdf0e10cSrcweir 		}
1485cdf0e10cSrcweir 		else
1486cdf0e10cSrcweir 		{
1487cdf0e10cSrcweir 			SfxItemPool* pEnginePool = EditEngine::CreatePool();
1488cdf0e10cSrcweir 			pEnginePool->FreezeIdRanges();
1489cdf0e10cSrcweir 			pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
1490cdf0e10cSrcweir 		}
1491cdf0e10cSrcweir 		//	currently, GetPortions doesn't work if UpdateMode is sal_False,
1492cdf0e10cSrcweir 		//	this will be fixed (in EditEngine) by src600
1493cdf0e10cSrcweir //		pEditEngine->SetUpdateMode( sal_False );
1494cdf0e10cSrcweir 		pEditEngine->EnableUndo( sal_False );
1495cdf0e10cSrcweir 		if (pDocShell)
1496cdf0e10cSrcweir 			pEditEngine->SetRefDevice(pDocShell->GetRefDevice());
1497cdf0e10cSrcweir 		else
1498cdf0e10cSrcweir 			pEditEngine->SetRefMapMode( MAP_100TH_MM );
1499cdf0e10cSrcweir 		pForwarder = new SvxEditEngineForwarder(*pEditEngine);
1500cdf0e10cSrcweir 	}
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir 	if (bDataValid)
1503cdf0e10cSrcweir 		return pForwarder;
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir 	if (maText.Len() && pEditEngine)
1506cdf0e10cSrcweir 	{
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir 		if ( mpViewShell  )
1509cdf0e10cSrcweir 		{
1510cdf0e10cSrcweir 			Size aOutputSize;
1511cdf0e10cSrcweir 			Window* pWindow = mpViewShell->GetWindow();
1512cdf0e10cSrcweir 			if ( pWindow )
1513cdf0e10cSrcweir 				aOutputSize = pWindow->GetOutputSizePixel();
1514cdf0e10cSrcweir 			Point aPoint;
1515cdf0e10cSrcweir 			Rectangle aVisRect( aPoint, aOutputSize );
1516cdf0e10cSrcweir 			Size aSize(mpViewShell->GetLocationData().GetHeaderCellOutputRect(aVisRect, aCellPos, mbColHeader).GetSize());
1517cdf0e10cSrcweir 			if (pWindow)
1518cdf0e10cSrcweir 				aSize = pWindow->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
1519cdf0e10cSrcweir 			pEditEngine->SetPaperSize(aSize);
1520cdf0e10cSrcweir 		}
1521cdf0e10cSrcweir 		pEditEngine->SetText( maText );
1522cdf0e10cSrcweir 	}
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir 	bDataValid = sal_True;
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir 	if (pEditEngine)
1527cdf0e10cSrcweir 		pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir 	return pForwarder;
1530cdf0e10cSrcweir }
1531cdf0e10cSrcweir 
GetViewForwarder()1532cdf0e10cSrcweir SvxViewForwarder* ScAccessiblePreviewHeaderCellTextData::GetViewForwarder()
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir 	if (!mpViewForwarder)
1535cdf0e10cSrcweir 		mpViewForwarder = new ScPreviewHeaderCellViewForwarder(mpViewShell, aCellPos, mbColHeader, mbRowHeader);
1536cdf0e10cSrcweir 	return mpViewForwarder;
1537cdf0e10cSrcweir }
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir //UNUSED2008-05  IMPL_LINK(ScAccessiblePreviewHeaderCellTextData, NotifyHdl, EENotify*, aNotify)
1540cdf0e10cSrcweir //UNUSED2008-05  {
1541cdf0e10cSrcweir //UNUSED2008-05      if( aNotify )
1542cdf0e10cSrcweir //UNUSED2008-05      {
1543cdf0e10cSrcweir //UNUSED2008-05          ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify);
1544cdf0e10cSrcweir //UNUSED2008-05
1545cdf0e10cSrcweir //UNUSED2008-05          if( aHint.get() )
1546cdf0e10cSrcweir //UNUSED2008-05              GetBroadcaster().Broadcast( *aHint.get() );
1547cdf0e10cSrcweir //UNUSED2008-05      }
1548cdf0e10cSrcweir //UNUSED2008-05
1549cdf0e10cSrcweir //UNUSED2008-05      return 0;
1550cdf0e10cSrcweir //UNUSED2008-05  }
1551cdf0e10cSrcweir 
GetDocShell(ScPreviewShell * pViewShell)1552cdf0e10cSrcweir ScDocShell* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell* pViewShell)
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir 	ScDocShell* pDocSh = NULL;
1555cdf0e10cSrcweir 	if (pViewShell && pViewShell->GetDocument())
1556cdf0e10cSrcweir 		pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1557cdf0e10cSrcweir 	return pDocSh;
1558cdf0e10cSrcweir }
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir // ============================================================================
1562cdf0e10cSrcweir 
ScAccessibleHeaderTextData(ScPreviewShell * pViewShell,const EditTextObject * pEditObj,sal_Bool bHeader,SvxAdjust eAdjust)1563cdf0e10cSrcweir ScAccessibleHeaderTextData::ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
1564cdf0e10cSrcweir                             const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust)
1565cdf0e10cSrcweir     :
1566cdf0e10cSrcweir     mpViewForwarder(NULL),
1567cdf0e10cSrcweir     mpViewShell(pViewShell),
1568cdf0e10cSrcweir     mpEditEngine(NULL),
1569cdf0e10cSrcweir     mpForwarder(NULL),
1570cdf0e10cSrcweir     mpDocSh(NULL),
1571cdf0e10cSrcweir     mpEditObj(pEditObj),
1572cdf0e10cSrcweir     mbHeader(bHeader),
1573cdf0e10cSrcweir     mbDataValid(sal_False),
1574cdf0e10cSrcweir     meAdjust(eAdjust)
1575cdf0e10cSrcweir {
1576cdf0e10cSrcweir 	if (pViewShell && pViewShell->GetDocument())
1577cdf0e10cSrcweir 		mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1578cdf0e10cSrcweir 	if (mpDocSh)
1579cdf0e10cSrcweir 		mpDocSh->GetDocument()->AddUnoObject(*this);
1580cdf0e10cSrcweir }
1581cdf0e10cSrcweir 
~ScAccessibleHeaderTextData()1582cdf0e10cSrcweir ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData()
1583cdf0e10cSrcweir {
1584cdf0e10cSrcweir 	ScUnoGuard aGuard;		//	needed for EditEngine dtor
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir 	if (mpDocSh)
1587cdf0e10cSrcweir 		mpDocSh->GetDocument()->RemoveUnoObject(*this);
1588cdf0e10cSrcweir     if (mpEditEngine)
1589cdf0e10cSrcweir         mpEditEngine->SetNotifyHdl(Link());
1590cdf0e10cSrcweir 	delete mpEditEngine;
1591cdf0e10cSrcweir 	delete mpForwarder;
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir 
Clone() const1594cdf0e10cSrcweir ScAccessibleTextData* ScAccessibleHeaderTextData::Clone() const
1595cdf0e10cSrcweir {
1596cdf0e10cSrcweir     return new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust);
1597cdf0e10cSrcweir }
1598cdf0e10cSrcweir 
Notify(SfxBroadcaster &,const SfxHint & rHint)1599cdf0e10cSrcweir void ScAccessibleHeaderTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) )
1602cdf0e10cSrcweir 	{
1603cdf0e10cSrcweir 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1604cdf0e10cSrcweir 		if ( nId == SFX_HINT_DYING )
1605cdf0e10cSrcweir 		{
1606cdf0e10cSrcweir 			mpViewShell = NULL;// invalid now
1607cdf0e10cSrcweir             mpDocSh = NULL;
1608cdf0e10cSrcweir             if (mpViewForwarder)
1609cdf0e10cSrcweir                 mpViewForwarder->SetInvalid();
1610cdf0e10cSrcweir 		}
1611cdf0e10cSrcweir 	}
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir 
GetTextForwarder()1614cdf0e10cSrcweir SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder()
1615cdf0e10cSrcweir {
1616cdf0e10cSrcweir 	if (!mpEditEngine)
1617cdf0e10cSrcweir 	{
1618cdf0e10cSrcweir 		SfxItemPool* pEnginePool = EditEngine::CreatePool();
1619cdf0e10cSrcweir 		pEnginePool->FreezeIdRanges();
1620cdf0e10cSrcweir 		ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, sal_True );
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir 		pHdrEngine->EnableUndo( sal_False );
1623cdf0e10cSrcweir 		pHdrEngine->SetRefMapMode( MAP_TWIP );
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 		//	default font must be set, independently of document
1626cdf0e10cSrcweir 		//	-> use global pool from module
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir 		SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() );
1629cdf0e10cSrcweir 		const ScPatternAttr& rPattern = (const ScPatternAttr&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN);
1630cdf0e10cSrcweir 		rPattern.FillEditItemSet( &aDefaults );
1631cdf0e10cSrcweir 		//	FillEditItemSet adjusts font height to 1/100th mm,
1632cdf0e10cSrcweir 		//	but for header/footer twips is needed, as in the PatternAttr:
1633cdf0e10cSrcweir 		aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
1634cdf0e10cSrcweir 		aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
1635cdf0e10cSrcweir 		aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
1636cdf0e10cSrcweir 		aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) );
1637cdf0e10cSrcweir 		pHdrEngine->SetDefaults( aDefaults );
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir 		ScHeaderFieldData aData;
1640cdf0e10cSrcweir         if (mpViewShell)
1641cdf0e10cSrcweir             mpViewShell->FillFieldData(aData);
1642cdf0e10cSrcweir         else
1643cdf0e10cSrcweir 		    ScHeaderFooterTextObj::FillDummyFieldData( aData );
1644cdf0e10cSrcweir 		pHdrEngine->SetData( aData );
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir 		mpEditEngine = pHdrEngine;
1647cdf0e10cSrcweir 		mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1648cdf0e10cSrcweir 	}
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir 	if (mbDataValid)
1651cdf0e10cSrcweir 		return mpForwarder;
1652cdf0e10cSrcweir 
1653cdf0e10cSrcweir 	if ( mpViewShell  )
1654cdf0e10cSrcweir 	{
1655cdf0e10cSrcweir 		Rectangle aVisRect;
1656cdf0e10cSrcweir 		mpViewShell->GetLocationData().GetHeaderPosition(aVisRect);
1657cdf0e10cSrcweir         Size aSize(aVisRect.GetSize());
1658cdf0e10cSrcweir 		Window* pWin = mpViewShell->GetWindow();
1659cdf0e10cSrcweir 		if (pWin)
1660cdf0e10cSrcweir 			aSize = pWin->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1661cdf0e10cSrcweir 		mpEditEngine->SetPaperSize(aSize);
1662cdf0e10cSrcweir 	}
1663cdf0e10cSrcweir 	if (mpEditObj)
1664cdf0e10cSrcweir 		mpEditEngine->SetText(*mpEditObj);
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir 	mbDataValid = sal_True;
1667cdf0e10cSrcweir     return mpForwarder;
1668cdf0e10cSrcweir }
1669cdf0e10cSrcweir 
GetViewForwarder()1670cdf0e10cSrcweir SvxViewForwarder* ScAccessibleHeaderTextData::GetViewForwarder()
1671cdf0e10cSrcweir {
1672cdf0e10cSrcweir 	if (!mpViewForwarder)
1673cdf0e10cSrcweir 		mpViewForwarder = new ScPreviewHeaderFooterViewForwarder(mpViewShell, mbHeader);
1674cdf0e10cSrcweir 	return mpViewForwarder;
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir // ============================================================================
1679cdf0e10cSrcweir 
ScAccessibleNoteTextData(ScPreviewShell * pViewShell,const String & sText,const ScAddress & aCellPos,sal_Bool bMarkNote)1680cdf0e10cSrcweir ScAccessibleNoteTextData::ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
1681cdf0e10cSrcweir                             const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote)
1682cdf0e10cSrcweir     :
1683cdf0e10cSrcweir     mpViewForwarder(NULL),
1684cdf0e10cSrcweir     mpViewShell(pViewShell),
1685cdf0e10cSrcweir     mpEditEngine(NULL),
1686cdf0e10cSrcweir     mpForwarder(NULL),
1687cdf0e10cSrcweir     mpDocSh(NULL),
1688cdf0e10cSrcweir     msText(sText),
1689cdf0e10cSrcweir     maCellPos(aCellPos),
1690cdf0e10cSrcweir     mbMarkNote(bMarkNote),
1691cdf0e10cSrcweir     mbDataValid(sal_False)
1692cdf0e10cSrcweir {
1693cdf0e10cSrcweir 	if (pViewShell && pViewShell->GetDocument())
1694cdf0e10cSrcweir 		mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1695cdf0e10cSrcweir 	if (mpDocSh)
1696cdf0e10cSrcweir 		mpDocSh->GetDocument()->AddUnoObject(*this);
1697cdf0e10cSrcweir }
1698cdf0e10cSrcweir 
~ScAccessibleNoteTextData()1699cdf0e10cSrcweir ScAccessibleNoteTextData::~ScAccessibleNoteTextData()
1700cdf0e10cSrcweir {
1701cdf0e10cSrcweir 	ScUnoGuard aGuard;		//	needed for EditEngine dtor
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir 	if (mpDocSh)
1704cdf0e10cSrcweir 		mpDocSh->GetDocument()->RemoveUnoObject(*this);
1705cdf0e10cSrcweir     if (mpEditEngine)
1706cdf0e10cSrcweir         mpEditEngine->SetNotifyHdl(Link());
1707cdf0e10cSrcweir 	delete mpEditEngine;
1708cdf0e10cSrcweir 	delete mpForwarder;
1709cdf0e10cSrcweir }
1710cdf0e10cSrcweir 
Clone() const1711cdf0e10cSrcweir ScAccessibleTextData* ScAccessibleNoteTextData::Clone() const
1712cdf0e10cSrcweir {
1713cdf0e10cSrcweir     return new ScAccessibleNoteTextData(mpViewShell, msText, maCellPos, mbMarkNote);
1714cdf0e10cSrcweir }
1715cdf0e10cSrcweir 
Notify(SfxBroadcaster &,const SfxHint & rHint)1716cdf0e10cSrcweir void ScAccessibleNoteTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) )
1719cdf0e10cSrcweir 	{
1720cdf0e10cSrcweir 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1721cdf0e10cSrcweir 		if ( nId == SFX_HINT_DYING )
1722cdf0e10cSrcweir 		{
1723cdf0e10cSrcweir 			mpViewShell = NULL;// invalid now
1724cdf0e10cSrcweir             mpDocSh = NULL;
1725cdf0e10cSrcweir             if (mpViewForwarder)
1726cdf0e10cSrcweir                 mpViewForwarder->SetInvalid();
1727cdf0e10cSrcweir 		}
1728cdf0e10cSrcweir 	}
1729cdf0e10cSrcweir }
1730cdf0e10cSrcweir 
GetTextForwarder()1731cdf0e10cSrcweir SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder()
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir 	if (!mpEditEngine)
1734cdf0e10cSrcweir 	{
1735cdf0e10cSrcweir 		if ( mpDocSh )
1736cdf0e10cSrcweir 		{
1737cdf0e10cSrcweir 			ScDocument* pDoc = mpDocSh->GetDocument();
1738cdf0e10cSrcweir 			mpEditEngine = pDoc->CreateFieldEditEngine();
1739cdf0e10cSrcweir 		}
1740cdf0e10cSrcweir 		else
1741cdf0e10cSrcweir 		{
1742cdf0e10cSrcweir 			SfxItemPool* pEnginePool = EditEngine::CreatePool();
1743cdf0e10cSrcweir 			pEnginePool->FreezeIdRanges();
1744cdf0e10cSrcweir 			mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
1745cdf0e10cSrcweir 		}
1746cdf0e10cSrcweir 		//	currently, GetPortions doesn't work if UpdateMode is sal_False,
1747cdf0e10cSrcweir 		//	this will be fixed (in EditEngine) by src600
1748cdf0e10cSrcweir //		pEditEngine->SetUpdateMode( sal_False );
1749cdf0e10cSrcweir 		mpEditEngine->EnableUndo( sal_False );
1750cdf0e10cSrcweir 		if (mpDocSh)
1751cdf0e10cSrcweir 			mpEditEngine->SetRefDevice(mpDocSh->GetRefDevice());
1752cdf0e10cSrcweir 		else
1753cdf0e10cSrcweir 			mpEditEngine->SetRefMapMode( MAP_100TH_MM );
1754cdf0e10cSrcweir 		mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1755cdf0e10cSrcweir 	}
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir 	if (mbDataValid)
1758cdf0e10cSrcweir 		return mpForwarder;
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir 	if (msText.Len() && mpEditEngine)
1761cdf0e10cSrcweir 	{
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir 		if ( mpViewShell  )
1764cdf0e10cSrcweir 		{
1765cdf0e10cSrcweir 			Size aOutputSize;
1766cdf0e10cSrcweir 			Window* pWindow = mpViewShell->GetWindow();
1767cdf0e10cSrcweir 			if ( pWindow )
1768cdf0e10cSrcweir 				aOutputSize = pWindow->GetOutputSizePixel();
1769cdf0e10cSrcweir 			Point aPoint;
1770cdf0e10cSrcweir 			Rectangle aVisRect( aPoint, aOutputSize );
1771cdf0e10cSrcweir 			Size aSize(mpViewShell->GetLocationData().GetNoteInRangeOutputRect(aVisRect, mbMarkNote, maCellPos).GetSize());
1772cdf0e10cSrcweir 			if (pWindow)
1773cdf0e10cSrcweir 				aSize = pWindow->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1774cdf0e10cSrcweir 			mpEditEngine->SetPaperSize(aSize);
1775cdf0e10cSrcweir 		}
1776cdf0e10cSrcweir 		mpEditEngine->SetText( msText );
1777cdf0e10cSrcweir 	}
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir 	mbDataValid = sal_True;
1780cdf0e10cSrcweir 
1781cdf0e10cSrcweir 	if (mpEditEngine)
1782cdf0e10cSrcweir 		mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
1783cdf0e10cSrcweir 
1784cdf0e10cSrcweir 	return mpForwarder;
1785cdf0e10cSrcweir }
1786cdf0e10cSrcweir 
GetViewForwarder()1787cdf0e10cSrcweir SvxViewForwarder* ScAccessibleNoteTextData::GetViewForwarder()
1788cdf0e10cSrcweir {
1789cdf0e10cSrcweir 	if (!mpViewForwarder)
1790cdf0e10cSrcweir 		mpViewForwarder = new ScPreviewNoteViewForwarder(mpViewShell, maCellPos, mbMarkNote);
1791cdf0e10cSrcweir 	return mpViewForwarder;
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir // CSV import =================================================================
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir class ScCsvViewForwarder : public SvxViewForwarder
1798cdf0e10cSrcweir {
1799cdf0e10cSrcweir     Rectangle                   maBoundBox;
1800cdf0e10cSrcweir     Window*                     mpWindow;
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir public:
1803cdf0e10cSrcweir     explicit                    ScCsvViewForwarder( Window* pWindow, const Rectangle& rBoundBox );
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir     virtual sal_Bool                IsValid() const;
1806cdf0e10cSrcweir     virtual Rectangle           GetVisArea() const;
1807cdf0e10cSrcweir     virtual Point               LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
1808cdf0e10cSrcweir     virtual Point               PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir     void                        SetInvalid();
1811cdf0e10cSrcweir };
1812cdf0e10cSrcweir 
ScCsvViewForwarder(Window * pWindow,const Rectangle & rBoundBox)1813cdf0e10cSrcweir ScCsvViewForwarder::ScCsvViewForwarder( Window* pWindow, const Rectangle& rBoundBox ) :
1814cdf0e10cSrcweir     maBoundBox( rBoundBox ),
1815cdf0e10cSrcweir     mpWindow( pWindow )
1816cdf0e10cSrcweir {
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir 
IsValid() const1819cdf0e10cSrcweir sal_Bool ScCsvViewForwarder::IsValid() const
1820cdf0e10cSrcweir {
1821cdf0e10cSrcweir     return mpWindow != NULL;
1822cdf0e10cSrcweir }
1823cdf0e10cSrcweir 
GetVisArea() const1824cdf0e10cSrcweir Rectangle ScCsvViewForwarder::GetVisArea() const
1825cdf0e10cSrcweir {
1826cdf0e10cSrcweir     return maBoundBox;
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir 
LogicToPixel(const Point & rPoint,const MapMode & rMapMode) const1829cdf0e10cSrcweir Point ScCsvViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1830cdf0e10cSrcweir {
1831cdf0e10cSrcweir     if( !mpWindow ) return Point();
1832cdf0e10cSrcweir     return mpWindow->LogicToPixel( rPoint, rMapMode );
1833cdf0e10cSrcweir }
1834cdf0e10cSrcweir 
PixelToLogic(const Point & rPoint,const MapMode & rMapMode) const1835cdf0e10cSrcweir Point ScCsvViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1836cdf0e10cSrcweir {
1837cdf0e10cSrcweir     if( !mpWindow ) return Point();
1838cdf0e10cSrcweir     return mpWindow->PixelToLogic( rPoint, rMapMode );
1839cdf0e10cSrcweir }
1840cdf0e10cSrcweir 
SetInvalid()1841cdf0e10cSrcweir void ScCsvViewForwarder::SetInvalid()
1842cdf0e10cSrcweir {
1843cdf0e10cSrcweir     mpWindow = NULL;
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir 
1846cdf0e10cSrcweir // ----------------------------------------------------------------------------
1847cdf0e10cSrcweir 
ScAccessibleCsvTextData(Window * pWindow,EditEngine * pEditEngine,const String & rCellText,const Rectangle & rBoundBox,const Size & rCellSize)1848cdf0e10cSrcweir ScAccessibleCsvTextData::ScAccessibleCsvTextData(
1849cdf0e10cSrcweir         Window* pWindow, EditEngine* pEditEngine,
1850cdf0e10cSrcweir         const String& rCellText, const Rectangle& rBoundBox, const Size& rCellSize ) :
1851cdf0e10cSrcweir     mpWindow( pWindow ),
1852cdf0e10cSrcweir     mpEditEngine( pEditEngine ),
1853cdf0e10cSrcweir     maCellText( rCellText ),
1854cdf0e10cSrcweir     maBoundBox( rBoundBox ),
1855cdf0e10cSrcweir     maCellSize( rCellSize )
1856cdf0e10cSrcweir {
1857cdf0e10cSrcweir }
1858cdf0e10cSrcweir 
~ScAccessibleCsvTextData()1859cdf0e10cSrcweir ScAccessibleCsvTextData::~ScAccessibleCsvTextData()
1860cdf0e10cSrcweir {
1861cdf0e10cSrcweir }
1862cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1863cdf0e10cSrcweir void ScAccessibleCsvTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1864cdf0e10cSrcweir {
1865cdf0e10cSrcweir     if ( rHint.ISA( SfxSimpleHint ) )
1866cdf0e10cSrcweir     {
1867cdf0e10cSrcweir         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1868cdf0e10cSrcweir         if( nId == SFX_HINT_DYING )
1869cdf0e10cSrcweir         {
1870cdf0e10cSrcweir             mpWindow = NULL;
1871cdf0e10cSrcweir             mpEditEngine = NULL;
1872cdf0e10cSrcweir             if (mpViewForwarder.get())
1873cdf0e10cSrcweir                 mpViewForwarder->SetInvalid();
1874cdf0e10cSrcweir         }
1875cdf0e10cSrcweir     }
1876cdf0e10cSrcweir     ScAccessibleTextData::Notify( rBC, rHint );
1877cdf0e10cSrcweir }
1878cdf0e10cSrcweir 
Clone() const1879cdf0e10cSrcweir ScAccessibleTextData* ScAccessibleCsvTextData::Clone() const
1880cdf0e10cSrcweir {
1881cdf0e10cSrcweir     return new ScAccessibleCsvTextData( mpWindow, mpEditEngine, maCellText, maBoundBox, maCellSize );
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir 
GetTextForwarder()1884cdf0e10cSrcweir SvxTextForwarder* ScAccessibleCsvTextData::GetTextForwarder()
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir     if( mpEditEngine )
1887cdf0e10cSrcweir     {
1888cdf0e10cSrcweir         mpEditEngine->SetPaperSize( maCellSize );
1889cdf0e10cSrcweir         mpEditEngine->SetText( maCellText );
1890cdf0e10cSrcweir         if( !mpTextForwarder.get() )
1891cdf0e10cSrcweir             mpTextForwarder.reset( new SvxEditEngineForwarder( *mpEditEngine ) );
1892cdf0e10cSrcweir     }
1893cdf0e10cSrcweir     else
1894*3d762826SHerbert Dürr         mpTextForwarder.reset();
1895cdf0e10cSrcweir     return mpTextForwarder.get();
1896cdf0e10cSrcweir }
1897cdf0e10cSrcweir 
GetViewForwarder()1898cdf0e10cSrcweir SvxViewForwarder* ScAccessibleCsvTextData::GetViewForwarder()
1899cdf0e10cSrcweir {
1900cdf0e10cSrcweir     if( !mpViewForwarder.get() )
1901cdf0e10cSrcweir         mpViewForwarder.reset( new ScCsvViewForwarder( mpWindow, maBoundBox ) );
1902cdf0e10cSrcweir     return mpViewForwarder.get();
1903cdf0e10cSrcweir }
1904cdf0e10cSrcweir 
GetEditViewForwarder(sal_Bool)1905cdf0e10cSrcweir SvxEditViewForwarder* ScAccessibleCsvTextData::GetEditViewForwarder( sal_Bool /* bCreate */ )
1906cdf0e10cSrcweir {
1907cdf0e10cSrcweir     return NULL;
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir 
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir // ============================================================================
1912cdf0e10cSrcweir 
1913