LibreOffice Module sw (master) 1
swevent.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SW_INC_SWEVENT_HXX
21#define INCLUDED_SW_INC_SWEVENT_HXX
22
23#include "calbck.hxx"
24#include "frmfmt.hxx"
25#include "hints.hxx"
26
27#define STR_SW_EVENT_PAGE_COUNT 0
28#define STR_SW_EVENT_MAIL_MERGE 1
29#define STR_SW_EVENT_MAIL_MERGE_END 2
30#define STR_SW_EVENT_FIELD_MERGE 3
31#define STR_SW_EVENT_FIELD_MERGE_FINISHED 4
32#define STR_SW_EVENT_LAYOUT_FINISHED 5
33#define STR_SW_EVENT_OBJECT_SELECT 6
34#define STR_SW_EVENT_START_INS_GLOSSARY 7
35#define STR_SW_EVENT_END_INS_GLOSSARY 8
36#define STR_SW_EVENT_FRM_KEYINPUT_ALPHA 9
37#define STR_SW_EVENT_FRM_KEYINPUT_NOALPHA 10
38#define STR_SW_EVENT_FRM_RESIZE 11
39#define STR_SW_EVENT_FRM_MOVE 12
40
42class IMapObject;
43
44// Enum for objects that call events into Basic or JavaScript.
46{
47 EVENT_OBJECT_NONE = 0, // Null is nothing at all.
52};
53
54// Structure for the exchange between UI/CORE.
55
56struct SwCallMouseEvent final
57 : public SwClient
58{
60 union
61 {
62 // EVENT_OBJECT_IMAGE/EVENT_OBJECT_URLITEM
64
65 // EVENT_OBJECT_INETATTR
67
68 // EVENT_OBJECT_IMAGEMAP
69 struct
70 {
74 } PTR;
75
78 { PTR.pFormat = nullptr; PTR.IMAP.pIMapObj = nullptr; }
79
82 , eType(rOther.eType)
83 {
84 memcpy(&PTR, &rOther.PTR, sizeof(PTR));
85 }
86
88 { Clear(); eType = eTyp; PTR.pFormat = pFormat; PTR.IMAP.pIMapObj = nullptr; assert(pFormat); const_cast<SwFrameFormat*>(pFormat)->Add(this); }
89
91 { Clear(); eType = EVENT_OBJECT_IMAGEMAP; PTR.pFormat = pFormat; PTR.IMAP.pIMapObj = pIMapObj; assert(pFormat); const_cast<SwFrameFormat*>(pFormat)->Add(this); }
92
94 { Clear(); eType = EVENT_OBJECT_INETATTR; PTR.pINetAttr = pINetAttr; PTR.IMAP.pIMapObj = nullptr; }
95
96 bool operator==( const SwCallMouseEvent& rEvent ) const
97 {
98 return eType == rEvent.eType &&
99 PTR.pFormat == rEvent.PTR.pFormat &&
100 PTR.IMAP.pIMapObj == rEvent.PTR.IMAP.pIMapObj;
101 }
102 bool operator!=( const SwCallMouseEvent& rEvent ) const
103 { return !( *this == rEvent ); }
104
105 void Clear()
106 {
108 {
109 // note: pFormat is not necessarily the same as
110 // GetRegisteredIn() here; see ~SwFormat()
111 assert(PTR.pFormat);
113 }
114 eType = EVENT_OBJECT_NONE; PTR.pFormat = nullptr; PTR.IMAP.pIMapObj = nullptr;
115 }
116
117 bool HasEvent() const { return EVENT_OBJECT_NONE != eType; }
118
119 virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override
120 {
121 if (rHint.GetId() != SfxHintId::SwLegacyModify)
122 return;
123 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
125 SwClient::SwClientNotify(rMod, rHint);
126 bool bClear = !GetRegisteredIn();
127 switch(pLegacy->GetWhich())
128 {
129 case RES_FMT_CHG:
130 bClear |= pLegacy->m_pOld->StaticWhichCast(RES_FMT_CHG).pChangedFormat == PTR.pFormat;
131 break;
133 bClear |= pLegacy->m_pOld->StaticWhichCast(RES_REMOVE_UNO_OBJECT).pObject == PTR.pFormat;
134 }
135 if(bClear)
136 Clear();
137 }
138};
139
140#endif
141
142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxHintId GetId() const
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:166
void EndListeningAll()
Definition: calbck.cxx:136
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:120
SwModify * GetRegisteredInNonConst() const
Definition: calbck.hxx:148
Style of a layout element.
Definition: frmfmt.hxx:72
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(168)
bool operator==(const SwCallMouseEvent &rEvent) const
Definition: swevent.hxx:96
virtual void SwClientNotify(const SwModify &rMod, const SfxHint &rHint) override
Definition: swevent.hxx:119
const IMapObject * pIMapObj
Definition: swevent.hxx:72
bool HasEvent() const
Definition: swevent.hxx:117
SwCallEventObjectType eType
Definition: swevent.hxx:59
void Set(const SwFrameFormat *pFormat, const IMapObject *pIMapObj)
Definition: swevent.hxx:90
void Set(const SwFormatINetFormat *pINetAttr)
Definition: swevent.hxx:93
union SwCallMouseEvent::@24 PTR
const SwFrameFormat * pFormat
Definition: swevent.hxx:63
void Set(SwCallEventObjectType eTyp, const SwFrameFormat *pFormat)
Definition: swevent.hxx:87
const SwFormatINetFormat * pINetAttr
Definition: swevent.hxx:66
SwCallMouseEvent(SwCallMouseEvent const &rOther)
Definition: swevent.hxx:80
bool operator!=(const SwCallMouseEvent &rEvent) const
Definition: swevent.hxx:102
struct SwCallMouseEvent::@24::@25 IMAP
SwCallEventObjectType
Definition: swevent.hxx:46
@ EVENT_OBJECT_NONE
Definition: swevent.hxx:47
@ EVENT_OBJECT_URLITEM
Definition: swevent.hxx:50
@ EVENT_OBJECT_IMAGEMAP
Definition: swevent.hxx:51
@ EVENT_OBJECT_IMAGE
Definition: swevent.hxx:48
@ EVENT_OBJECT_INETATTR
Definition: swevent.hxx:49