1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "scitems.hxx"
22 #include <editeng/eeitem.hxx>
25 #include "AccessibleText.hxx"
26 #include "AccessibleCell.hxx"
27 #include "tabvwsh.hxx"
28 #include "editutil.hxx"
29 #include "document.hxx"
31 #include "prevwsh.hxx"
33 #include "prevloc.hxx"
34 #include "patattr.hxx"
35 #include "inputwin.hxx"
36 #include <editeng/unofored.hxx>
37 #include <editeng/editview.hxx>
38 #include <editeng/unoedhlp.hxx>
39 #include <vcl/virdev.hxx>
40 #include <editeng/editobj.hxx>
41 #include <editeng/adjustitem.hxx>
42 #include <editeng/justifyitem.hxx>
43 #include <svx/svdmodel.hxx>
44 #include <svx/algitem.hxx>
45 #include <vcl/svapp.hxx>
48 class ScViewForwarder
: public SvxViewForwarder
50 ScTabViewShell
* mpViewShell
;
52 ScSplitPos meSplitPos
;
54 ScViewForwarder(ScTabViewShell
* pViewShell
, ScSplitPos eSplitPos
, const ScAddress
& rCell
);
55 virtual ~ScViewForwarder();
57 virtual bool IsValid() const SAL_OVERRIDE
;
58 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
59 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
60 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
65 ScViewForwarder::ScViewForwarder(ScTabViewShell
* pViewShell
, ScSplitPos eSplitPos
, const ScAddress
& rCell
)
67 mpViewShell(pViewShell
),
73 ScViewForwarder::~ScViewForwarder()
77 bool ScViewForwarder::IsValid() const
79 return mpViewShell
!= NULL
;
82 Rectangle
ScViewForwarder::GetVisArea() const
87 Window
* pWindow
= mpViewShell
->GetWindowByPos(meSplitPos
);
90 aVisArea
.SetSize(pWindow
->GetSizePixel());
92 ScHSplitPos eWhichH
= ((meSplitPos
== SC_SPLIT_TOPLEFT
) || (meSplitPos
== SC_SPLIT_BOTTOMLEFT
)) ?
93 SC_SPLIT_LEFT
: SC_SPLIT_RIGHT
;
94 ScVSplitPos eWhichV
= ((meSplitPos
== SC_SPLIT_TOPLEFT
) || (meSplitPos
== SC_SPLIT_TOPRIGHT
)) ?
95 SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
;
97 Point
aBaseCellPos(mpViewShell
->GetViewData()->GetScrPos(mpViewShell
->GetViewData()->GetPosX(eWhichH
),
98 mpViewShell
->GetViewData()->GetPosY(eWhichV
), meSplitPos
, true));
99 Point
aCellPos(mpViewShell
->GetViewData()->GetScrPos(maCellPos
.Col(), maCellPos
.Row(), meSplitPos
, true));
100 aVisArea
.SetPos(aCellPos
- aBaseCellPos
);
105 OSL_FAIL("this ViewForwarder is not valid");
110 Point
ScViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
114 Window
* pWindow
= mpViewShell
->GetWindowByPos(meSplitPos
);
116 return pWindow
->LogicToPixel( rPoint
, rMapMode
);
120 OSL_FAIL("this ViewForwarder is not valid");
125 Point
ScViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
129 Window
* pWindow
= mpViewShell
->GetWindowByPos(meSplitPos
);
131 return pWindow
->PixelToLogic( rPoint
, rMapMode
);
135 OSL_FAIL("this ViewForwarder is not valid");
140 void ScViewForwarder::SetInvalid()
145 class ScEditObjectViewForwarder
: public SvxViewForwarder
148 // #i49561# EditView needed for access to its visible area.
149 const EditView
* mpEditView
;
151 ScEditObjectViewForwarder( Window
* pWindow
,
152 const EditView
* _pEditView
);
153 virtual ~ScEditObjectViewForwarder();
155 virtual bool IsValid() const SAL_OVERRIDE
;
156 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
157 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
158 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
163 ScEditObjectViewForwarder::ScEditObjectViewForwarder( Window
* pWindow
,
164 const EditView
* _pEditView
)
167 mpEditView( _pEditView
)
171 ScEditObjectViewForwarder::~ScEditObjectViewForwarder()
175 bool ScEditObjectViewForwarder::IsValid() const
177 return (mpWindow
!= NULL
);
180 Rectangle
ScEditObjectViewForwarder::GetVisArea() const
185 Rectangle
aVisRect(mpWindow
->GetWindowExtentsRelative(mpWindow
->GetAccessibleParentWindow()));
187 aVisRect
.SetPos(Point(0, 0));
193 OSL_FAIL("this ViewForwarder is not valid");
198 Point
ScEditObjectViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
202 // #i49561# - consider offset of the visible area
203 // of the EditView before converting point to pixel.
204 Point
aPoint( rPoint
);
207 Rectangle
aEditViewVisArea( mpEditView
->GetVisArea() );
208 aPoint
+= aEditViewVisArea
.TopLeft();
210 return mpWindow
->LogicToPixel( aPoint
, rMapMode
);
214 OSL_FAIL("this ViewForwarder is not valid");
219 Point
ScEditObjectViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
223 // #i49561# - consider offset of the visible area
224 // of the EditView after converting point to logic.
225 Point
aPoint( mpWindow
->PixelToLogic( rPoint
, rMapMode
) );
228 Rectangle
aEditViewVisArea( mpEditView
->GetVisArea() );
229 aPoint
-= aEditViewVisArea
.TopLeft();
235 OSL_FAIL("this ViewForwarder is not valid");
240 void ScEditObjectViewForwarder::SetInvalid()
245 class ScPreviewViewForwarder
: public SvxViewForwarder
248 ScPreviewShell
* mpViewShell
;
249 mutable ScPreviewTableInfo
* mpTableInfo
;
251 ScPreviewViewForwarder(ScPreviewShell
* pViewShell
);
252 virtual ~ScPreviewViewForwarder();
254 virtual bool IsValid() const SAL_OVERRIDE
;
255 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
256 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
257 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
261 Rectangle
GetVisRect() const;
263 // clips the VisArea and calculates with the negativ coordinates
264 Rectangle
CorrectVisArea(const Rectangle
& rVisArea
) const;
267 ScPreviewViewForwarder::ScPreviewViewForwarder(ScPreviewShell
* pViewShell
)
269 mpViewShell(pViewShell
),
274 ScPreviewViewForwarder::~ScPreviewViewForwarder()
279 bool ScPreviewViewForwarder::IsValid() const
281 return mpViewShell
!= NULL
;
284 Rectangle
ScPreviewViewForwarder::GetVisArea() const
287 OSL_FAIL("should be implemented in an abrevated class");
291 Point
ScPreviewViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
295 Window
* pWindow
= mpViewShell
->GetWindow();
298 MapMode
aMapMode(pWindow
->GetMapMode().GetMapUnit());
299 Point
aPoint2( OutputDevice::LogicToLogic( rPoint
, rMapMode
, aMapMode
) );
300 return pWindow
->LogicToPixel(aPoint2
);
305 OSL_FAIL("this ViewForwarder is not valid");
310 Point
ScPreviewViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
314 Window
* pWindow
= mpViewShell
->GetWindow();
317 MapMode
aMapMode(pWindow
->GetMapMode());
318 aMapMode
.SetOrigin(Point());
319 Point
aPoint1( pWindow
->PixelToLogic( rPoint
) );
320 Point
aPoint2( OutputDevice::LogicToLogic( aPoint1
,
321 aMapMode
.GetMapUnit(),
328 OSL_FAIL("this ViewForwarder is not valid");
333 void ScPreviewViewForwarder::SetInvalid()
338 Rectangle
ScPreviewViewForwarder::GetVisRect() const
343 Window
* pWindow
= mpViewShell
->GetWindow();
345 aOutputSize
= pWindow
->GetOutputSizePixel();
347 Rectangle
aVisRect( aPoint
, aOutputSize
);
353 Rectangle
ScPreviewViewForwarder::CorrectVisArea(const Rectangle
& rVisArea
) const
355 Rectangle
aVisArea(rVisArea
);
356 Point aPos
= aVisArea
.TopLeft(); // get first the position to remember negative positions after clipping
358 Window
* pWin
= mpViewShell
->GetWindow();
360 aVisArea
= pWin
->GetWindowExtentsRelative(pWin
).GetIntersection(aVisArea
);
362 sal_Int32
nX(aPos
.getX());
363 sal_Int32
nY(aPos
.getY());
373 aVisArea
.SetPos(Point(nX
, nY
));
378 class ScPreviewHeaderFooterViewForwarder
: public ScPreviewViewForwarder
382 ScPreviewHeaderFooterViewForwarder(ScPreviewShell
* pViewShell
, bool bHeader
);
383 virtual ~ScPreviewHeaderFooterViewForwarder();
385 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
388 ScPreviewHeaderFooterViewForwarder::ScPreviewHeaderFooterViewForwarder(ScPreviewShell
* pViewShell
, bool bHeader
)
390 ScPreviewViewForwarder(pViewShell
),
395 ScPreviewHeaderFooterViewForwarder::~ScPreviewHeaderFooterViewForwarder()
399 Rectangle
ScPreviewHeaderFooterViewForwarder::GetVisArea() const
404 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
406 rData
.GetHeaderPosition( aVisArea
);
408 rData
.GetFooterPosition( aVisArea
);
410 aVisArea
= CorrectVisArea(aVisArea
);
414 OSL_FAIL("this ViewForwarder is not valid");
419 class ScPreviewCellViewForwarder
: public ScPreviewViewForwarder
423 ScPreviewCellViewForwarder(ScPreviewShell
* pViewShell
,
425 virtual ~ScPreviewCellViewForwarder();
427 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
430 ScPreviewCellViewForwarder::ScPreviewCellViewForwarder(ScPreviewShell
* pViewShell
,
433 ScPreviewViewForwarder(pViewShell
),
438 ScPreviewCellViewForwarder::~ScPreviewCellViewForwarder()
442 Rectangle
ScPreviewCellViewForwarder::GetVisArea() const
447 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
448 aVisArea
= rData
.GetCellOutputRect(maCellPos
);
450 aVisArea
= CorrectVisArea(aVisArea
);
454 OSL_FAIL("this ViewForwarder is not valid");
459 class ScPreviewHeaderCellViewForwarder
: public ScPreviewViewForwarder
464 ScPreviewHeaderCellViewForwarder(ScPreviewShell
* pViewShell
,
467 virtual ~ScPreviewHeaderCellViewForwarder();
469 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
472 ScPreviewHeaderCellViewForwarder::ScPreviewHeaderCellViewForwarder(ScPreviewShell
* pViewShell
,
476 ScPreviewViewForwarder(pViewShell
),
478 mbColHeader(bColHeader
)
482 ScPreviewHeaderCellViewForwarder::~ScPreviewHeaderCellViewForwarder()
486 Rectangle
ScPreviewHeaderCellViewForwarder::GetVisArea() const
491 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
492 aVisArea
= rData
.GetHeaderCellOutputRect(GetVisRect(), maCellPos
, mbColHeader
);
494 aVisArea
= CorrectVisArea(aVisArea
);
498 OSL_FAIL("this ViewForwarder is not valid");
503 class ScPreviewNoteViewForwarder
: public ScPreviewViewForwarder
508 ScPreviewNoteViewForwarder(ScPreviewShell
* pViewShell
,
511 virtual ~ScPreviewNoteViewForwarder();
513 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
516 ScPreviewNoteViewForwarder::ScPreviewNoteViewForwarder(ScPreviewShell
* pViewShell
,
520 ScPreviewViewForwarder(pViewShell
),
522 mbNoteMark(bNoteMark
)
526 ScPreviewNoteViewForwarder::~ScPreviewNoteViewForwarder()
530 Rectangle
ScPreviewNoteViewForwarder::GetVisArea() const
535 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
536 aVisArea
= rData
.GetNoteInRangeOutputRect(GetVisRect(), mbNoteMark
, maCellPos
);
538 aVisArea
= CorrectVisArea(aVisArea
);
542 OSL_FAIL("this ViewForwarder is not valid");
547 class ScEditViewForwarder
: public SvxEditViewForwarder
549 EditView
* mpEditView
;
552 ScEditViewForwarder(EditView
* pEditView
, Window
* pWin
);
553 virtual ~ScEditViewForwarder();
555 virtual bool IsValid() const SAL_OVERRIDE
;
556 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
557 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
558 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
559 virtual bool GetSelection( ESelection
& rSelection
) const SAL_OVERRIDE
;
560 virtual bool SetSelection( const ESelection
& rSelection
) SAL_OVERRIDE
;
561 virtual bool Copy() SAL_OVERRIDE
;
562 virtual bool Cut() SAL_OVERRIDE
;
563 virtual bool Paste() SAL_OVERRIDE
;
570 ScEditViewForwarder::ScEditViewForwarder(EditView
* pEditView
, Window
* pWin
)
571 : mpEditView(pEditView
),
577 ScEditViewForwarder::~ScEditViewForwarder()
581 bool ScEditViewForwarder::IsValid() const
583 return mpWindow
&& mpEditView
;
586 Rectangle
ScEditViewForwarder::GetVisArea() const
589 if (IsValid() && mpEditView
->GetEditEngine())
591 MapMode
aMapMode(mpEditView
->GetEditEngine()->GetRefMapMode());
593 aVisArea
= mpWindow
->LogicToPixel( mpEditView
->GetVisArea(), aMapMode
);
597 OSL_FAIL("this EditViewForwarder is no longer valid");
602 Point
ScEditViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
605 return mpWindow
->LogicToPixel( rPoint
, rMapMode
);
608 OSL_FAIL("this ViewForwarder is not valid");
613 Point
ScEditViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
616 return mpWindow
->PixelToLogic( rPoint
, rMapMode
);
619 OSL_FAIL("this ViewForwarder is not valid");
624 bool ScEditViewForwarder::GetSelection( ESelection
& rSelection
) const
629 rSelection
= mpEditView
->GetSelection();
634 OSL_FAIL("this ViewForwarder is not valid");
639 bool ScEditViewForwarder::SetSelection( const ESelection
& rSelection
)
644 mpEditView
->SetSelection(rSelection
);
649 OSL_FAIL("this ViewForwarder is not valid");
654 bool ScEditViewForwarder::Copy()
664 OSL_FAIL("this ViewForwarder is not valid");
669 bool ScEditViewForwarder::Cut()
679 OSL_FAIL("this ViewForwarder is not valid");
684 bool ScEditViewForwarder::Paste()
694 OSL_FAIL("this ViewForwarder is not valid");
699 void ScEditViewForwarder::GrabFocus()
703 void ScEditViewForwarder::SetInvalid()
709 // ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
711 ScAccessibleCellTextData::ScAccessibleCellTextData(ScTabViewShell
* pViewShell
,
712 const ScAddress
& rP
, ScSplitPos eSplitPos
, ScAccessibleCell
* pAccCell
)
713 : ScAccessibleCellBaseTextData(GetDocShell(pViewShell
), rP
),
714 mpViewForwarder(NULL
),
715 mpEditViewForwarder(NULL
),
716 mpViewShell(pViewShell
),
717 meSplitPos(eSplitPos
),
718 mpAccessibleCell( pAccCell
)
722 ScAccessibleCellTextData::~ScAccessibleCellTextData()
725 pEditEngine
->SetNotifyHdl(Link());
727 delete mpViewForwarder
;
728 if (mpEditViewForwarder
)
729 delete mpEditViewForwarder
;
732 void ScAccessibleCellTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
734 if ( rHint
.ISA( SfxSimpleHint
) )
736 sal_uLong nId
= ((const SfxSimpleHint
&)rHint
).GetId();
737 if ( nId
== SFX_HINT_DYING
)
739 mpViewShell
= NULL
; // invalid now
741 mpViewForwarder
->SetInvalid();
742 if (mpEditViewForwarder
)
743 mpEditViewForwarder
->SetInvalid();
746 ScAccessibleCellBaseTextData::Notify(rBC
, rHint
);
749 ScAccessibleTextData
* ScAccessibleCellTextData::Clone() const
751 return new ScAccessibleCellTextData( mpViewShell
, aCellPos
, meSplitPos
, mpAccessibleCell
);
754 void ScAccessibleCellTextData::GetCellText(const ScAddress
& rCellPos
, OUString
& rText
)
756 // #104893#; don't use the input string
757 // ScCellTextData::GetCellText(rCellPos, rText);
758 ScDocument
* pDoc
= pDocShell
->GetDocument();
761 // #104893#; use the displayed string
762 rText
= pDoc
->GetString(rCellPos
.Col(), rCellPos
.Row(), rCellPos
.Tab());
765 const ScViewOptions
& aOptions
= mpViewShell
->GetViewData()->GetOptions();
767 pDoc
->GetCellType(rCellPos
.Col(), rCellPos
.Row(), rCellPos
.Tab(), aCellType
);
768 if (aCellType
== CELLTYPE_FORMULA
&& aOptions
.GetOption( VOPT_FORMULAS
))
770 pDoc
->GetFormula( rCellPos
.Col(), rCellPos
.Row(), rCellPos
.Tab(), rText
);
772 else if (!aOptions
.GetOption( VOPT_NULLVALS
))
774 if ((aCellType
== CELLTYPE_VALUE
|| aCellType
== CELLTYPE_FORMULA
) && pDoc
->GetValue(rCellPos
) == 0.0)
781 SvxTextForwarder
* ScAccessibleCellTextData::GetTextForwarder()
783 ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
785 ScDocument
* pDoc
= ( pDocShell
? pDocShell
->GetDocument() : NULL
);
786 if ( pDoc
&& pEditEngine
&& mpViewShell
)
789 mpViewShell
->GetViewData()->GetMergeSizePixel(
790 aCellPos
.Col(), aCellPos
.Row(), nSizeX
, nSizeY
);
792 Size
aSize(nSizeX
, nSizeY
);
794 // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
796 const SvxHorJustifyItem
* pHorJustifyItem
= static_cast< const SvxHorJustifyItem
* >(
797 pDoc
->GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_HOR_JUSTIFY
) );
798 SvxCellHorJustify eHorJust
= ( pHorJustifyItem
? static_cast< SvxCellHorJustify
>( pHorJustifyItem
->GetValue() ) : SVX_HOR_JUSTIFY_STANDARD
);
799 if ( eHorJust
== SVX_HOR_JUSTIFY_LEFT
)
801 const SfxUInt16Item
* pIndentItem
= static_cast< const SfxUInt16Item
* >(
802 pDoc
->GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_INDENT
) );
805 nIndent
= static_cast< long >( pIndentItem
->GetValue() );
809 const SvxMarginItem
* pMarginItem
= static_cast< const SvxMarginItem
* >(
810 pDoc
->GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_MARGIN
) );
811 ScViewData
* pViewData
= mpViewShell
->GetViewData();
812 double nPPTX
= ( pViewData
? pViewData
->GetPPTX() : 0 );
813 double nPPTY
= ( pViewData
? pViewData
->GetPPTY() : 0 );
814 long nLeftM
= ( pMarginItem
? static_cast< long >( ( pMarginItem
->GetLeftMargin() + nIndent
) * nPPTX
) : 0 );
815 long nTopM
= ( pMarginItem
? static_cast< long >( pMarginItem
->GetTopMargin() * nPPTY
) : 0 );
816 long nRightM
= ( pMarginItem
? static_cast< long >( pMarginItem
->GetRightMargin() * nPPTX
) : 0 );
817 long nBottomM
= ( pMarginItem
? static_cast< long >( pMarginItem
->GetBottomMargin() * nPPTY
) : 0 );
818 long nWidth
= aSize
.getWidth() - nLeftM
- nRightM
;
819 aSize
.setWidth( nWidth
);
820 aSize
.setHeight( aSize
.getHeight() - nTopM
- nBottomM
);
822 Window
* pWin
= mpViewShell
->GetWindowByPos( meSplitPos
);
825 aSize
= pWin
->PixelToLogic( aSize
, pEditEngine
->GetRefMapMode() );
828 /* #i19430# Gnopernicus reads text partly if it sticks out of the cell
829 boundaries. This leads to wrong results in cases where the cell text
830 is rotated, because rotation is not taken into account when calcu-
831 lating the visible part of the text. In these cases we will expand
832 the cell size passed as paper size to the edit engine. The function
833 accessibility::AccessibleStaticTextBase::GetParagraphBoundingBox()
834 (see svx/source/accessibility/AccessibleStaticTextBase.cxx) will
835 return the size of the complete text then, which is used to expand
836 the cell bounding box in ScAccessibleCell::GetBoundingBox()
837 (see sc/source/ui/Accessibility/AccessibleCell.cxx). */
838 const SfxInt32Item
* pItem
= static_cast< const SfxInt32Item
* >(
839 pDoc
->GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_ROTATE_VALUE
) );
840 if( pItem
&& (pItem
->GetValue() != 0) )
842 pEditEngine
->SetPaperSize( Size( LONG_MAX
, aSize
.getHeight() ) );
843 long nTxtWidth
= static_cast< long >( pEditEngine
->CalcTextWidth() );
844 aSize
.setWidth( std::max( aSize
.getWidth(), nTxtWidth
+ 2 ) );
848 // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
849 const SfxBoolItem
* pLineBreakItem
= static_cast< const SfxBoolItem
* >(
850 pDoc
->GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_LINEBREAK
) );
851 bool bLineBreak
= ( pLineBreakItem
&& pLineBreakItem
->GetValue() );
854 long nTxtWidth
= static_cast< long >( pEditEngine
->CalcTextWidth() );
855 aSize
.setWidth( ::std::max( aSize
.getWidth(), nTxtWidth
) );
859 pEditEngine
->SetPaperSize( aSize
);
861 // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
862 if ( eHorJust
== SVX_HOR_JUSTIFY_STANDARD
&& pDoc
->HasValueData( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab() ) )
864 pEditEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
870 aTextSize
= pWin
->LogicToPixel( Size( pEditEngine
->CalcTextWidth(), pEditEngine
->GetTextHeight() ), pEditEngine
->GetRefMapMode() );
872 long nTextWidth
= aTextSize
.Width();
873 long nTextHeight
= aTextSize
.Height();
875 long nOffsetX
= nLeftM
;
876 long nDiffX
= nTextWidth
- nWidth
;
881 case SVX_HOR_JUSTIFY_RIGHT
:
886 case SVX_HOR_JUSTIFY_CENTER
:
888 nOffsetX
-= nDiffX
/ 2;
899 const SvxVerJustifyItem
* pVerJustifyItem
= static_cast< const SvxVerJustifyItem
* >(
900 pDoc
->GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_VER_JUSTIFY
) );
901 SvxCellVerJustify eVerJust
= ( pVerJustifyItem
? static_cast< SvxCellVerJustify
>( pVerJustifyItem
->GetValue() ) : SVX_VER_JUSTIFY_STANDARD
);
904 case SVX_VER_JUSTIFY_STANDARD
:
905 case SVX_VER_JUSTIFY_BOTTOM
:
907 nOffsetY
= nSizeY
- nBottomM
- nTextHeight
;
910 case SVX_VER_JUSTIFY_CENTER
:
912 nOffsetY
= ( nSizeY
- nTopM
- nBottomM
- nTextHeight
) / 2 + nTopM
;
922 if ( mpAccessibleCell
)
924 mpAccessibleCell
->SetOffset( Point( nOffsetX
, nOffsetY
) );
927 pEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleCellTextData
, NotifyHdl
) );
933 SvxViewForwarder
* ScAccessibleCellTextData::GetViewForwarder()
935 if (!mpViewForwarder
)
936 mpViewForwarder
= new ScViewForwarder(mpViewShell
, meSplitPos
, aCellPos
);
937 return mpViewForwarder
;
940 SvxEditViewForwarder
* ScAccessibleCellTextData::GetEditViewForwarder( bool /* bCreate */ )
942 //#102219#; there should no EditViewForwarder be, because the cell is now readonly in this interface
946 IMPL_LINK(ScAccessibleCellTextData
, NotifyHdl
, EENotify
*, aNotify
)
950 SAL_WNODEPRECATED_DECLARATIONS_PUSH
951 ::std::auto_ptr
< SfxHint
> aHint
= SvxEditSourceHelper::EENotification2Hint( aNotify
);
952 SAL_WNODEPRECATED_DECLARATIONS_POP
955 GetBroadcaster().Broadcast( *aHint
.get() );
961 ScDocShell
* ScAccessibleCellTextData::GetDocShell(ScTabViewShell
* pViewShell
)
963 ScDocShell
* pDocSh
= NULL
;
965 pDocSh
= pViewShell
->GetViewData()->GetDocShell();
970 ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView
* pEditView
, Window
* pWin
, bool isClone
)
972 mpViewForwarder(NULL
),
973 mpEditViewForwarder(NULL
),
974 mpEditView(pEditView
),
975 mpEditEngine(pEditView
? pEditView
->GetEditEngine() : 0),
979 // If the object is cloned, do NOT add notify hdl.
980 mbIsCloned
= isClone
;
981 if (mpEditEngine
&& !mbIsCloned
)
982 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData
, NotifyHdl
) );
985 ScAccessibleEditObjectTextData::~ScAccessibleEditObjectTextData()
987 // If the object is cloned, do NOT set notify hdl.
988 if (mpEditEngine
&& !mbIsCloned
)
989 mpEditEngine
->SetNotifyHdl(Link());
991 delete mpViewForwarder
;
992 if (mpEditViewForwarder
)
993 delete mpEditViewForwarder
;
998 void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1000 if ( rHint
.ISA( SfxSimpleHint
) )
1002 sal_uLong nId
= ((const SfxSimpleHint
&)rHint
).GetId();
1003 if ( nId
== SFX_HINT_DYING
)
1007 mpEditEngine
= NULL
;
1008 DELETEZ(mpForwarder
);
1009 if (mpViewForwarder
)
1010 mpViewForwarder
->SetInvalid();
1011 if (mpEditViewForwarder
)
1012 mpEditViewForwarder
->SetInvalid();
1015 ScAccessibleTextData::Notify(rBC
, rHint
);
1018 ScAccessibleTextData
* ScAccessibleEditObjectTextData::Clone() const
1020 // Add para to indicate the object is cloned
1021 return new ScAccessibleEditObjectTextData(mpEditView
, mpWindow
, true);
1024 SvxTextForwarder
* ScAccessibleEditObjectTextData::GetTextForwarder()
1026 if ((!mpForwarder
&& mpEditView
) || (mpEditEngine
&& !mpEditEngine
->GetNotifyHdl().IsSet()))
1029 mpEditEngine
= mpEditView
->GetEditEngine();
1030 // If the object is cloned, do NOT add notify hdl.
1031 if (mpEditEngine
&& !mpEditEngine
->GetNotifyHdl().IsSet()&&!mbIsCloned
)
1032 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData
, NotifyHdl
) );
1034 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1039 SvxViewForwarder
* ScAccessibleEditObjectTextData::GetViewForwarder()
1041 if (!mpViewForwarder
)
1043 // i#49561 Get right-aligned cell content to be read by screenreader.
1044 mpViewForwarder
= new ScEditObjectViewForwarder( mpWindow
, mpEditView
);
1046 return mpViewForwarder
;
1049 SvxEditViewForwarder
* ScAccessibleEditObjectTextData::GetEditViewForwarder( bool bCreate
)
1051 if (!mpEditViewForwarder
&& mpEditView
)
1052 mpEditViewForwarder
= new ScEditViewForwarder(mpEditView
, mpWindow
);
1055 if (!mpEditView
&& mpEditViewForwarder
)
1057 DELETEZ(mpEditViewForwarder
);
1059 else if (mpEditViewForwarder
)
1060 mpEditViewForwarder
->GrabFocus();
1062 return mpEditViewForwarder
;
1065 IMPL_LINK(ScAccessibleEditObjectTextData
, NotifyHdl
, EENotify
*, aNotify
)
1069 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1070 ::std::auto_ptr
< SfxHint
> aHint
= SvxEditSourceHelper::EENotification2Hint( aNotify
);
1071 SAL_WNODEPRECATED_DECLARATIONS_POP
1074 GetBroadcaster().Broadcast( *aHint
.get() );
1080 ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView
* pEditView
, Window
* pWin
)
1082 ScAccessibleEditObjectTextData(pEditView
, pWin
),
1083 mbEditEngineCreated(false)
1085 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>( pWin
);
1088 pTxtWnd
->InsertAccessibleTextData( *this );
1091 ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
1093 ScTextWnd
* pTxtWnd
= dynamic_cast< ScTextWnd
* >(mpWindow
);
1096 pTxtWnd
->RemoveAccessibleTextData( *this );
1098 if (mbEditEngineCreated
&& mpEditEngine
)
1100 delete mpEditEngine
;
1101 mpEditEngine
= NULL
; // don't access in ScAccessibleEditObjectTextData dtor!
1103 else if (pTxtWnd
&& pTxtWnd
->GetEditView() && pTxtWnd
->GetEditView()->GetEditEngine())
1105 // the NotifyHdl also has to be removed from the ScTextWnd's EditEngine
1106 // (it's set in ScAccessibleEditLineTextData::GetTextForwarder, and mpEditEngine
1108 pTxtWnd
->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
1112 void ScAccessibleEditLineTextData::Dispose()
1114 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
);
1117 pTxtWnd
->RemoveAccessibleTextData( *this );
1123 ScAccessibleTextData
* ScAccessibleEditLineTextData::Clone() const
1125 return new ScAccessibleEditLineTextData(mpEditView
, mpWindow
);
1128 SvxTextForwarder
* ScAccessibleEditLineTextData::GetTextForwarder()
1130 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
);
1134 mpEditView
= pTxtWnd
->GetEditView();
1137 if (mbEditEngineCreated
&& mpEditEngine
)
1139 mbEditEngineCreated
= false;
1141 mpEditView
= pTxtWnd
->GetEditView();
1142 ScAccessibleEditObjectTextData::GetTextForwarder(); // fill the mpForwarder
1143 mpEditEngine
= NULL
;
1147 if (mpEditEngine
&& !mbEditEngineCreated
)
1151 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1152 pEnginePool
->FreezeIdRanges();
1153 mpEditEngine
= new ScFieldEditEngine(NULL
, pEnginePool
, NULL
, true);
1154 mbEditEngineCreated
= true;
1155 mpEditEngine
->EnableUndo( false );
1156 mpEditEngine
->SetRefMapMode( MAP_100TH_MM
);
1157 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1159 mpEditEngine
->SetText(pTxtWnd
->GetTextString());
1161 Size
aSize(pTxtWnd
->GetSizePixel());
1163 aSize
= pTxtWnd
->PixelToLogic(aSize
, mpEditEngine
->GetRefMapMode());
1165 mpEditEngine
->SetPaperSize(aSize
);
1167 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData
, NotifyHdl
) );
1174 SvxEditViewForwarder
* ScAccessibleEditLineTextData::GetEditViewForwarder( bool bCreate
)
1176 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
);
1180 mpEditView
= pTxtWnd
->GetEditView();
1181 if (!mpEditView
&& bCreate
)
1183 if ( !pTxtWnd
->IsInputActive() )
1185 pTxtWnd
->StartEditEngine();
1186 pTxtWnd
->GrabFocus();
1188 mpEditView
= pTxtWnd
->GetEditView();
1193 return ScAccessibleEditObjectTextData::GetEditViewForwarder(bCreate
);
1196 void ScAccessibleEditLineTextData::ResetEditMode()
1198 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
);
1200 if (mbEditEngineCreated
&& mpEditEngine
)
1201 delete mpEditEngine
;
1202 else if (pTxtWnd
&& pTxtWnd
->GetEditView() && pTxtWnd
->GetEditView()->GetEditEngine())
1203 pTxtWnd
->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
1204 mpEditEngine
= NULL
;
1206 DELETEZ(mpForwarder
);
1207 DELETEZ(mpEditViewForwarder
);
1208 DELETEZ(mpViewForwarder
);
1209 mbEditEngineCreated
= false;
1212 void ScAccessibleEditLineTextData::TextChanged()
1214 if (mbEditEngineCreated
&& mpEditEngine
)
1216 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
);
1219 mpEditEngine
->SetText(pTxtWnd
->GetTextString());
1223 void ScAccessibleEditLineTextData::StartEdit()
1228 // send HINT_BEGEDIT
1229 SdrHint
aHint(HINT_BEGEDIT
);
1230 GetBroadcaster().Broadcast( aHint
);
1233 void ScAccessibleEditLineTextData::EndEdit()
1235 // send HINT_ENDEDIT
1236 SdrHint
aHint(HINT_ENDEDIT
);
1237 GetBroadcaster().Broadcast( aHint
);
1244 // ScAccessiblePreviewCellTextData: shared data between sub objects of a accessible cell text object
1246 ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell
* pViewShell
,
1247 const ScAddress
& rP
)
1248 : ScAccessibleCellBaseTextData(GetDocShell(pViewShell
), rP
),
1249 mpViewForwarder(NULL
),
1250 mpViewShell(pViewShell
)
1254 ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData()
1257 pEditEngine
->SetNotifyHdl(Link());
1258 if (mpViewForwarder
)
1259 delete mpViewForwarder
;
1262 void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1264 if ( rHint
.ISA( SfxSimpleHint
) )
1266 sal_uLong nId
= ((const SfxSimpleHint
&)rHint
).GetId();
1267 if ( nId
== SFX_HINT_DYING
)
1269 mpViewShell
= NULL
; // invalid now
1270 if (mpViewForwarder
)
1271 mpViewForwarder
->SetInvalid();
1274 ScAccessibleCellBaseTextData::Notify(rBC
, rHint
);
1277 ScAccessibleTextData
* ScAccessiblePreviewCellTextData::Clone() const
1279 return new ScAccessiblePreviewCellTextData(mpViewShell
, aCellPos
);
1282 SvxTextForwarder
* ScAccessiblePreviewCellTextData::GetTextForwarder()
1284 bool bEditEngineBefore(pEditEngine
!= NULL
);
1286 ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
1288 if (!bEditEngineBefore
&& pEditEngine
)
1290 Size
aSize(mpViewShell
->GetLocationData().GetCellOutputRect(aCellPos
).GetSize());
1291 Window
* pWin
= mpViewShell
->GetWindow();
1293 aSize
= pWin
->PixelToLogic(aSize
, pEditEngine
->GetRefMapMode());
1294 pEditEngine
->SetPaperSize(aSize
);
1298 pEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleCellTextData
, NotifyHdl
) );
1303 SvxViewForwarder
* ScAccessiblePreviewCellTextData::GetViewForwarder()
1305 if (!mpViewForwarder
)
1306 mpViewForwarder
= new ScPreviewCellViewForwarder(mpViewShell
, aCellPos
);
1307 return mpViewForwarder
;
1310 ScDocShell
* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell
* pViewShell
)
1312 ScDocShell
* pDocSh
= NULL
;
1313 if (pViewShell
&& pViewShell
->GetDocument())
1314 pDocSh
= (ScDocShell
*) pViewShell
->GetDocument()->GetDocumentShell();
1319 // ScAccessiblePreviewHeaderCellTextData: shared data between sub objects of a accessible cell text object
1321 ScAccessiblePreviewHeaderCellTextData::ScAccessiblePreviewHeaderCellTextData(ScPreviewShell
* pViewShell
,
1322 const OUString
& rText
, const ScAddress
& rP
, bool bColHeader
, bool bRowHeader
)
1323 : ScAccessibleCellBaseTextData(GetDocShell(pViewShell
), rP
),
1324 mpViewForwarder(NULL
),
1325 mpViewShell(pViewShell
),
1327 mbColHeader(bColHeader
),
1328 mbRowHeader(bRowHeader
)
1332 ScAccessiblePreviewHeaderCellTextData::~ScAccessiblePreviewHeaderCellTextData()
1335 pEditEngine
->SetNotifyHdl(Link());
1336 if (mpViewForwarder
)
1337 delete mpViewForwarder
;
1340 void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1342 if ( rHint
.ISA( SfxSimpleHint
) )
1344 sal_uLong nId
= ((const SfxSimpleHint
&)rHint
).GetId();
1345 if ( nId
== SFX_HINT_DYING
)
1347 mpViewShell
= NULL
; // invalid now
1348 if (mpViewForwarder
)
1349 mpViewForwarder
->SetInvalid();
1352 ScAccessibleCellBaseTextData::Notify(rBC
, rHint
);
1355 ScAccessibleTextData
* ScAccessiblePreviewHeaderCellTextData::Clone() const
1357 return new ScAccessiblePreviewHeaderCellTextData(mpViewShell
, maText
, aCellPos
, mbColHeader
, mbRowHeader
);
1360 SvxTextForwarder
* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
1366 ScDocument
* pDoc
= pDocShell
->GetDocument();
1367 pEditEngine
= pDoc
->CreateFieldEditEngine();
1371 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1372 pEnginePool
->FreezeIdRanges();
1373 pEditEngine
= new ScFieldEditEngine(NULL
, pEnginePool
, NULL
, true);
1375 pEditEngine
->EnableUndo( false );
1377 pEditEngine
->SetRefDevice(pDocShell
->GetRefDevice());
1379 pEditEngine
->SetRefMapMode( MAP_100TH_MM
);
1380 pForwarder
= new SvxEditEngineForwarder(*pEditEngine
);
1386 if (!maText
.isEmpty())
1391 Window
* pWindow
= mpViewShell
->GetWindow();
1393 aOutputSize
= pWindow
->GetOutputSizePixel();
1395 Rectangle
aVisRect( aPoint
, aOutputSize
);
1396 Size
aSize(mpViewShell
->GetLocationData().GetHeaderCellOutputRect(aVisRect
, aCellPos
, mbColHeader
).GetSize());
1398 aSize
= pWindow
->PixelToLogic(aSize
, pEditEngine
->GetRefMapMode());
1399 pEditEngine
->SetPaperSize(aSize
);
1401 pEditEngine
->SetText( maText
);
1406 pEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleCellTextData
, NotifyHdl
) );
1411 SvxViewForwarder
* ScAccessiblePreviewHeaderCellTextData::GetViewForwarder()
1413 if (!mpViewForwarder
)
1414 mpViewForwarder
= new ScPreviewHeaderCellViewForwarder(mpViewShell
, aCellPos
, mbColHeader
);
1415 return mpViewForwarder
;
1418 ScDocShell
* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell
* pViewShell
)
1420 ScDocShell
* pDocSh
= NULL
;
1421 if (pViewShell
&& pViewShell
->GetDocument())
1422 pDocSh
= (ScDocShell
*) pViewShell
->GetDocument()->GetDocumentShell();
1426 ScAccessibleHeaderTextData::ScAccessibleHeaderTextData(ScPreviewShell
* pViewShell
,
1427 const EditTextObject
* pEditObj
, bool bHeader
, SvxAdjust eAdjust
)
1429 mpViewForwarder(NULL
),
1430 mpViewShell(pViewShell
),
1434 mpEditObj(pEditObj
),
1439 if (pViewShell
&& pViewShell
->GetDocument())
1440 mpDocSh
= (ScDocShell
*) pViewShell
->GetDocument()->GetDocumentShell();
1442 mpDocSh
->GetDocument()->AddUnoObject(*this);
1445 ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData()
1447 SolarMutexGuard aGuard
; // needed for EditEngine dtor
1450 mpDocSh
->GetDocument()->RemoveUnoObject(*this);
1452 mpEditEngine
->SetNotifyHdl(Link());
1453 delete mpEditEngine
;
1457 ScAccessibleTextData
* ScAccessibleHeaderTextData::Clone() const
1459 return new ScAccessibleHeaderTextData(mpViewShell
, mpEditObj
, mbHeader
, meAdjust
);
1462 void ScAccessibleHeaderTextData::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1464 if ( rHint
.ISA( SfxSimpleHint
) )
1466 sal_uLong nId
= ((const SfxSimpleHint
&)rHint
).GetId();
1467 if ( nId
== SFX_HINT_DYING
)
1469 mpViewShell
= NULL
;// invalid now
1471 if (mpViewForwarder
)
1472 mpViewForwarder
->SetInvalid();
1477 SvxTextForwarder
* ScAccessibleHeaderTextData::GetTextForwarder()
1481 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1482 pEnginePool
->FreezeIdRanges();
1483 ScHeaderEditEngine
* pHdrEngine
= new ScHeaderEditEngine( pEnginePool
, true );
1485 pHdrEngine
->EnableUndo( false );
1486 pHdrEngine
->SetRefMapMode( MAP_TWIP
);
1488 // default font must be set, independently of document
1489 // -> use global pool from module
1491 SfxItemSet
aDefaults( pHdrEngine
->GetEmptyItemSet() );
1492 const ScPatternAttr
& rPattern
= (const ScPatternAttr
&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN
);
1493 rPattern
.FillEditItemSet( &aDefaults
);
1494 // FillEditItemSet adjusts font height to 1/100th mm,
1495 // but for header/footer twips is needed, as in the PatternAttr:
1496 aDefaults
.Put( rPattern
.GetItem(ATTR_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT
);
1497 aDefaults
.Put( rPattern
.GetItem(ATTR_CJK_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT_CJK
);
1498 aDefaults
.Put( rPattern
.GetItem(ATTR_CTL_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT_CTL
);
1499 aDefaults
.Put( SvxAdjustItem( meAdjust
, EE_PARA_JUST
) );
1500 pHdrEngine
->SetDefaults( aDefaults
);
1502 ScHeaderFieldData aData
;
1504 mpViewShell
->FillFieldData(aData
);
1506 ScHeaderFooterTextObj::FillDummyFieldData( aData
);
1507 pHdrEngine
->SetData( aData
);
1509 mpEditEngine
= pHdrEngine
;
1510 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1519 mpViewShell
->GetLocationData().GetHeaderPosition(aVisRect
);
1520 Size
aSize(aVisRect
.GetSize());
1521 Window
* pWin
= mpViewShell
->GetWindow();
1523 aSize
= pWin
->PixelToLogic(aSize
, mpEditEngine
->GetRefMapMode());
1524 mpEditEngine
->SetPaperSize(aSize
);
1527 mpEditEngine
->SetText(*mpEditObj
);
1533 SvxViewForwarder
* ScAccessibleHeaderTextData::GetViewForwarder()
1535 if (!mpViewForwarder
)
1536 mpViewForwarder
= new ScPreviewHeaderFooterViewForwarder(mpViewShell
, mbHeader
);
1537 return mpViewForwarder
;
1540 ScAccessibleNoteTextData::ScAccessibleNoteTextData(ScPreviewShell
* pViewShell
,
1541 const OUString
& sText
, const ScAddress
& aCellPos
, bool bMarkNote
)
1543 mpViewForwarder(NULL
),
1544 mpViewShell(pViewShell
),
1549 maCellPos(aCellPos
),
1550 mbMarkNote(bMarkNote
),
1553 if (pViewShell
&& pViewShell
->GetDocument())
1554 mpDocSh
= (ScDocShell
*) pViewShell
->GetDocument()->GetDocumentShell();
1556 mpDocSh
->GetDocument()->AddUnoObject(*this);
1559 ScAccessibleNoteTextData::~ScAccessibleNoteTextData()
1561 SolarMutexGuard aGuard
; // needed for EditEngine dtor
1564 mpDocSh
->GetDocument()->RemoveUnoObject(*this);
1566 mpEditEngine
->SetNotifyHdl(Link());
1567 delete mpEditEngine
;
1571 ScAccessibleTextData
* ScAccessibleNoteTextData::Clone() const
1573 return new ScAccessibleNoteTextData(mpViewShell
, msText
, maCellPos
, mbMarkNote
);
1576 void ScAccessibleNoteTextData::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1578 if ( rHint
.ISA( SfxSimpleHint
) )
1580 sal_uLong nId
= ((const SfxSimpleHint
&)rHint
).GetId();
1581 if ( nId
== SFX_HINT_DYING
)
1583 mpViewShell
= NULL
;// invalid now
1585 if (mpViewForwarder
)
1586 mpViewForwarder
->SetInvalid();
1591 SvxTextForwarder
* ScAccessibleNoteTextData::GetTextForwarder()
1597 ScDocument
* pDoc
= mpDocSh
->GetDocument();
1598 mpEditEngine
= pDoc
->CreateFieldEditEngine();
1602 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1603 pEnginePool
->FreezeIdRanges();
1604 mpEditEngine
= new ScFieldEditEngine(NULL
, pEnginePool
, NULL
, true);
1606 mpEditEngine
->EnableUndo( false );
1608 mpEditEngine
->SetRefDevice(mpDocSh
->GetRefDevice());
1610 mpEditEngine
->SetRefMapMode( MAP_100TH_MM
);
1611 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1617 if (!msText
.isEmpty())
1623 Window
* pWindow
= mpViewShell
->GetWindow();
1625 aOutputSize
= pWindow
->GetOutputSizePixel();
1627 Rectangle
aVisRect( aPoint
, aOutputSize
);
1628 Size
aSize(mpViewShell
->GetLocationData().GetNoteInRangeOutputRect(aVisRect
, mbMarkNote
, maCellPos
).GetSize());
1630 aSize
= pWindow
->PixelToLogic(aSize
, mpEditEngine
->GetRefMapMode());
1631 mpEditEngine
->SetPaperSize(aSize
);
1633 mpEditEngine
->SetText( msText
);
1638 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleCellTextData
, NotifyHdl
) );
1643 SvxViewForwarder
* ScAccessibleNoteTextData::GetViewForwarder()
1645 if (!mpViewForwarder
)
1646 mpViewForwarder
= new ScPreviewNoteViewForwarder(mpViewShell
, maCellPos
, mbMarkNote
);
1647 return mpViewForwarder
;
1651 // CSV import =================================================================
1653 class ScCsvViewForwarder
: public SvxViewForwarder
1655 Rectangle maBoundBox
;
1659 explicit ScCsvViewForwarder( Window
* pWindow
, const Rectangle
& rBoundBox
);
1661 virtual bool IsValid() const SAL_OVERRIDE
;
1662 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
1663 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
1664 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
1669 ScCsvViewForwarder::ScCsvViewForwarder( Window
* pWindow
, const Rectangle
& rBoundBox
) :
1670 maBoundBox( rBoundBox
),
1675 bool ScCsvViewForwarder::IsValid() const
1677 return mpWindow
!= NULL
;
1680 Rectangle
ScCsvViewForwarder::GetVisArea() const
1685 Point
ScCsvViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
1687 if( !mpWindow
) return Point();
1688 return mpWindow
->LogicToPixel( rPoint
, rMapMode
);
1691 Point
ScCsvViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
1693 if( !mpWindow
) return Point();
1694 return mpWindow
->PixelToLogic( rPoint
, rMapMode
);
1697 void ScCsvViewForwarder::SetInvalid()
1702 ScAccessibleCsvTextData::ScAccessibleCsvTextData(
1703 Window
* pWindow
, EditEngine
* pEditEngine
,
1704 const OUString
& rCellText
, const Rectangle
& rBoundBox
, const Size
& rCellSize
) :
1705 mpWindow( pWindow
),
1706 mpEditEngine( pEditEngine
),
1707 maCellText( rCellText
),
1708 maBoundBox( rBoundBox
),
1709 maCellSize( rCellSize
)
1713 ScAccessibleCsvTextData::~ScAccessibleCsvTextData()
1717 void ScAccessibleCsvTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1719 if ( rHint
.ISA( SfxSimpleHint
) )
1721 sal_uLong nId
= ((const SfxSimpleHint
&)rHint
).GetId();
1722 if( nId
== SFX_HINT_DYING
)
1725 mpEditEngine
= NULL
;
1726 if (mpViewForwarder
.get())
1727 mpViewForwarder
->SetInvalid();
1730 ScAccessibleTextData::Notify( rBC
, rHint
);
1733 ScAccessibleTextData
* ScAccessibleCsvTextData::Clone() const
1735 return new ScAccessibleCsvTextData( mpWindow
, mpEditEngine
, maCellText
, maBoundBox
, maCellSize
);
1738 SvxTextForwarder
* ScAccessibleCsvTextData::GetTextForwarder()
1742 mpEditEngine
->SetPaperSize( maCellSize
);
1743 mpEditEngine
->SetText( maCellText
);
1744 if( !mpTextForwarder
.get() )
1745 mpTextForwarder
.reset( new SvxEditEngineForwarder( *mpEditEngine
) );
1748 mpTextForwarder
.reset();
1749 return mpTextForwarder
.get();
1752 SvxViewForwarder
* ScAccessibleCsvTextData::GetViewForwarder()
1754 if( !mpViewForwarder
.get() )
1755 mpViewForwarder
.reset( new ScCsvViewForwarder( mpWindow
, maBoundBox
) );
1756 return mpViewForwarder
.get();
1759 SvxEditViewForwarder
* ScAccessibleCsvTextData::GetEditViewForwarder( bool /* bCreate */ )
1764 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */