Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / svtools / DocumentToGraphicRenderer.hxx
bloba5dc8e115a8e4e19ff255391df379fbbe7163f28
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 * 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 .
21 #pragma once
23 #include <vector>
25 #include <vcl/graph.hxx>
27 #include <svtools/svtdllapi.h>
29 namespace com :: sun :: star :: awt { class XToolkit; }
30 namespace com :: sun :: star :: frame { class XModel; }
31 namespace com :: sun :: star :: lang { class XComponent; }
32 namespace com :: sun :: star :: view { class XRenderable; }
34 namespace com::sun::star {
35 namespace drawing {
36 class XShapes;
37 class XShape;
39 namespace frame {
40 class XController;
44 class SVT_DLLPUBLIC DocumentToGraphicRenderer
46 const css::uno::Reference<css::lang::XComponent>& mxDocument;
48 enum DocType {
49 WRITER,
50 CALC,
51 IMPRESS,
52 UNKNOWN
55 css::uno::Reference<css::frame::XModel> mxModel;
56 css::uno::Reference<css::frame::XController> mxController;
57 css::uno::Reference<css::view::XRenderable> mxRenderable;
58 css::uno::Reference<css::awt::XToolkit> mxToolkit;
59 css::uno::Any maSelection;
60 DocType meDocType;
61 std::vector<OUString> maChapterNames;
63 bool hasSelection() const;
65 /** Always something even if hasSelection() is false (in which case the
66 selection is mxDocument).
68 css::uno::Any getSelection() const;
70 sal_Int32 getCurrentPageWriter();
72 public:
73 DocumentToGraphicRenderer(const css::uno::Reference<css::lang::XComponent>& xDocument, bool bSelectionOnly);
74 ~DocumentToGraphicRenderer();
76 sal_Int32 getCurrentPage();
77 sal_Int32 getPageCount();
78 /**
79 * Get list of chapter names for a page, current page is set by
80 * renderToGraphic().
82 const std::vector<OUString>& getChapterNames() const;
84 Size getDocumentSizeInPixels( sal_Int32 nCurrentPage );
86 Size getDocumentSizeIn100mm(sal_Int32 nCurrentPage, Point* pDocumentPosition = nullptr,
87 Point* pCalcPagePosition = nullptr, Size *pCalcPageSize = nullptr);
89 Graphic renderToGraphic( sal_Int32 nCurrentPage, Size aDocumentSizePixel,
90 Size aTargetSizePixel, Color aPageColor, bool bExtOutDevData);
92 /** Determine whether rxController has a css::view::XSelectionSupplier at
93 which either a css::drawing::XShapes or css::drawing::XShape is
94 selected. XShapes has precedence over XShape.
96 Call only if the SelectionOnly property was set.
98 static bool isShapeSelected(
99 css::uno::Reference< css::drawing::XShapes > & rxShapes,
100 css::uno::Reference< css::drawing::XShape > & rxShape,
101 const css::uno::Reference< css::frame::XController > & rxController );
103 bool isWriter() const;
104 bool isCalc() const;
105 bool isImpress() const;
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */