1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #ifndef INCLUDED_CUI_SOURCE_INC_SFXREDACTIONHELPER_HXX
11 #define INCLUDED_CUI_SOURCE_INC_SFXREDACTIONHELPER_HXX
13 #include <com/sun/star/uno/Reference.hxx>
14 #include <com/sun/star/lang/XComponent.hpp>
15 #include <com/sun/star/frame/XModel.hpp>
16 #include <com/sun/star/beans/XPropertySet.hpp>
17 #include <com/sun/star/drawing/XDrawPage.hpp>
19 #include <sal/types.h>
20 #include <rtl/ustring.hxx>
21 #include <tools/gen.hxx>
25 using namespace ::com::sun::star
;
26 using namespace ::com::sun::star::lang
;
27 using namespace ::com::sun::star::uno
;
32 class DocumentToGraphicRenderer
;
37 // Page margins in mm100th
45 * Mostly a bunch of static methods to handle the redaction functionality at
46 * different points of the process.
48 class SfxRedactionHelper
51 /// Checks to see if the request has a parameter of IsRedactMode:bool=true
52 static bool isRedactMode(const SfxRequest
& rReq
);
54 * Returns the value of the given string param as an OUString
55 * Returns empty OUString if no param
57 static OUString
getStringParam(const SfxRequest
& rReq
, const sal_uInt16
& nParamId
);
59 * Creates metafiles from the pages of the given document,
60 * and pushes into the given vector.
62 static void getPageMetaFilesFromDoc(std::vector
<GDIMetaFile
>& aMetaFiles
,
63 std::vector
<::Size
>& aPageSizes
, const sal_Int32
& nPages
,
64 DocumentToGraphicRenderer
& aRenderer
);
66 * Creates one shape and one draw page for each gdimetafile,
67 * and inserts the shapes into the newly created draw pages.
69 static void addPagesToDraw(uno::Reference
<XComponent
>& xComponent
, const sal_Int32
& nPages
,
70 const std::vector
<GDIMetaFile
>& aMetaFiles
,
71 const std::vector
<::Size
>& aPageSizes
,
72 const PageMargins
& aPageMargins
);
74 * Makes the Redaction toolbar visible to the user.
75 * Meant to be called after converting a document to a Draw doc
76 * for redaction purposes.
78 static void showRedactionToolbar(SfxViewFrame
* pViewFrame
);
81 * Used to get the page margins from the original/source Writer document. Then we apply these values to the
82 * pages inserted into Draw for redaction.
84 static PageMargins
getPageMarginsForWriter(css::uno::Reference
<css::frame::XModel
>& xModel
);
87 * Used to get the page margins from the original/source Calc document. Then we apply these values to the
88 * pages inserted into Draw for redaction.
90 static PageMargins
getPageMarginsForCalc(css::uno::Reference
<css::frame::XModel
>& xModel
);
92 static void searchInMetaFile(const OUString
& sSearchTerm
, const GDIMetaFile
& rMtf
,
93 std::vector
<tools::Rectangle
>& aRedactionRectangles
,
94 uno::Reference
<XComponent
>& xComponent
);
97 * Draws a redaction rectangle on the draw page referenced with its page number (0-based)
99 static void addRedactionRectToPage(uno::Reference
<XComponent
>& xComponent
,
100 uno::Reference
<drawing::XDrawPage
>& xPage
,
101 const std::vector
<tools::Rectangle
>& aNewRectangles
);
104 * Search for the given term through the gdimetafile, which has the whole content of a draw page,
105 * and draw redaction rectangles to the appropriate positions with suitable sizes.
107 static void autoRedactPage(const OUString
& sRedactionTerm
, const GDIMetaFile
& rGDIMetaFile
,
108 uno::Reference
<drawing::XDrawPage
>& xPage
,
109 uno::Reference
<XComponent
>& xComponent
);
112 #endif // INCLUDED_CUI_SOURCE_INC_SFXREDACTIONHELPER_HXX
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */