1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
24 #include "AccessibleText.hxx"
25 #include "AccessibleCell.hxx"
26 #include "tabvwsh.hxx"
27 #include "editutil.hxx"
28 #include "document.hxx"
30 #include "prevwsh.hxx"
32 #include "prevloc.hxx"
33 #include "patattr.hxx"
34 #include "inputwin.hxx"
35 #include <editeng/unofored.hxx>
36 #include <editeng/editview.hxx>
37 #include <editeng/unoedhlp.hxx>
38 #include <vcl/virdev.hxx>
39 #include <editeng/editobj.hxx>
40 #include <editeng/adjustitem.hxx>
41 #include <editeng/justifyitem.hxx>
42 #include <svx/svdmodel.hxx>
43 #include <svx/algitem.hxx>
44 #include <vcl/svapp.hxx>
46 class ScViewForwarder
: public SvxViewForwarder
48 ScTabViewShell
* mpViewShell
;
50 ScSplitPos meSplitPos
;
52 ScViewForwarder(ScTabViewShell
* pViewShell
, ScSplitPos eSplitPos
, const ScAddress
& rCell
);
53 virtual ~ScViewForwarder();
55 virtual bool IsValid() const SAL_OVERRIDE
;
56 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
57 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
58 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
63 ScViewForwarder::ScViewForwarder(ScTabViewShell
* pViewShell
, ScSplitPos eSplitPos
, const ScAddress
& rCell
)
65 mpViewShell(pViewShell
),
71 ScViewForwarder::~ScViewForwarder()
75 bool ScViewForwarder::IsValid() const
77 return mpViewShell
!= NULL
;
80 Rectangle
ScViewForwarder::GetVisArea() const
85 vcl::Window
* pWindow
= mpViewShell
->GetWindowByPos(meSplitPos
);
88 aVisArea
.SetSize(pWindow
->GetSizePixel());
90 ScHSplitPos eWhichH
= ((meSplitPos
== SC_SPLIT_TOPLEFT
) || (meSplitPos
== SC_SPLIT_BOTTOMLEFT
)) ?
91 SC_SPLIT_LEFT
: SC_SPLIT_RIGHT
;
92 ScVSplitPos eWhichV
= ((meSplitPos
== SC_SPLIT_TOPLEFT
) || (meSplitPos
== SC_SPLIT_TOPRIGHT
)) ?
93 SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
;
95 Point
aBaseCellPos(mpViewShell
->GetViewData().GetScrPos(mpViewShell
->GetViewData().GetPosX(eWhichH
),
96 mpViewShell
->GetViewData().GetPosY(eWhichV
), meSplitPos
, true));
97 Point
aCellPos(mpViewShell
->GetViewData().GetScrPos(maCellPos
.Col(), maCellPos
.Row(), meSplitPos
, true));
98 aVisArea
.SetPos(aCellPos
- aBaseCellPos
);
103 OSL_FAIL("this ViewForwarder is not valid");
108 Point
ScViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
112 vcl::Window
* pWindow
= mpViewShell
->GetWindowByPos(meSplitPos
);
114 return pWindow
->LogicToPixel( rPoint
, rMapMode
);
118 OSL_FAIL("this ViewForwarder is not valid");
123 Point
ScViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
127 vcl::Window
* pWindow
= mpViewShell
->GetWindowByPos(meSplitPos
);
129 return pWindow
->PixelToLogic( rPoint
, rMapMode
);
133 OSL_FAIL("this ViewForwarder is not valid");
138 void ScViewForwarder::SetInvalid()
143 class ScEditObjectViewForwarder
: public SvxViewForwarder
145 VclPtr
<vcl::Window
> mpWindow
;
146 // #i49561# EditView needed for access to its visible area.
147 const EditView
* mpEditView
;
149 ScEditObjectViewForwarder( vcl::Window
* pWindow
,
150 const EditView
* _pEditView
);
151 virtual ~ScEditObjectViewForwarder();
153 virtual bool IsValid() const SAL_OVERRIDE
;
154 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
155 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
156 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
161 ScEditObjectViewForwarder::ScEditObjectViewForwarder( vcl::Window
* pWindow
,
162 const EditView
* _pEditView
)
165 mpEditView( _pEditView
)
169 ScEditObjectViewForwarder::~ScEditObjectViewForwarder()
173 bool ScEditObjectViewForwarder::IsValid() const
175 return (mpWindow
!= nullptr);
178 Rectangle
ScEditObjectViewForwarder::GetVisArea() const
183 Rectangle
aVisRect(mpWindow
->GetWindowExtentsRelative(mpWindow
->GetAccessibleParentWindow()));
185 aVisRect
.SetPos(Point(0, 0));
191 OSL_FAIL("this ViewForwarder is not valid");
196 Point
ScEditObjectViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
200 // #i49561# - consider offset of the visible area
201 // of the EditView before converting point to pixel.
202 Point
aPoint( rPoint
);
205 Rectangle
aEditViewVisArea( mpEditView
->GetVisArea() );
206 aPoint
+= aEditViewVisArea
.TopLeft();
208 return mpWindow
->LogicToPixel( aPoint
, rMapMode
);
212 OSL_FAIL("this ViewForwarder is not valid");
217 Point
ScEditObjectViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
221 // #i49561# - consider offset of the visible area
222 // of the EditView after converting point to logic.
223 Point
aPoint( mpWindow
->PixelToLogic( rPoint
, rMapMode
) );
226 Rectangle
aEditViewVisArea( mpEditView
->GetVisArea() );
227 aPoint
-= aEditViewVisArea
.TopLeft();
233 OSL_FAIL("this ViewForwarder is not valid");
238 void ScEditObjectViewForwarder::SetInvalid()
243 class ScPreviewViewForwarder
: public SvxViewForwarder
246 ScPreviewShell
* mpViewShell
;
247 mutable ScPreviewTableInfo
* mpTableInfo
;
249 ScPreviewViewForwarder(ScPreviewShell
* pViewShell
);
250 virtual ~ScPreviewViewForwarder();
252 virtual bool IsValid() const SAL_OVERRIDE
;
253 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
254 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
255 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
259 Rectangle
GetVisRect() const;
261 // clips the VisArea and calculates with the negativ coordinates
262 Rectangle
CorrectVisArea(const Rectangle
& rVisArea
) const;
265 ScPreviewViewForwarder::ScPreviewViewForwarder(ScPreviewShell
* pViewShell
)
267 mpViewShell(pViewShell
),
272 ScPreviewViewForwarder::~ScPreviewViewForwarder()
277 bool ScPreviewViewForwarder::IsValid() const
279 return mpViewShell
!= NULL
;
282 Rectangle
ScPreviewViewForwarder::GetVisArea() const
285 OSL_FAIL("should be implemented in an abrevated class");
289 Point
ScPreviewViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
293 vcl::Window
* pWindow
= mpViewShell
->GetWindow();
296 MapMode
aMapMode(pWindow
->GetMapMode().GetMapUnit());
297 Point
aPoint2( OutputDevice::LogicToLogic( rPoint
, rMapMode
, aMapMode
) );
298 return pWindow
->LogicToPixel(aPoint2
);
303 OSL_FAIL("this ViewForwarder is not valid");
308 Point
ScPreviewViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
312 vcl::Window
* pWindow
= mpViewShell
->GetWindow();
315 MapMode
aMapMode(pWindow
->GetMapMode());
316 aMapMode
.SetOrigin(Point());
317 Point
aPoint1( pWindow
->PixelToLogic( rPoint
) );
318 Point
aPoint2( OutputDevice::LogicToLogic( aPoint1
,
319 aMapMode
.GetMapUnit(),
326 OSL_FAIL("this ViewForwarder is not valid");
331 void ScPreviewViewForwarder::SetInvalid()
336 Rectangle
ScPreviewViewForwarder::GetVisRect() const
341 vcl::Window
* pWindow
= mpViewShell
->GetWindow();
343 aOutputSize
= pWindow
->GetOutputSizePixel();
345 Rectangle
aVisRect( aPoint
, aOutputSize
);
351 Rectangle
ScPreviewViewForwarder::CorrectVisArea(const Rectangle
& rVisArea
) const
353 Rectangle
aVisArea(rVisArea
);
354 Point aPos
= aVisArea
.TopLeft(); // get first the position to remember negative positions after clipping
356 vcl::Window
* pWin
= mpViewShell
->GetWindow();
358 aVisArea
= pWin
->GetWindowExtentsRelative(pWin
).GetIntersection(aVisArea
);
360 sal_Int32
nX(aPos
.getX());
361 sal_Int32
nY(aPos
.getY());
371 aVisArea
.SetPos(Point(nX
, nY
));
376 class ScPreviewHeaderFooterViewForwarder
: public ScPreviewViewForwarder
380 ScPreviewHeaderFooterViewForwarder(ScPreviewShell
* pViewShell
, bool bHeader
);
381 virtual ~ScPreviewHeaderFooterViewForwarder();
383 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
386 ScPreviewHeaderFooterViewForwarder::ScPreviewHeaderFooterViewForwarder(ScPreviewShell
* pViewShell
, bool bHeader
)
388 ScPreviewViewForwarder(pViewShell
),
393 ScPreviewHeaderFooterViewForwarder::~ScPreviewHeaderFooterViewForwarder()
397 Rectangle
ScPreviewHeaderFooterViewForwarder::GetVisArea() const
402 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
404 rData
.GetHeaderPosition( aVisArea
);
406 rData
.GetFooterPosition( aVisArea
);
408 aVisArea
= CorrectVisArea(aVisArea
);
412 OSL_FAIL("this ViewForwarder is not valid");
417 class ScPreviewCellViewForwarder
: public ScPreviewViewForwarder
421 ScPreviewCellViewForwarder(ScPreviewShell
* pViewShell
,
423 virtual ~ScPreviewCellViewForwarder();
425 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
428 ScPreviewCellViewForwarder::ScPreviewCellViewForwarder(ScPreviewShell
* pViewShell
,
431 ScPreviewViewForwarder(pViewShell
),
436 ScPreviewCellViewForwarder::~ScPreviewCellViewForwarder()
440 Rectangle
ScPreviewCellViewForwarder::GetVisArea() const
445 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
446 aVisArea
= rData
.GetCellOutputRect(maCellPos
);
448 aVisArea
= CorrectVisArea(aVisArea
);
452 OSL_FAIL("this ViewForwarder is not valid");
457 class ScPreviewHeaderCellViewForwarder
: public ScPreviewViewForwarder
462 ScPreviewHeaderCellViewForwarder(ScPreviewShell
* pViewShell
,
465 virtual ~ScPreviewHeaderCellViewForwarder();
467 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
470 ScPreviewHeaderCellViewForwarder::ScPreviewHeaderCellViewForwarder(ScPreviewShell
* pViewShell
,
474 ScPreviewViewForwarder(pViewShell
),
476 mbColHeader(bColHeader
)
480 ScPreviewHeaderCellViewForwarder::~ScPreviewHeaderCellViewForwarder()
484 Rectangle
ScPreviewHeaderCellViewForwarder::GetVisArea() const
489 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
490 aVisArea
= rData
.GetHeaderCellOutputRect(GetVisRect(), maCellPos
, mbColHeader
);
492 aVisArea
= CorrectVisArea(aVisArea
);
496 OSL_FAIL("this ViewForwarder is not valid");
501 class ScPreviewNoteViewForwarder
: public ScPreviewViewForwarder
506 ScPreviewNoteViewForwarder(ScPreviewShell
* pViewShell
,
509 virtual ~ScPreviewNoteViewForwarder();
511 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
514 ScPreviewNoteViewForwarder::ScPreviewNoteViewForwarder(ScPreviewShell
* pViewShell
,
518 ScPreviewViewForwarder(pViewShell
),
520 mbNoteMark(bNoteMark
)
524 ScPreviewNoteViewForwarder::~ScPreviewNoteViewForwarder()
528 Rectangle
ScPreviewNoteViewForwarder::GetVisArea() const
533 const ScPreviewLocationData
& rData
= mpViewShell
->GetLocationData();
534 aVisArea
= rData
.GetNoteInRangeOutputRect(GetVisRect(), mbNoteMark
, maCellPos
);
536 aVisArea
= CorrectVisArea(aVisArea
);
540 OSL_FAIL("this ViewForwarder is not valid");
545 class ScEditViewForwarder
: public SvxEditViewForwarder
547 EditView
* mpEditView
;
548 VclPtr
<vcl::Window
> mpWindow
;
550 ScEditViewForwarder(EditView
* pEditView
, vcl::Window
* pWin
);
551 virtual ~ScEditViewForwarder();
553 virtual bool IsValid() const SAL_OVERRIDE
;
554 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
555 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
556 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
557 virtual bool GetSelection( ESelection
& rSelection
) const SAL_OVERRIDE
;
558 virtual bool SetSelection( const ESelection
& rSelection
) SAL_OVERRIDE
;
559 virtual bool Copy() SAL_OVERRIDE
;
560 virtual bool Cut() SAL_OVERRIDE
;
561 virtual bool Paste() SAL_OVERRIDE
;
566 ScEditViewForwarder::ScEditViewForwarder(EditView
* pEditView
, vcl::Window
* pWin
)
567 : mpEditView(pEditView
),
572 ScEditViewForwarder::~ScEditViewForwarder()
576 bool ScEditViewForwarder::IsValid() const
578 return mpWindow
&& mpEditView
;
581 Rectangle
ScEditViewForwarder::GetVisArea() const
584 if (IsValid() && mpEditView
->GetEditEngine())
586 MapMode
aMapMode(mpEditView
->GetEditEngine()->GetRefMapMode());
588 aVisArea
= mpWindow
->LogicToPixel( mpEditView
->GetVisArea(), aMapMode
);
592 OSL_FAIL("this EditViewForwarder is no longer valid");
597 Point
ScEditViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
600 return mpWindow
->LogicToPixel( rPoint
, rMapMode
);
603 OSL_FAIL("this ViewForwarder is not valid");
608 Point
ScEditViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
611 return mpWindow
->PixelToLogic( rPoint
, rMapMode
);
614 OSL_FAIL("this ViewForwarder is not valid");
619 bool ScEditViewForwarder::GetSelection( ESelection
& rSelection
) const
624 rSelection
= mpEditView
->GetSelection();
629 OSL_FAIL("this ViewForwarder is not valid");
634 bool ScEditViewForwarder::SetSelection( const ESelection
& rSelection
)
639 mpEditView
->SetSelection(rSelection
);
644 OSL_FAIL("this ViewForwarder is not valid");
649 bool ScEditViewForwarder::Copy()
659 OSL_FAIL("this ViewForwarder is not valid");
664 bool ScEditViewForwarder::Cut()
674 OSL_FAIL("this ViewForwarder is not valid");
679 bool ScEditViewForwarder::Paste()
689 OSL_FAIL("this ViewForwarder is not valid");
694 void ScEditViewForwarder::SetInvalid()
700 // ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
702 ScAccessibleCellTextData::ScAccessibleCellTextData(ScTabViewShell
* pViewShell
,
703 const ScAddress
& rP
, ScSplitPos eSplitPos
, ScAccessibleCell
* pAccCell
)
704 : ScAccessibleCellBaseTextData(GetDocShell(pViewShell
), rP
),
705 mpViewForwarder(NULL
),
706 mpEditViewForwarder(NULL
),
707 mpViewShell(pViewShell
),
708 meSplitPos(eSplitPos
),
709 mpAccessibleCell( pAccCell
)
713 ScAccessibleCellTextData::~ScAccessibleCellTextData()
716 pEditEngine
->SetNotifyHdl(Link
<>());
718 delete mpViewForwarder
;
719 if (mpEditViewForwarder
)
720 delete mpEditViewForwarder
;
723 void ScAccessibleCellTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
725 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
728 sal_uLong nId
= pSimpleHint
->GetId();
729 if ( nId
== SFX_HINT_DYING
)
731 mpViewShell
= NULL
; // invalid now
733 mpViewForwarder
->SetInvalid();
734 if (mpEditViewForwarder
)
735 mpEditViewForwarder
->SetInvalid();
738 ScAccessibleCellBaseTextData::Notify(rBC
, rHint
);
741 ScAccessibleTextData
* ScAccessibleCellTextData::Clone() const
743 return new ScAccessibleCellTextData( mpViewShell
, aCellPos
, meSplitPos
, mpAccessibleCell
);
746 void ScAccessibleCellTextData::GetCellText(const ScAddress
& rCellPos
, OUString
& rText
)
748 // #104893#; don't use the input string
749 // ScCellTextData::GetCellText(rCellPos, rText);
750 ScDocument
& rDoc
= pDocShell
->GetDocument();
751 // #104893#; use the displayed string
752 rText
= rDoc
.GetString(rCellPos
.Col(), rCellPos
.Row(), rCellPos
.Tab());
755 const ScViewOptions
& aOptions
= mpViewShell
->GetViewData().GetOptions();
757 rDoc
.GetCellType(rCellPos
.Col(), rCellPos
.Row(), rCellPos
.Tab(), aCellType
);
758 if (aCellType
== CELLTYPE_FORMULA
&& aOptions
.GetOption( VOPT_FORMULAS
))
760 rDoc
.GetFormula( rCellPos
.Col(), rCellPos
.Row(), rCellPos
.Tab(), rText
);
762 else if (!aOptions
.GetOption( VOPT_NULLVALS
))
764 if ((aCellType
== CELLTYPE_VALUE
|| aCellType
== CELLTYPE_FORMULA
) && rDoc
.GetValue(rCellPos
) == 0.0)
770 SvxTextForwarder
* ScAccessibleCellTextData::GetTextForwarder()
772 ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
774 if ( pDocShell
&& pEditEngine
&& mpViewShell
)
776 ScDocument
& rDoc
= pDocShell
->GetDocument();
778 mpViewShell
->GetViewData().GetMergeSizePixel(
779 aCellPos
.Col(), aCellPos
.Row(), nSizeX
, nSizeY
);
781 Size
aSize(nSizeX
, nSizeY
);
783 // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
785 const SvxHorJustifyItem
* pHorJustifyItem
= static_cast< const SvxHorJustifyItem
* >(
786 rDoc
.GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_HOR_JUSTIFY
) );
787 SvxCellHorJustify eHorJust
= ( pHorJustifyItem
? static_cast< SvxCellHorJustify
>( pHorJustifyItem
->GetValue() ) : SVX_HOR_JUSTIFY_STANDARD
);
788 if ( eHorJust
== SVX_HOR_JUSTIFY_LEFT
)
790 const SfxUInt16Item
* pIndentItem
= static_cast< const SfxUInt16Item
* >(
791 rDoc
.GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_INDENT
) );
794 nIndent
= static_cast< long >( pIndentItem
->GetValue() );
798 const SvxMarginItem
* pMarginItem
= static_cast< const SvxMarginItem
* >(
799 rDoc
.GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_MARGIN
) );
800 ScViewData
& rViewData
= mpViewShell
->GetViewData();
801 double nPPTX
= rViewData
.GetPPTX();
802 double nPPTY
= rViewData
.GetPPTY();
803 long nLeftM
= ( pMarginItem
? static_cast< long >( ( pMarginItem
->GetLeftMargin() + nIndent
) * nPPTX
) : 0 );
804 long nTopM
= ( pMarginItem
? static_cast< long >( pMarginItem
->GetTopMargin() * nPPTY
) : 0 );
805 long nRightM
= ( pMarginItem
? static_cast< long >( pMarginItem
->GetRightMargin() * nPPTX
) : 0 );
806 long nBottomM
= ( pMarginItem
? static_cast< long >( pMarginItem
->GetBottomMargin() * nPPTY
) : 0 );
807 long nWidth
= aSize
.getWidth() - nLeftM
- nRightM
;
808 aSize
.setWidth( nWidth
);
809 aSize
.setHeight( aSize
.getHeight() - nTopM
- nBottomM
);
811 vcl::Window
* pWin
= mpViewShell
->GetWindowByPos( meSplitPos
);
814 aSize
= pWin
->PixelToLogic( aSize
, pEditEngine
->GetRefMapMode() );
817 /* #i19430# Gnopernicus reads text partly if it sticks out of the cell
818 boundaries. This leads to wrong results in cases where the cell text
819 is rotated, because rotation is not taken into account when calcu-
820 lating the visible part of the text. In these cases we will expand
821 the cell size passed as paper size to the edit engine. The function
822 accessibility::AccessibleStaticTextBase::GetParagraphBoundingBox()
823 (see svx/source/accessibility/AccessibleStaticTextBase.cxx) will
824 return the size of the complete text then, which is used to expand
825 the cell bounding box in ScAccessibleCell::GetBoundingBox()
826 (see sc/source/ui/Accessibility/AccessibleCell.cxx). */
827 const SfxInt32Item
* pItem
= static_cast< const SfxInt32Item
* >(
828 rDoc
.GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_ROTATE_VALUE
) );
829 if( pItem
&& (pItem
->GetValue() != 0) )
831 pEditEngine
->SetPaperSize( Size( LONG_MAX
, aSize
.getHeight() ) );
832 long nTxtWidth
= static_cast< long >( pEditEngine
->CalcTextWidth() );
833 aSize
.setWidth( std::max( aSize
.getWidth(), nTxtWidth
+ 2 ) );
837 // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
838 const SfxBoolItem
* pLineBreakItem
= static_cast< const SfxBoolItem
* >(
839 rDoc
.GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_LINEBREAK
) );
840 bool bLineBreak
= ( pLineBreakItem
&& pLineBreakItem
->GetValue() );
843 long nTxtWidth
= static_cast< long >( pEditEngine
->CalcTextWidth() );
844 aSize
.setWidth( ::std::max( aSize
.getWidth(), nTxtWidth
) );
848 pEditEngine
->SetPaperSize( aSize
);
850 // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
851 if ( eHorJust
== SVX_HOR_JUSTIFY_STANDARD
&& rDoc
.HasValueData( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab() ) )
853 pEditEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
859 aTextSize
= pWin
->LogicToPixel( Size( pEditEngine
->CalcTextWidth(), pEditEngine
->GetTextHeight() ), pEditEngine
->GetRefMapMode() );
861 long nTextWidth
= aTextSize
.Width();
862 long nTextHeight
= aTextSize
.Height();
864 long nOffsetX
= nLeftM
;
865 long nDiffX
= nTextWidth
- nWidth
;
870 case SVX_HOR_JUSTIFY_RIGHT
:
875 case SVX_HOR_JUSTIFY_CENTER
:
877 nOffsetX
-= nDiffX
/ 2;
888 const SvxVerJustifyItem
* pVerJustifyItem
= static_cast< const SvxVerJustifyItem
* >(
889 rDoc
.GetAttr( aCellPos
.Col(), aCellPos
.Row(), aCellPos
.Tab(), ATTR_VER_JUSTIFY
) );
890 SvxCellVerJustify eVerJust
= ( pVerJustifyItem
? static_cast< SvxCellVerJustify
>( pVerJustifyItem
->GetValue() ) : SVX_VER_JUSTIFY_STANDARD
);
893 case SVX_VER_JUSTIFY_STANDARD
:
894 case SVX_VER_JUSTIFY_BOTTOM
:
896 nOffsetY
= nSizeY
- nBottomM
- nTextHeight
;
899 case SVX_VER_JUSTIFY_CENTER
:
901 nOffsetY
= ( nSizeY
- nTopM
- nBottomM
- nTextHeight
) / 2 + nTopM
;
911 if ( mpAccessibleCell
)
913 mpAccessibleCell
->SetOffset( Point( nOffsetX
, nOffsetY
) );
916 pEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleCellTextData
, NotifyHdl
) );
922 SvxViewForwarder
* ScAccessibleCellTextData::GetViewForwarder()
924 if (!mpViewForwarder
)
925 mpViewForwarder
= new ScViewForwarder(mpViewShell
, meSplitPos
, aCellPos
);
926 return mpViewForwarder
;
929 SvxEditViewForwarder
* ScAccessibleCellTextData::GetEditViewForwarder( bool /* bCreate */ )
931 //#102219#; there should no EditViewForwarder be, because the cell is now readonly in this interface
935 IMPL_LINK(ScAccessibleTextData
, NotifyHdl
, EENotify
*, aNotify
)
939 ::std::unique_ptr
< SfxHint
> aHint
= SvxEditSourceHelper::EENotification2Hint( aNotify
);
942 GetBroadcaster().Broadcast( *aHint
.get() );
948 ScDocShell
* ScAccessibleCellTextData::GetDocShell(ScTabViewShell
* pViewShell
)
950 ScDocShell
* pDocSh
= NULL
;
952 pDocSh
= pViewShell
->GetViewData().GetDocShell();
956 ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView
* pEditView
, vcl::Window
* pWin
, bool isClone
)
958 mpViewForwarder(NULL
),
959 mpEditViewForwarder(NULL
),
960 mpEditView(pEditView
),
961 mpEditEngine(pEditView
? pEditView
->GetEditEngine() : 0),
965 // If the object is cloned, do NOT add notify hdl.
966 mbIsCloned
= isClone
;
967 if (mpEditEngine
&& !mbIsCloned
)
968 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData
, NotifyHdl
) );
971 ScAccessibleEditObjectTextData::~ScAccessibleEditObjectTextData()
973 // If the object is cloned, do NOT set notify hdl.
974 if (mpEditEngine
&& !mbIsCloned
)
975 mpEditEngine
->SetNotifyHdl(Link
<>());
977 delete mpViewForwarder
;
978 if (mpEditViewForwarder
)
979 delete mpEditViewForwarder
;
984 void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
986 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
989 sal_uLong nId
= pSimpleHint
->GetId();
990 if ( nId
== SFX_HINT_DYING
)
995 DELETEZ(mpForwarder
);
997 mpViewForwarder
->SetInvalid();
998 if (mpEditViewForwarder
)
999 mpEditViewForwarder
->SetInvalid();
1002 ScAccessibleTextData::Notify(rBC
, rHint
);
1005 ScAccessibleTextData
* ScAccessibleEditObjectTextData::Clone() const
1007 // Add para to indicate the object is cloned
1008 return new ScAccessibleEditObjectTextData(mpEditView
, mpWindow
, true);
1011 SvxTextForwarder
* ScAccessibleEditObjectTextData::GetTextForwarder()
1013 if ((!mpForwarder
&& mpEditView
) || (mpEditEngine
&& !mpEditEngine
->GetNotifyHdl().IsSet()))
1016 mpEditEngine
= mpEditView
->GetEditEngine();
1017 // If the object is cloned, do NOT add notify hdl.
1018 if (mpEditEngine
&& !mpEditEngine
->GetNotifyHdl().IsSet()&&!mbIsCloned
)
1019 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData
, NotifyHdl
) );
1021 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1026 SvxViewForwarder
* ScAccessibleEditObjectTextData::GetViewForwarder()
1028 if (!mpViewForwarder
)
1030 // i#49561 Get right-aligned cell content to be read by screenreader.
1031 mpViewForwarder
= new ScEditObjectViewForwarder( mpWindow
, mpEditView
);
1033 return mpViewForwarder
;
1036 SvxEditViewForwarder
* ScAccessibleEditObjectTextData::GetEditViewForwarder( bool bCreate
)
1038 if (!mpEditViewForwarder
&& mpEditView
)
1039 mpEditViewForwarder
= new ScEditViewForwarder(mpEditView
, mpWindow
);
1042 if (!mpEditView
&& mpEditViewForwarder
)
1044 DELETEZ(mpEditViewForwarder
);
1047 return mpEditViewForwarder
;
1050 IMPL_LINK(ScAccessibleEditObjectTextData
, NotifyHdl
, EENotify
*, aNotify
)
1054 ::std::unique_ptr
< SfxHint
> aHint
= SvxEditSourceHelper::EENotification2Hint( aNotify
);
1057 GetBroadcaster().Broadcast( *aHint
.get() );
1063 ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView
* pEditView
, vcl::Window
* pWin
)
1065 ScAccessibleEditObjectTextData(pEditView
, pWin
),
1066 mbEditEngineCreated(false)
1068 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>( pWin
);
1071 pTxtWnd
->InsertAccessibleTextData( *this );
1074 ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
1076 ScTextWnd
* pTxtWnd
= dynamic_cast< ScTextWnd
* >(mpWindow
.get());
1079 pTxtWnd
->RemoveAccessibleTextData( *this );
1081 if (mbEditEngineCreated
&& mpEditEngine
)
1083 delete mpEditEngine
;
1084 mpEditEngine
= NULL
; // don't access in ScAccessibleEditObjectTextData dtor!
1086 else if (pTxtWnd
&& pTxtWnd
->GetEditView() && pTxtWnd
->GetEditView()->GetEditEngine())
1088 // the NotifyHdl also has to be removed from the ScTextWnd's EditEngine
1089 // (it's set in ScAccessibleEditLineTextData::GetTextForwarder, and mpEditEngine
1091 pTxtWnd
->GetEditView()->GetEditEngine()->SetNotifyHdl(Link
<>());
1095 void ScAccessibleEditLineTextData::Dispose()
1097 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
.get());
1100 pTxtWnd
->RemoveAccessibleTextData( *this );
1106 ScAccessibleTextData
* ScAccessibleEditLineTextData::Clone() const
1108 return new ScAccessibleEditLineTextData(mpEditView
, mpWindow
);
1111 SvxTextForwarder
* ScAccessibleEditLineTextData::GetTextForwarder()
1113 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
.get());
1117 mpEditView
= pTxtWnd
->GetEditView();
1120 if (mbEditEngineCreated
&& mpEditEngine
)
1122 mbEditEngineCreated
= false;
1124 mpEditView
= pTxtWnd
->GetEditView();
1125 ScAccessibleEditObjectTextData::GetTextForwarder(); // fill the mpForwarder
1126 mpEditEngine
= NULL
;
1130 if (mpEditEngine
&& !mbEditEngineCreated
)
1134 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1135 pEnginePool
->FreezeIdRanges();
1136 mpEditEngine
= new ScFieldEditEngine(NULL
, pEnginePool
, NULL
, true);
1137 mbEditEngineCreated
= true;
1138 mpEditEngine
->EnableUndo( false );
1139 mpEditEngine
->SetRefMapMode( MAP_100TH_MM
);
1140 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1142 mpEditEngine
->SetText(pTxtWnd
->GetTextString());
1144 Size
aSize(pTxtWnd
->GetSizePixel());
1146 aSize
= pTxtWnd
->PixelToLogic(aSize
, mpEditEngine
->GetRefMapMode());
1148 mpEditEngine
->SetPaperSize(aSize
);
1150 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData
, NotifyHdl
) );
1157 SvxEditViewForwarder
* ScAccessibleEditLineTextData::GetEditViewForwarder( bool bCreate
)
1159 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
.get());
1163 mpEditView
= pTxtWnd
->GetEditView();
1164 if (!mpEditView
&& bCreate
)
1166 if ( !pTxtWnd
->IsInputActive() )
1168 pTxtWnd
->StartEditEngine();
1169 pTxtWnd
->GrabFocus();
1171 mpEditView
= pTxtWnd
->GetEditView();
1176 return ScAccessibleEditObjectTextData::GetEditViewForwarder(bCreate
);
1179 void ScAccessibleEditLineTextData::ResetEditMode()
1181 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
.get());
1183 if (mbEditEngineCreated
&& mpEditEngine
)
1184 delete mpEditEngine
;
1185 else if (pTxtWnd
&& pTxtWnd
->GetEditView() && pTxtWnd
->GetEditView()->GetEditEngine())
1186 pTxtWnd
->GetEditView()->GetEditEngine()->SetNotifyHdl(Link
<>());
1187 mpEditEngine
= NULL
;
1189 DELETEZ(mpForwarder
);
1190 DELETEZ(mpEditViewForwarder
);
1191 DELETEZ(mpViewForwarder
);
1192 mbEditEngineCreated
= false;
1195 void ScAccessibleEditLineTextData::TextChanged()
1197 if (mbEditEngineCreated
&& mpEditEngine
)
1199 ScTextWnd
* pTxtWnd
= dynamic_cast<ScTextWnd
*>(mpWindow
.get());
1202 mpEditEngine
->SetText(pTxtWnd
->GetTextString());
1206 void ScAccessibleEditLineTextData::StartEdit()
1211 // send HINT_BEGEDIT
1212 SdrHint
aHint(HINT_BEGEDIT
);
1213 GetBroadcaster().Broadcast( aHint
);
1216 void ScAccessibleEditLineTextData::EndEdit()
1218 // send HINT_ENDEDIT
1219 SdrHint
aHint(HINT_ENDEDIT
);
1220 GetBroadcaster().Broadcast( aHint
);
1226 // ScAccessiblePreviewCellTextData: shared data between sub objects of a accessible cell text object
1228 ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell
* pViewShell
,
1229 const ScAddress
& rP
)
1230 : ScAccessibleCellBaseTextData(GetDocShell(pViewShell
), rP
),
1231 mpViewForwarder(NULL
),
1232 mpViewShell(pViewShell
)
1236 ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData()
1239 pEditEngine
->SetNotifyHdl(Link
<>());
1240 if (mpViewForwarder
)
1241 delete mpViewForwarder
;
1244 void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1246 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
1249 sal_uLong nId
= pSimpleHint
->GetId();
1250 if ( nId
== SFX_HINT_DYING
)
1252 mpViewShell
= NULL
; // invalid now
1253 if (mpViewForwarder
)
1254 mpViewForwarder
->SetInvalid();
1257 ScAccessibleCellBaseTextData::Notify(rBC
, rHint
);
1260 ScAccessibleTextData
* ScAccessiblePreviewCellTextData::Clone() const
1262 return new ScAccessiblePreviewCellTextData(mpViewShell
, aCellPos
);
1265 SvxTextForwarder
* ScAccessiblePreviewCellTextData::GetTextForwarder()
1267 bool bEditEngineBefore(pEditEngine
!= NULL
);
1269 ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
1271 if (!bEditEngineBefore
&& pEditEngine
)
1273 Size
aSize(mpViewShell
->GetLocationData().GetCellOutputRect(aCellPos
).GetSize());
1274 vcl::Window
* pWin
= mpViewShell
->GetWindow();
1276 aSize
= pWin
->PixelToLogic(aSize
, pEditEngine
->GetRefMapMode());
1277 pEditEngine
->SetPaperSize(aSize
);
1281 pEditEngine
->SetNotifyHdl( LINK(this, ScAccessiblePreviewCellTextData
, NotifyHdl
) );
1286 SvxViewForwarder
* ScAccessiblePreviewCellTextData::GetViewForwarder()
1288 if (!mpViewForwarder
)
1289 mpViewForwarder
= new ScPreviewCellViewForwarder(mpViewShell
, aCellPos
);
1290 return mpViewForwarder
;
1293 ScDocShell
* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell
* pViewShell
)
1295 ScDocShell
* pDocSh
= NULL
;
1297 pDocSh
= static_cast<ScDocShell
*>( pViewShell
->GetDocument().GetDocumentShell());
1301 // ScAccessiblePreviewHeaderCellTextData: shared data between sub objects of a accessible cell text object
1303 ScAccessiblePreviewHeaderCellTextData::ScAccessiblePreviewHeaderCellTextData(ScPreviewShell
* pViewShell
,
1304 const OUString
& rText
, const ScAddress
& rP
, bool bColHeader
, bool bRowHeader
)
1305 : ScAccessibleCellBaseTextData(GetDocShell(pViewShell
), rP
),
1306 mpViewForwarder(NULL
),
1307 mpViewShell(pViewShell
),
1309 mbColHeader(bColHeader
),
1310 mbRowHeader(bRowHeader
)
1314 ScAccessiblePreviewHeaderCellTextData::~ScAccessiblePreviewHeaderCellTextData()
1317 pEditEngine
->SetNotifyHdl(Link
<>());
1318 if (mpViewForwarder
)
1319 delete mpViewForwarder
;
1322 void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1324 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
1327 sal_uLong nId
= pSimpleHint
->GetId();
1328 if ( nId
== SFX_HINT_DYING
)
1330 mpViewShell
= NULL
; // invalid now
1331 if (mpViewForwarder
)
1332 mpViewForwarder
->SetInvalid();
1335 ScAccessibleCellBaseTextData::Notify(rBC
, rHint
);
1338 ScAccessibleTextData
* ScAccessiblePreviewHeaderCellTextData::Clone() const
1340 return new ScAccessiblePreviewHeaderCellTextData(mpViewShell
, maText
, aCellPos
, mbColHeader
, mbRowHeader
);
1343 SvxTextForwarder
* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
1349 ScDocument
& rDoc
= pDocShell
->GetDocument();
1350 pEditEngine
= rDoc
.CreateFieldEditEngine();
1354 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1355 pEnginePool
->FreezeIdRanges();
1356 pEditEngine
= new ScFieldEditEngine(NULL
, pEnginePool
, NULL
, true);
1358 pEditEngine
->EnableUndo( false );
1360 pEditEngine
->SetRefDevice(pDocShell
->GetRefDevice());
1362 pEditEngine
->SetRefMapMode( MAP_100TH_MM
);
1363 pForwarder
= new SvxEditEngineForwarder(*pEditEngine
);
1369 if (!maText
.isEmpty())
1374 vcl::Window
* pWindow
= mpViewShell
->GetWindow();
1376 aOutputSize
= pWindow
->GetOutputSizePixel();
1378 Rectangle
aVisRect( aPoint
, aOutputSize
);
1379 Size
aSize(mpViewShell
->GetLocationData().GetHeaderCellOutputRect(aVisRect
, aCellPos
, mbColHeader
).GetSize());
1381 aSize
= pWindow
->PixelToLogic(aSize
, pEditEngine
->GetRefMapMode());
1382 pEditEngine
->SetPaperSize(aSize
);
1384 pEditEngine
->SetText( maText
);
1389 pEditEngine
->SetNotifyHdl( LINK(this, ScAccessiblePreviewHeaderCellTextData
, NotifyHdl
) );
1394 SvxViewForwarder
* ScAccessiblePreviewHeaderCellTextData::GetViewForwarder()
1396 if (!mpViewForwarder
)
1397 mpViewForwarder
= new ScPreviewHeaderCellViewForwarder(mpViewShell
, aCellPos
, mbColHeader
);
1398 return mpViewForwarder
;
1401 ScDocShell
* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell
* pViewShell
)
1403 ScDocShell
* pDocSh
= NULL
;
1405 pDocSh
= static_cast<ScDocShell
*>(pViewShell
->GetDocument().GetDocumentShell());
1409 ScAccessibleHeaderTextData::ScAccessibleHeaderTextData(ScPreviewShell
* pViewShell
,
1410 const EditTextObject
* pEditObj
, bool bHeader
, SvxAdjust eAdjust
)
1412 mpViewForwarder(NULL
),
1413 mpViewShell(pViewShell
),
1417 mpEditObj(pEditObj
),
1423 mpDocSh
= static_cast<ScDocShell
*>(pViewShell
->GetDocument().GetDocumentShell());
1425 mpDocSh
->GetDocument().AddUnoObject(*this);
1428 ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData()
1430 SolarMutexGuard aGuard
; // needed for EditEngine dtor
1433 mpDocSh
->GetDocument().RemoveUnoObject(*this);
1435 mpEditEngine
->SetNotifyHdl(Link
<>());
1436 delete mpEditEngine
;
1440 ScAccessibleTextData
* ScAccessibleHeaderTextData::Clone() const
1442 return new ScAccessibleHeaderTextData(mpViewShell
, mpEditObj
, mbHeader
, meAdjust
);
1445 void ScAccessibleHeaderTextData::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1447 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
1450 sal_uLong nId
= pSimpleHint
->GetId();
1451 if ( nId
== SFX_HINT_DYING
)
1453 mpViewShell
= NULL
;// invalid now
1455 if (mpViewForwarder
)
1456 mpViewForwarder
->SetInvalid();
1461 SvxTextForwarder
* ScAccessibleHeaderTextData::GetTextForwarder()
1465 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1466 pEnginePool
->FreezeIdRanges();
1467 ScHeaderEditEngine
* pHdrEngine
= new ScHeaderEditEngine( pEnginePool
, true );
1469 pHdrEngine
->EnableUndo( false );
1470 pHdrEngine
->SetRefMapMode( MAP_TWIP
);
1472 // default font must be set, independently of document
1473 // -> use global pool from module
1475 SfxItemSet
aDefaults( pHdrEngine
->GetEmptyItemSet() );
1476 const ScPatternAttr
& rPattern
= static_cast<const ScPatternAttr
&>(SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN
));
1477 rPattern
.FillEditItemSet( &aDefaults
);
1478 // FillEditItemSet adjusts font height to 1/100th mm,
1479 // but for header/footer twips is needed, as in the PatternAttr:
1480 aDefaults
.Put( rPattern
.GetItem(ATTR_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT
);
1481 aDefaults
.Put( rPattern
.GetItem(ATTR_CJK_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT_CJK
);
1482 aDefaults
.Put( rPattern
.GetItem(ATTR_CTL_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT_CTL
);
1483 aDefaults
.Put( SvxAdjustItem( meAdjust
, EE_PARA_JUST
) );
1484 pHdrEngine
->SetDefaults( aDefaults
);
1486 ScHeaderFieldData aData
;
1488 mpViewShell
->FillFieldData(aData
);
1490 ScHeaderFooterTextObj::FillDummyFieldData( aData
);
1491 pHdrEngine
->SetData( aData
);
1493 mpEditEngine
= pHdrEngine
;
1494 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1503 mpViewShell
->GetLocationData().GetHeaderPosition(aVisRect
);
1504 Size
aSize(aVisRect
.GetSize());
1505 vcl::Window
* pWin
= mpViewShell
->GetWindow();
1507 aSize
= pWin
->PixelToLogic(aSize
, mpEditEngine
->GetRefMapMode());
1508 mpEditEngine
->SetPaperSize(aSize
);
1511 mpEditEngine
->SetText(*mpEditObj
);
1517 SvxViewForwarder
* ScAccessibleHeaderTextData::GetViewForwarder()
1519 if (!mpViewForwarder
)
1520 mpViewForwarder
= new ScPreviewHeaderFooterViewForwarder(mpViewShell
, mbHeader
);
1521 return mpViewForwarder
;
1524 ScAccessibleNoteTextData::ScAccessibleNoteTextData(ScPreviewShell
* pViewShell
,
1525 const OUString
& sText
, const ScAddress
& aCellPos
, bool bMarkNote
)
1527 mpViewForwarder(NULL
),
1528 mpViewShell(pViewShell
),
1533 maCellPos(aCellPos
),
1534 mbMarkNote(bMarkNote
),
1538 mpDocSh
= static_cast<ScDocShell
*>(pViewShell
->GetDocument().GetDocumentShell());
1540 mpDocSh
->GetDocument().AddUnoObject(*this);
1543 ScAccessibleNoteTextData::~ScAccessibleNoteTextData()
1545 SolarMutexGuard aGuard
; // needed for EditEngine dtor
1548 mpDocSh
->GetDocument().RemoveUnoObject(*this);
1550 mpEditEngine
->SetNotifyHdl(Link
<>());
1551 delete mpEditEngine
;
1555 ScAccessibleTextData
* ScAccessibleNoteTextData::Clone() const
1557 return new ScAccessibleNoteTextData(mpViewShell
, msText
, maCellPos
, mbMarkNote
);
1560 void ScAccessibleNoteTextData::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1562 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
1565 sal_uLong nId
= pSimpleHint
->GetId();
1566 if ( nId
== SFX_HINT_DYING
)
1568 mpViewShell
= NULL
;// invalid now
1570 if (mpViewForwarder
)
1571 mpViewForwarder
->SetInvalid();
1576 SvxTextForwarder
* ScAccessibleNoteTextData::GetTextForwarder()
1582 ScDocument
& rDoc
= mpDocSh
->GetDocument();
1583 mpEditEngine
= rDoc
.CreateFieldEditEngine();
1587 SfxItemPool
* pEnginePool
= EditEngine::CreatePool();
1588 pEnginePool
->FreezeIdRanges();
1589 mpEditEngine
= new ScFieldEditEngine(NULL
, pEnginePool
, NULL
, true);
1591 mpEditEngine
->EnableUndo( false );
1593 mpEditEngine
->SetRefDevice(mpDocSh
->GetRefDevice());
1595 mpEditEngine
->SetRefMapMode( MAP_100TH_MM
);
1596 mpForwarder
= new SvxEditEngineForwarder(*mpEditEngine
);
1602 if (!msText
.isEmpty())
1608 vcl::Window
* pWindow
= mpViewShell
->GetWindow();
1610 aOutputSize
= pWindow
->GetOutputSizePixel();
1612 Rectangle
aVisRect( aPoint
, aOutputSize
);
1613 Size
aSize(mpViewShell
->GetLocationData().GetNoteInRangeOutputRect(aVisRect
, mbMarkNote
, maCellPos
).GetSize());
1615 aSize
= pWindow
->PixelToLogic(aSize
, mpEditEngine
->GetRefMapMode());
1616 mpEditEngine
->SetPaperSize(aSize
);
1618 mpEditEngine
->SetText( msText
);
1623 mpEditEngine
->SetNotifyHdl( LINK(this, ScAccessibleNoteTextData
, NotifyHdl
) );
1628 SvxViewForwarder
* ScAccessibleNoteTextData::GetViewForwarder()
1630 if (!mpViewForwarder
)
1631 mpViewForwarder
= new ScPreviewNoteViewForwarder(mpViewShell
, maCellPos
, mbMarkNote
);
1632 return mpViewForwarder
;
1635 // CSV import =================================================================
1637 class ScCsvViewForwarder
: public SvxViewForwarder
1639 Rectangle maBoundBox
;
1640 VclPtr
<vcl::Window
> mpWindow
;
1643 explicit ScCsvViewForwarder( vcl::Window
* pWindow
, const Rectangle
& rBoundBox
);
1645 virtual bool IsValid() const SAL_OVERRIDE
;
1646 virtual Rectangle
GetVisArea() const SAL_OVERRIDE
;
1647 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
1648 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const SAL_OVERRIDE
;
1653 ScCsvViewForwarder::ScCsvViewForwarder( vcl::Window
* pWindow
, const Rectangle
& rBoundBox
) :
1654 maBoundBox( rBoundBox
),
1659 bool ScCsvViewForwarder::IsValid() const
1661 return mpWindow
!= nullptr;
1664 Rectangle
ScCsvViewForwarder::GetVisArea() const
1669 Point
ScCsvViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
1671 if( !mpWindow
) return Point();
1672 return mpWindow
->LogicToPixel( rPoint
, rMapMode
);
1675 Point
ScCsvViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
1677 if( !mpWindow
) return Point();
1678 return mpWindow
->PixelToLogic( rPoint
, rMapMode
);
1681 void ScCsvViewForwarder::SetInvalid()
1686 ScAccessibleCsvTextData::ScAccessibleCsvTextData(
1687 vcl::Window
* pWindow
, EditEngine
* pEditEngine
,
1688 const OUString
& rCellText
, const Rectangle
& rBoundBox
, const Size
& rCellSize
) :
1689 mpWindow( pWindow
),
1690 mpEditEngine( pEditEngine
),
1691 maCellText( rCellText
),
1692 maBoundBox( rBoundBox
),
1693 maCellSize( rCellSize
)
1697 ScAccessibleCsvTextData::~ScAccessibleCsvTextData()
1701 void ScAccessibleCsvTextData::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1703 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
1706 sal_uLong nId
= pSimpleHint
->GetId();
1707 if( nId
== SFX_HINT_DYING
)
1710 mpEditEngine
= NULL
;
1711 if (mpViewForwarder
.get())
1712 mpViewForwarder
->SetInvalid();
1715 ScAccessibleTextData::Notify( rBC
, rHint
);
1718 ScAccessibleTextData
* ScAccessibleCsvTextData::Clone() const
1720 return new ScAccessibleCsvTextData( mpWindow
, mpEditEngine
, maCellText
, maBoundBox
, maCellSize
);
1723 SvxTextForwarder
* ScAccessibleCsvTextData::GetTextForwarder()
1727 mpEditEngine
->SetPaperSize( maCellSize
);
1728 mpEditEngine
->SetText( maCellText
);
1729 if( !mpTextForwarder
.get() )
1730 mpTextForwarder
.reset( new SvxEditEngineForwarder( *mpEditEngine
) );
1733 mpTextForwarder
.reset();
1734 return mpTextForwarder
.get();
1737 SvxViewForwarder
* ScAccessibleCsvTextData::GetViewForwarder()
1739 if( !mpViewForwarder
.get() )
1740 mpViewForwarder
.reset( new ScCsvViewForwarder( mpWindow
, maBoundBox
) );
1741 return mpViewForwarder
.get();
1744 SvxEditViewForwarder
* ScAccessibleCsvTextData::GetEditViewForwarder( bool /* bCreate */ )
1749 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */