Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / vcl / ITiledRenderable.hxx
blobbe6c050ad36dc781bd680fefd49f2fa11b3fc9b5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 */
11 #pragma once
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>
19 #include <map>
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; }
30 class VirtualDevice;
32 namespace vcl
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
48 public:
50 typedef std::map<OUString, OUString> StringMap;
52 virtual ~ITiledRenderable();
54 /**
55 * Paint a tile to a given VirtualDevice.
57 * Output parameters are measured in pixels, tile parameters are in
58 * twips.
60 virtual void paintTile( VirtualDevice &rDevice,
61 int nOutputWidth,
62 int nOutputHeight,
63 int nTilePosX,
64 int nTilePosY,
65 tools::Long nTileWidth,
66 tools::Long nTileHeight ) = 0;
68 /**
69 * Get the document size in twips.
71 virtual Size getDocumentSize() = 0;
73 /**
74 * Get the data area size (in Calc last column and row).
76 virtual Size getDataArea(long /*nPart*/)
78 return Size(1, 1);
81 /**
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 ) {}
89 /**
90 * Get the number of parts -- see setPart for further details.
92 virtual int getParts()
94 return 1;
97 /**
98 * Get the currently displayed/selected part -- see setPart for further
99 * details.
101 virtual int getPart()
103 return 0;
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)
112 return OUString();
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()
134 return 0;
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 selection as a transferable for later processing
172 virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() = 0;
175 * Adjusts the graphic selection.
177 * @see lok::Document::setGraphicSelection().
179 virtual void setGraphicSelection(int nType, int nX, int nY) = 0;
182 * @see lok::Document::resetSelection().
184 virtual void resetSelection() = 0;
187 * @see lok::Document::getPartPageRectangles().
189 virtual OUString getPartPageRectangles()
191 return OUString();
195 * Get position and content of row/column headers of Calc documents.
197 * @param rRectangle - if not empty, then limit the output only to the area of this rectangle
198 * @return a JSON describing position/content of rows/columns
200 virtual void getRowColumnHeaders(const tools::Rectangle& /*rRectangle*/, tools::JsonWriter& /*rJsonWriter*/)
205 * Generates a serialization of the active (Calc document) sheet's geometry data.
207 * @param bColumns - if true, the column widths/hidden/filtered/groups data
208 * are included depending on the settings of the flags bSizes, bHidden,
209 * bFiltered and bGroups.
210 * @param bRows - if true, the row heights/hidden/filtered/groups data
211 * are included depending on the settings of the flags bSizes, bHidden,
212 * bFiltered and bGroups.
213 * @bSizes - if true, the column-widths and/or row-heights data (represented as a list of spans)
214 * are included depending on the settings of the flags bColumns and bRows.
215 * @bHidden - if true, the hidden columns and/or rows data (represented as a list of spans)
216 * are included depending on the settings of the flags bColumns and bRows.
217 * @bFiltered - if true, the filtered columns and/or rows data (represented as a list of spans)
218 * are included depending on the settings of the flags bColumns and bRows.
219 * @bGroups - if true, the column grouping and/or row grouping data
220 * are included depending on the settings of the flags bColumns and bRows.
221 * @return serialization of the active sheet's geometry data as OString.
223 virtual OString getSheetGeometryData(bool /*bColumns*/, bool /*bRows*/, bool /*bSizes*/,
224 bool /*bHidden*/, bool /*bFiltered*/, bool /*bGroups*/)
226 return ""_ostr;
230 * Get position and size of cell cursor in Calc - as JSON in the
231 * current' views' co-ordinate system.
232 * (This could maybe also be used for tables in Writer/Impress in future?)
234 virtual void getCellCursor(tools::JsonWriter& /*rJsonWriter*/)
238 virtual PointerStyle getPointer() = 0;
240 /// Sets the clipboard of the component.
241 virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
243 /// If the current contents of the clipboard is something we can paste.
244 virtual bool isMimeTypeSupported() = 0;
247 * Save the client's view so that we can compute the right zoom level
248 * for the mouse events.
249 * @param nTilePixelWidth - tile width in pixels
250 * @param nTilePixelHeight - tile height in pixels
251 * @param nTileTwipWidth - tile width in twips
252 * @param nTileTwipHeight - tile height in twips
254 virtual void setClientZoom(int /*nTilePixelWidth*/,
255 int /*nTilePixelHeight*/,
256 int /*nTileTwipWidth*/,
257 int /*nTileTwipHeight*/)
260 /// @see lok::Document::setClientVisibleArea().
261 virtual void setClientVisibleArea(const tools::Rectangle& /*rRectangle*/)
266 * Show/Hide a single row/column header outline for Calc documents.
268 * @param bColumn - if we are dealing with a column or row group
269 * @param nLevel - the level to which the group belongs
270 * @param nIndex - the group entry index
271 * @param bHidden - the new group state (collapsed/expanded)
273 virtual void setOutlineState(bool /*bColumn*/, int /*nLevel*/, int /*nIndex*/, bool /*bHidden*/)
275 return;
278 /// Implementation for
279 /// lok::Document::getCommandValues(".uno:AcceptTrackedChanges") when there
280 /// is no matching UNO API.
281 virtual void getTrackedChanges(tools::JsonWriter&)
285 /// Implementation for
286 /// lok::Document::getCommandValues(".uno:TrackedChangeAuthors").
287 virtual void getTrackedChangeAuthors(tools::JsonWriter& /*rJsonWriter*/)
291 /// Implementation for
292 /// lok::Document::getCommandValues(".uno:ViewAnnotations");
293 virtual void getPostIts(tools::JsonWriter& /*rJsonWriter*/)
297 /// Implementation for
298 /// lok::Document::getCommandValues(".uno:ViewAnnotationsPosition");
299 virtual void getPostItsPos(tools::JsonWriter& /*rJsonWriter*/)
303 /// Implementation for
304 /// lok::Document::getCommandValues(".uno:RulerState");
305 virtual void getRulerState(tools::JsonWriter& /*rJsonWriter*/)
310 * Used for sheets in spreadsheet documents,
311 * and slides in presentation documents.
313 virtual OUString getPartInfo(int /*nPart*/)
315 return OUString();
319 * Select/Unselect a document "part", i.e. slide for a slideshow, and
320 * tab for a spreadsheet(?).
321 * nSelect: 0 to deselect, 1 to select, and 2 to toggle.
323 virtual void selectPart(int /*nPart*/, int /*nSelect*/) {}
326 * Move selected pages/slides to a new position.
327 * nPosition: the new position to move to.
328 * bDuplicate: to copy (true), or to move (false).
330 virtual void moveSelectedParts(int /*nPosition*/, bool /*bDuplicate*/) {}
332 /// @see lok::Document::completeFunction().
333 virtual void completeFunction(const OUString& /*rFunctionName*/)
338 * It can happen that the underlying implementation is being disposed, but
339 * somebody is trying to access the data...
341 virtual bool isDisposed() const
343 return false;
347 * Execute a form field event in the document.
348 * E.g. select an item from a drop down field's list.
350 virtual void executeFromFieldEvent(const StringMap&)
355 * Returns the rectangles of the input search result JSON
357 virtual std::vector<basegfx::B2DRange> getSearchResultRectangles(const char* /*pPayload*/)
359 return std::vector<basegfx::B2DRange>();
363 * Execute a content control event in the document.
364 * E.g. select a list item from a drop down content control.
366 virtual void executeContentControlEvent(const StringMap&) {}
369 * Allow / disable drawing current text edit (used in Impress for slide previews)
371 virtual void setPaintTextEdit(bool) {}
373 /// Decides if it's OK to call getCommandValues(rCommand).
374 virtual bool supportsCommand(std::u16string_view /*rCommand*/) { return false; }
376 /// Returns a json mapping of the possible values for the given command.
377 virtual void getCommandValues(tools::JsonWriter& /*rJsonWriter*/, std::string_view /*rCommand*/)
382 * Returns an opaque string reflecting the render state of a component
383 * eg. 'PD' - P for non-printing-characters, D for dark-mode.
384 * @param pViewShell the view to get the options from, if nullptr the current view shell is used
386 virtual OString getViewRenderState(SfxViewShell* = nullptr) { return rtl::OString(); }
388 } // namespace vcl
390 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */