20#include <com/sun/star/geometry/RealPoint2D.hpp>
21#include <com/sun/star/office/XAnnotation.hpp>
23#include <rtl/ustrbuf.hxx>
65 OUStringBuffer sInitials;
68 sal_Int32
nLength = rName.getLength();
73 while(
nLength && (*pStr <=
' ') )
81 sInitials.append(*pStr);
86 while(
nLength && (*pStr >
' ') )
92 return sInitials.makeStringAndClear();
101 virtual bool BeginSdrDrag()
override;
102 virtual bool EndSdrDrag(
bool bCopy)
override;
103 virtual void MoveSdrDrag(
const Point& rNoSnapPnt)
override;
104 virtual void CancelSdrDrag()
override;
115, mxTag(
std::move( xTag ))
119bool AnnotationDragMove::BeginSdrDrag()
121 DragStat().SetRef1(GetDragHdl()->GetPos());
122 DragStat().SetShown(!DragStat().IsShown());
130void AnnotationDragMove::MoveSdrDrag(
const Point& rNoSnapPnt)
132 Point aPnt(rNoSnapPnt);
134 if (DragStat().CheckMinMoved(rNoSnapPnt))
136 if (aPnt!=DragStat().GetNow())
139 DragStat().NextMove(aPnt);
140 GetDragHdl()->SetPos( maOrigin +
Point( DragStat().GetDX(), DragStat().GetDY() ) );
147bool AnnotationDragMove::EndSdrDrag(
bool )
151 mxTag->Move( DragStat().GetDX(), DragStat().GetDY() );
155void AnnotationDragMove::CancelSdrDrag()
162class AnnotationHdl :
public SmartHdl
165 AnnotationHdl(
const SmartTagReference& xTag,
const Reference< XAnnotation >& xAnnotation,
const Point& rPnt );
167 virtual void CreateB2dIAObject()
override;
168 virtual bool IsFocusHdl()
const override;
171 Reference< XAnnotation > mxAnnotation;
177AnnotationHdl::AnnotationHdl(
const SmartTagReference& xTag,
const Reference< XAnnotation >& xAnnotation,
const Point& rPnt )
179, mxAnnotation( xAnnotation )
180, mxTag( dynamic_cast< AnnotationTag* >( xTag.
get() ) )
184void AnnotationHdl::CreateB2dIAObject()
189 if (!mxAnnotation.is())
194 const Point aTagPos( GetPos() );
197 const bool bFocused = IsFocusHdl() && pHdlList && (pHdlList->GetFocusHdl() ==
this);
199 BitmapEx aBitmapEx( mxTag->CreateAnnotationBitmap(mxTag->isSelected()) );
202 aBitmapEx2 = mxTag->CreateAnnotationBitmap(!mxTag->isSelected() );
226 std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject;
228 auto* pAnnotation =
dynamic_cast<sd::Annotation*
>(mxAnnotation.get());
230 if (pAnnotation && pAnnotation->hasCustomAnnotationMarker())
234 auto& rPolygons = rCustomAnnotationMarker.
maPolygons;
235 if (!rPolygons.empty())
238 for (
auto const & rPolygon : rPolygons)
239 aPolyPolygon.
append(rPolygon);
242 std::move(aPolyPolygon),
243 rCustomAnnotationMarker.maLineColor,
244 rCustomAnnotationMarker.mnLineWidth,
245 rCustomAnnotationMarker.maFillColor));
264 insertNewlyCreatedOverlayObjectForSdrHdl(
265 std::move(pOverlayObject),
272bool AnnotationHdl::IsFocusHdl()
const
279, mrManager( rManager )
280, mxAnnotation( xAnnotation )
284, mpListenWindow( nullptr )
371 if (rCEvt.
GetCommand() != CommandEventId::ContextMenu)
392 aPosition.X +=
static_cast<double>(nDX) / 100.0;
393 aPosition.Y +=
static_cast<double>(nDY) / 100.0;
409 case KEY_UP: nY = -1;
break;
420 nX *= aLogicSizeOnePixel.
Width();
421 nY *= aLogicSizeOnePixel.
Height();
474 std::unique_ptr<AnnotationHdl> pHdl(
new AnnotationHdl( xThis,
mxAnnotation,
Point() ));
480 pHdl->SetPos( aBasePos );
482 rHandlerList.
AddHdl( std::move(pHdl) );
529 if (pAnnotation && pAnnotation->isFreeText())
536 if (sInitials.isEmpty())
541 sText = sInitials +
" " + OUString::number(
mnIndex);
546 const int BORDER_X = 4;
547 const int BORDER_Y = 4;
549 maSize =
Size(pVDev->GetTextWidth(sText) + 2 * BORDER_X, pVDev->GetTextHeight() + 2 * BORDER_Y);
550 pVDev->SetOutputSizePixel(
maSize,
false );
572 pVDev->SetLineColor(aBorderColor);
574 pVDev->DrawRect( aBorderRect );
577 pVDev->DrawText(
Point(BORDER_X, BORDER_Y), sText);
579 return pVDev->GetBitmapEx( aPos,
maSize );
632 if( pWindow != mpListenWindow )
635 switch( rEvent.GetId() )
637 case VclEventId::WindowMouseButtonUp:
640 mpListenWindow->RemoveEventListener(
LINK(
this,
AnnotationTag, WindowEventHandler));
641 mpListenWindow =
nullptr;
642 if( !mpAnnotationWindow )
646 case VclEventId::WindowMouseMove:
649 mpListenWindow->RemoveEventListener(
LINK(
this,
AnnotationTag, WindowEventHandler));
650 mpListenWindow =
nullptr;
661 mrView.BegDragObj(maMouseDownPos,
nullptr, pHdl, nDrgLog, pDragMethod );
665 case VclEventId::ObjectDying:
666 mpListenWindow =
nullptr;
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
void DecreaseLuminance(sal_uInt8 cLumDec)
void IncreaseLuminance(sal_uInt8 cLumInc)
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
const vcl::KeyCode & GetKeyCode() const
const Point & GetPosPixel() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
void AddHdl(std::unique_ptr< SdrHdl > pHdl)
bool areMarkHandlesHidden() const
bool IsUndoEnabled() const
sal_uInt32 PageWindowCount() const
SdrPageWindow * GetPageWindow(sal_uInt32 nIndex) const
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
SdrPaintWindow & GetPaintWindow() const
const sdr::contact::ObjectContact & GetObjectContact() const
OutputDevice * GetFirstOutputDevice() const
virtual void MakeVisible(const tools::Rectangle &rRect, vcl::Window &rWin)
SdrPageView * GetSdrPageView() const
bool OutputToWindow() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
sal_uInt64 GetCursorBlinkTime() const
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
void onTagSelected(AnnotationTag const &rTag)
SdDrawDocument * GetDoc()
void SelectNextAnnotation(bool bForward)
void onTagDeselected(AnnotationTag const &rTag)
void DeleteAnnotation(const css::uno::Reference< css::office::XAnnotation > &xAnnotation)
void ExecuteAnnotationTagContextMenu(const css::uno::Reference< css::office::XAnnotation > &xAnnotation, weld::Widget *pParent, const ::tools::Rectangle &rContextRect)
void OpenPopup(bool bEdit)
BitmapEx CreateAnnotationBitmap(bool)
std::unique_ptr< AnnotationWindow > mpAnnotationWindow
virtual bool MarkPoints(const ::tools::Rectangle *pRect, bool bUnmark) override
virtual void addCustomHandles(SdrHdlList &rHandlerList) override
virtual void select() override
AnnotationManagerImpl & mrManager
virtual bool MouseButtonDown(const MouseEvent &, SmartHdl &) override
returns true if the AnnotationTag handled the event.
virtual bool getContext(SdrViewContext &rContext) override
VclPtr< vcl::Window > mpListenWindow
bool OnMove(const KeyEvent &rKEvt)
virtual bool Command(const CommandEvent &rCEvt) override
returns true if the SmartTag consumes this event.
virtual ~AnnotationTag() override
css::uno::Reference< css::office::XAnnotation > mxAnnotation
virtual void disposing() override
void Move(int nDX, int nDY)
virtual bool KeyInput(const KeyEvent &rKEvt) override
returns true if the SmartTag consumes this event.
virtual void CheckPossibilities() override
virtual bool MarkPoint(SdrHdl &rHdl, bool bUnmark) override
virtual sal_Int32 GetMarkablePointCount() const override
virtual void deselect() override
virtual sal_Int32 GetMarkedPointCount() const override
CustomAnnotationMarker & getCustomAnnotationMarker()
a derivation from this handle is the visual representation for a smart tag.
a smart tag represents a visual user interface element on the documents edit view that is not part of...
virtual void disposing() override
::sd::View & getView() const
bool isSelected() const
returns true if this smart tag is currently selected
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
DrawDocShell * GetDocSh() const
ViewShell * GetViewShell() const
SmartTagSet & getSmartTags()
sal_uInt16 GetCode() const
Point LogicToPixel(const Point &rLogicPt) const
::OutputDevice const * GetOutDev() const
Point PixelToLogic(const Point &rDevicePt) const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_SPACE
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
rtl::Reference< SmartTag > SmartTagReference
IMPL_LINK(SdCharHeightPropertyBox, implMenuSelectHdl, const OUString &, rIdent, void)
static OUString getInitials(const OUString &rName)
const sal_uInt32 SMART_TAG_HDL_NUM
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
OUString SdResId(TranslateId aId)
std::vector< basegfx::B2DPolygon > maPolygons