26#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
27#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
28#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
52 OUString lcl_genRandom( std::u16string_view rId )
56 return OUString( rId + OUString::number( nRand ) );
60 OUString lcl_AltDescr()
62 OUString aTempl(
"<alt id=\"%1\">"
65 aTempl = aTempl.replaceFirst(
"%1", lcl_genRandom(u
"alt_id") );
70 OUString lcl_Image( std::u16string_view rScreenshotId,
const Size& rSize )
72 OUString aTempl(
"<image id=\"%1\" src=\"media/screenshots/%2.png\""
73 " width=\"%3cm\" height=\"%4cm\">"
76 aTempl = aTempl.replaceFirst(
"%1", lcl_genRandom(u
"img_id") );
77 aTempl = aTempl.replaceFirst(
"%2", rScreenshotId );
78 aTempl = aTempl.replaceFirst(
"%3", OUString::number( rSize.
Width() ) );
79 aTempl = aTempl.replaceFirst(
"%4", OUString::number( rSize.
Height() ) );
80 aTempl = aTempl.replaceFirst(
"%5", lcl_AltDescr() );
85 OUString lcl_ParagraphWithImage( std::u16string_view rScreenshotId,
const Size& rSize )
87 OUString aTempl(
"<paragraph id=\"%1\" role=\"paragraph\">%2"
88 "</paragraph>" SAL_NEWLINE_STRING );
89 aTempl = aTempl.replaceFirst(
"%1", lcl_genRandom(u
"par_id") );
90 aTempl = aTempl.replaceFirst(
"%2", lcl_Image(rScreenshotId, rSize) );
95 OUString lcl_Bookmark( std::u16string_view rWidgetId )
99 aTempl = aTempl.replaceFirst(
"%1", rWidgetId );
100 aTempl = aTempl.replaceFirst(
"%2", rWidgetId );
101 aTempl = aTempl.replaceFirst(
"%3", lcl_genRandom(u
"bm_id") );
121 , m_bMouseOver(false)
125 bool IsMouseOver()
const
151 double fTransparency);
153 bool bUseDimmed =
false,
154 bool bPaintHilight =
false);
173 std::set< weld::ScreenShotEntry* >
200: mpParentWindow(pParent),
201 mrParentDialog(rParentDialog),
202 mxVirtualBufferDevice(nullptr),
203 mpHilighted(nullptr),
205 maSaveAsText(
CuiResId(RID_CUISTR_SAVE_SCREENSHOT_AS))
254 mxText->set_size_request(400,
mxText->get_height_rows(10));
259 mxText->set_editable(
false);
279 OUString aDerivedFileName = mrParentDialog.get_buildable_name();
281 auto xFileDlg = std::make_unique<sfx2::FileDialogHelper>(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
282 FileDialogFlags::NONE, mpParentWindow);
287 xFilePicker->setTitle(maSaveAsText);
289 if (!maLastFolderURL.isEmpty())
291 xFilePicker->setDisplayDirectory(maLastFolderURL);
294 xFilePicker->appendFilter(
"*.png",
"*.png");
295 xFilePicker->setCurrentFilter(
"*.png");
296 xFilePicker->setDefaultName(aDerivedFileName);
297 xFilePicker->setMultiSelectionMode(
false);
299 if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
302 maLastFolderURL = xFilePicker->getDisplayDirectory();
305 if (!files.hasElements())
308 OUString aConfirmedName = files[0];
310 if (aConfirmedName.isEmpty())
314 OUString aCurrentExtension(aConfirmedURL.
getExtension());
316 if (!aCurrentExtension.isEmpty() && aCurrentExtension !=
"png")
319 aCurrentExtension.clear();
322 if (aCurrentExtension.isEmpty())
339 mxVirtualBufferDevice->GetBitmapEx(
341 mxVirtualBufferDevice->GetOutputSizePixel()));
345 aPNGWriter.
write(aTargetBitmap);
354 if (rCandidate.getB2IRange().isInside(rPosition))
361 pRetval = &rCandidate;
366 pRetval = &rCandidate;
378 double fTransparency)
387 static const double fGrowTopLeft(1.5);
388 static const double fGrowBottomRight(0.5);
394 static const double fEdgeRoundPixel(8.0);
398 fEdgeRoundPixel / aB2DRange.
getWidth(),
399 fEdgeRoundPixel / aB2DRange.
getHeight()));
454 static const double fLineWidthEntries(5.0);
461 static const double fLineWidthHilight(7.0);
490 m_pDialog->Paint(rRenderContext);
495 bool bRepaint(
false);
506 if (pHit && pOldHit != pHit)
531 m_bMouseOver =
false;
532 return m_pDialog->MouseMove(rMouseEvent);
538 bool bRepaint(
false);
549 aBookmarks.append(lcl_Bookmark(rCandidate->GetHelpId()));
551 mxText->set_text( aBookmarks.makeStringAndClear() );
565 return m_pDialog->MouseButtonUp();
569 : GenericDialogController(&rParentDialog,
"cui/ui/screenshotannotationdialog.ui",
"ScreenshotAnnotationDialog")
static OutputDevice * GetDefaultDevice()
bool Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
const Size & GetSizePixel() const
bool removeExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString PathToFileName() const
bool setExtension(std::u16string_view rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
bool IsEnterWindow() const
bool IsLeaveWindow() const
const Point & GetPosPixel() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
constexpr tools::Long Y() const
constexpr tools::Long X() const
void Paint(vcl::RenderContext &rRenderContext)
weld::ScreenShotEntry * CheckHit(const basegfx::B2IPoint &rPosition)
void RepaintPictureElement()
weld::ScreenShotCollection maAllChildren
void PaintScreenShotEntry(const weld::ScreenShotEntry &rEntry, const Color &rColor, double fLineWidth, double fTransparency)
static OUString maLastFolderURL
BitmapEx maParentDialogBitmap
VclPtr< VirtualDevice > mxVirtualBufferDevice
std::unique_ptr< weld::TextView > mxText
std::unique_ptr< weld::CustomWeld > mxPicture
void RepaintToBuffer(bool bUseDimmed=false, bool bPaintHilight=false)
std::unique_ptr< weld::Button > mxSave
std::set< weld::ScreenShotEntry * > maSelected
weld::Dialog & mrParentDialog
weld::Window * mpParentWindow
BitmapEx maDimmedDialogBitmap
Point GetOffsetInPicture() const
bool MouseMove(const MouseEvent &rMouseEvent)
DECL_LINK(saveButtonHandler, weld::Button &, void)
OUString maMainMarkupText
weld::ScreenShotEntry * mpHilighted
ScreenshotAnnotationDlg_Impl(weld::Window *pParent, weld::Builder &rParent, weld::Dialog &rParentDialog)
~ScreenshotAnnotationDlg_Impl()
std::unique_ptr< ScreenshotAnnotationDlg_Impl > m_pImpl
ScreenshotAnnotationDlg(const ScreenshotAnnotationDlg &)=delete
virtual ~ScreenshotAnnotationDlg() override
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static VclPtr< reference_type > Create(Arg &&... arg)
B2DPoint getMaximum() const
B2DPoint getMinimum() const
void expand(const Tuple2D< TYPE > &rTuple)
bool isInside(const Tuple2D< TYPE > &rTuple) const
bool write(const BitmapEx &rBitmap)
virtual std::unique_ptr< TextView > weld_text_view(const OUString &id)=0
virtual std::unique_ptr< Button > weld_button(const OUString &id)=0
std::shared_ptr< weld::Dialog > m_xDialog
std::unique_ptr< weld::Builder > m_xBuilder
const basegfx::B2IRange & getB2IRange() const
virtual ScreenShotCollection collect_screenshot_data()=0
virtual VclPtr< VirtualDevice > screenshot()=0
constexpr ::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define SAL_NEWLINE_STRING
OUString CuiResId(TranslateId aKey)
#define LINK(Instance, Class, Member)
sal_uInt16 GetTransparentSelectionPercent()
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
unsigned int uniform_uint_distribution(unsigned int a, unsigned int b)
std::vector< ScreenShotEntry > ScreenShotCollection
IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button &, void)