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/.
13 #include <sfx2/viewsh.hxx>
14 #include <tools/gen.hxx>
15 #include <rtl/ustring.hxx>
16 #include <vcl/dllapi.h>
17 #include <vcl/ptrstyle.hxx>
18 #include <vcl/vclptr.hxx>
20 #include <com/sun/star/datatransfer/XTransferable.hpp>
21 #include <basegfx/range/b2drange.hxx>
23 namespace com::sun::star::beans
{ struct PropertyValue
; }
24 namespace com::sun::star::datatransfer::clipboard
{ class XClipboard
; }
25 namespace com::sun::star::uno
{ template <class interface_type
> class Reference
; }
26 namespace com::sun::star::uno
{ template <typename
> class Sequence
; }
27 namespace vcl
{ class Window
; }
28 namespace tools
{ class JsonWriter
; }
35 * Map directly to css cursor styles to avoid further mapping in the client.
36 * Gtk (via gdk_cursor_new_from_name) also supports the same css cursor styles.
38 * This was created partially with help of the mappings in gtkdata.cxx.
39 * The list is incomplete as some cursor style simply aren't supported
40 * by css, it might turn out to be worth mapping some of these missing cursors
41 * to available cursors?
43 extern const std::map
<PointerStyle
, OString
> gaLOKPointerMap
;
46 class VCL_DLLPUBLIC
SAL_LOPLUGIN_ANNOTATE("crosscast") ITiledRenderable
50 typedef std::map
<OUString
, OUString
> StringMap
;
52 virtual ~ITiledRenderable();
55 * Paint a tile to a given VirtualDevice.
57 * Output parameters are measured in pixels, tile parameters are in
60 virtual void paintTile( VirtualDevice
&rDevice
,
65 tools::Long nTileWidth
,
66 tools::Long nTileHeight
) = 0;
69 * Get the document size in twips.
71 virtual Size
getDocumentSize() = 0;
74 * Get the data area size (in Calc last column and row).
76 virtual Size
getDataArea(long /*nPart*/)
82 * Set the document "part", i.e. slide for a slideshow, and
83 * tab for a spreadsheet.
84 * bool bAllowChangeFocus - used to not disturb other users while editing when
85 * setPart is used for tile rendering only
87 virtual void setPart( int /*nPart*/, bool /*bAllowChangeFocus*/ = true ) {}
90 * Get the number of parts -- see setPart for further details.
92 virtual int getParts()
98 * Get the currently displayed/selected part -- see setPart for further
101 virtual int getPart()
107 * Get the name of the currently displayed part, i.e. sheet in a spreadsheet
108 * or slide in a presentation.
110 virtual OUString
getPartName(int)
116 * Get the vcl::Window for the document being edited
118 virtual VclPtr
<vcl::Window
> getDocWindow() = 0;
121 * Get the hash of the currently displayed part, i.e. sheet in a spreadsheet
122 * or slide in a presentation.
124 virtual OUString
getPartHash(int nPart
) = 0;
126 /// @see lok::Document::setPartMode().
127 virtual void setPartMode(int) {}
130 * Get the currently used EditMode (supported in Impress).
132 virtual int getEditMode()
138 * Set the currently used EditMode (supported in Impress).
140 virtual void setEditMode(int) {}
143 * Setup various document properties that are needed for the document to
144 * be renderable via tiled rendering.
146 virtual void initializeForTiledRendering(const css::uno::Sequence
<css::beans::PropertyValue
>& rArguments
) = 0;
149 * Posts a keyboard event on the document.
151 * @see lok::Document::postKeyEvent().
153 virtual void postKeyEvent(int nType
, int nCharCode
, int nKeyCode
) = 0;
156 * Posts a mouse event on the document.
158 * @see lok::Document::postMouseEvent().
160 virtual void postMouseEvent(int nType
, int nX
, int nY
, int nCount
, int nButtons
, int nModifier
) = 0;
163 * Sets the start or end of a text selection.
165 * @see lok::Document::setTextSelection().
167 virtual void setTextSelection(int nType
, int nX
, int nY
) = 0;
170 * Gets the info of hyperlink under the mouse position if any.
171 * @see lok::Document::hyperlinkInfoAtPosition().
173 virtual OUString
hyperlinkInfoAtPosition(int x
, int y
) = 0;
176 * Gets the selection as a transferable for later processing
178 virtual css::uno::Reference
<css::datatransfer::XTransferable
> getSelection() = 0;
181 * Adjusts the graphic selection.
183 * @see lok::Document::setGraphicSelection().
185 virtual void setGraphicSelection(int nType
, int nX
, int nY
) = 0;
188 * @see lok::Document::resetSelection().
190 virtual void resetSelection() = 0;
193 * @see lok::Document::getPartPageRectangles().
195 virtual OUString
getPartPageRectangles()
201 * Get position and content of row/column headers of Calc documents.
203 * @param rRectangle - if not empty, then limit the output only to the area of this rectangle
204 * @return a JSON describing position/content of rows/columns
206 virtual void getRowColumnHeaders(const tools::Rectangle
& /*rRectangle*/, tools::JsonWriter
& /*rJsonWriter*/)
211 * Generates a serialization of the active (Calc document) sheet's geometry data.
213 * @param bColumns - if true, the column widths/hidden/filtered/groups data
214 * are included depending on the settings of the flags bSizes, bHidden,
215 * bFiltered and bGroups.
216 * @param bRows - if true, the row heights/hidden/filtered/groups data
217 * are included depending on the settings of the flags bSizes, bHidden,
218 * bFiltered and bGroups.
219 * @bSizes - if true, the column-widths and/or row-heights data (represented as a list of spans)
220 * are included depending on the settings of the flags bColumns and bRows.
221 * @bHidden - if true, the hidden columns and/or rows data (represented as a list of spans)
222 * are included depending on the settings of the flags bColumns and bRows.
223 * @bFiltered - if true, the filtered columns and/or rows data (represented as a list of spans)
224 * are included depending on the settings of the flags bColumns and bRows.
225 * @bGroups - if true, the column grouping and/or row grouping data
226 * are included depending on the settings of the flags bColumns and bRows.
227 * @return serialization of the active sheet's geometry data as OString.
229 virtual OString
getSheetGeometryData(bool /*bColumns*/, bool /*bRows*/, bool /*bSizes*/,
230 bool /*bHidden*/, bool /*bFiltered*/, bool /*bGroups*/)
236 * Get position and size of cell cursor in Calc - as JSON in the
237 * current' views' co-ordinate system.
238 * (This could maybe also be used for tables in Writer/Impress in future?)
240 virtual void getCellCursor(tools::JsonWriter
& /*rJsonWriter*/)
244 virtual PointerStyle
getPointer() = 0;
246 /// Sets the clipboard of the component.
247 virtual void setClipboard(const css::uno::Reference
<css::datatransfer::clipboard::XClipboard
>& xClipboard
) = 0;
249 /// If the current contents of the clipboard is something we can paste.
250 virtual bool isMimeTypeSupported() = 0;
253 * Save the client's view so that we can compute the right zoom level
254 * for the mouse events.
255 * @param nTilePixelWidth - tile width in pixels
256 * @param nTilePixelHeight - tile height in pixels
257 * @param nTileTwipWidth - tile width in twips
258 * @param nTileTwipHeight - tile height in twips
260 virtual void setClientZoom(int /*nTilePixelWidth*/,
261 int /*nTilePixelHeight*/,
262 int /*nTileTwipWidth*/,
263 int /*nTileTwipHeight*/)
266 /// @see lok::Document::setClientVisibleArea().
267 virtual void setClientVisibleArea(const tools::Rectangle
& /*rRectangle*/)
272 * Show/Hide a single row/column header outline for Calc documents.
274 * @param bColumn - if we are dealing with a column or row group
275 * @param nLevel - the level to which the group belongs
276 * @param nIndex - the group entry index
277 * @param bHidden - the new group state (collapsed/expanded)
279 virtual void setOutlineState(bool /*bColumn*/, int /*nLevel*/, int /*nIndex*/, bool /*bHidden*/)
284 /// Implementation for
285 /// lok::Document::getCommandValues(".uno:AcceptTrackedChanges") when there
286 /// is no matching UNO API.
287 virtual void getTrackedChanges(tools::JsonWriter
&)
291 /// Implementation for
292 /// lok::Document::getCommandValues(".uno:TrackedChangeAuthors").
293 virtual void getTrackedChangeAuthors(tools::JsonWriter
& /*rJsonWriter*/)
297 /// Implementation for
298 /// lok::Document::getCommandValues(".uno:ViewAnnotations");
299 virtual void getPostIts(tools::JsonWriter
& /*rJsonWriter*/)
303 /// Implementation for
304 /// lok::Document::getCommandValues(".uno:ViewAnnotationsPosition");
305 virtual void getPostItsPos(tools::JsonWriter
& /*rJsonWriter*/)
309 /// Implementation for
310 /// lok::Document::getCommandValues(".uno:RulerState");
311 virtual void getRulerState(tools::JsonWriter
& /*rJsonWriter*/)
316 * Used for sheets in spreadsheet documents,
317 * and slides in presentation documents.
319 virtual OUString
getPartInfo(int /*nPart*/)
325 * Select/Unselect a document "part", i.e. slide for a slideshow, and
326 * tab for a spreadsheet(?).
327 * nSelect: 0 to deselect, 1 to select, and 2 to toggle.
329 virtual void selectPart(int /*nPart*/, int /*nSelect*/) {}
332 * Move selected pages/slides to a new position.
333 * nPosition: the new position to move to.
334 * bDuplicate: to copy (true), or to move (false).
336 virtual void moveSelectedParts(int /*nPosition*/, bool /*bDuplicate*/) {}
338 /// @see lok::Document::completeFunction().
339 virtual void completeFunction(const OUString
& /*rFunctionName*/)
344 * It can happen that the underlying implementation is being disposed, but
345 * somebody is trying to access the data...
347 virtual bool isDisposed() const
353 * Execute a form field event in the document.
354 * E.g. select an item from a drop down field's list.
356 virtual void executeFromFieldEvent(const StringMap
&)
361 * Returns the rectangles of the input search result JSON
363 virtual std::vector
<basegfx::B2DRange
> getSearchResultRectangles(const char* /*pPayload*/)
365 return std::vector
<basegfx::B2DRange
>();
369 * Execute a content control event in the document.
370 * E.g. select a list item from a drop down content control.
372 virtual void executeContentControlEvent(const StringMap
&) {}
375 * Allow / disable drawing current text edit (used in Impress for slide previews)
377 virtual void setPaintTextEdit(bool) {}
379 /// Decides if it's OK to call getCommandValues(rCommand).
380 virtual bool supportsCommand(std::u16string_view
/*rCommand*/) { return false; }
382 /// Returns a json mapping of the possible values for the given command.
383 virtual void getCommandValues(tools::JsonWriter
& /*rJsonWriter*/, std::string_view
/*rCommand*/)
388 * Returns an opaque string reflecting the render state of a component
389 * eg. 'PD' - P for non-printing-characters, D for dark-mode.
390 * @param pViewShell the view to get the options from, if nullptr the current view shell is used
392 virtual OString
getViewRenderState(SfxViewShell
* = nullptr) { return rtl::OString(); }
396 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */