22 #include <strings.hrc>
23 #include <dialmgr.hxx>
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>
46 #include <string_view>
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
147 void PaintScreenShotEntry(
151 double fTransparency);
152 void RepaintToBuffer(
153 bool bUseDimmed =
false,
154 bool bPaintHilight =
false);
155 void RepaintPictureElement();
156 Point GetOffsetInPicture()
const;
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))
244 maPicture.SetOutputSizePixel(maParentDialogSize);
245 mxPicture->set_size_request(maParentDialogSize.Width(), maParentDialogSize.Height());
254 mxText->set_size_request(400,
mxText->get_height_rows(10));
259 mxText->set_editable(
false);
279 OString aDerivedFileName = mrParentDialog.get_buildable_name();
281 auto xFileDlg = std::make_unique<sfx2::FileDialogHelper>(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
282 FileDialogFlags::NONE, mpParentWindow);
285 const uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = xFileDlg->GetFilePicker();
287 xFilePicker->setTitle(maSaveAsText);
289 if (!maLastFolderURL.isEmpty())
291 xFilePicker->setDisplayDirectory(maLastFolderURL);
294 xFilePicker->appendFilter(
"*.png",
"*.png");
295 xFilePicker->setCurrentFilter(
"*.png");
296 xFilePicker->setDefaultName(OStringToOUString(aDerivedFileName, RTL_TEXTENCODING_UTF8));
297 xFilePicker->setMultiSelectionMode(
false);
299 if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
302 maLastFolderURL = xFilePicker->getDisplayDirectory();
303 const uno::Sequence< OUString > files(xFilePicker->getSelectedFiles());
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(aNew);
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);
389 aB2DRange.expand(aB2DRange.getMinimum() -
basegfx::B2DPoint(fGrowTopLeft, fGrowTopLeft));
390 aB2DRange.expand(aB2DRange.getMaximum() +
basegfx::B2DPoint(fGrowBottomRight, fGrowBottomRight));
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);
550 OUString aHelpId = OStringToOUString( rCandidate->GetHelpId(), RTL_TEXTENCODING_UTF8 );
551 aBookmarks.append(lcl_Bookmark( aHelpId ));
554 mxText->set_text( aBookmarks.makeStringAndClear() );
568 return m_pDialog->MouseButtonUp();
572 : GenericDialogController(&rParentDialog,
"cui/ui/screenshotannotationdialog.ui",
"ScreenshotAnnotationDialog")
#define LINK(Instance, Class, Member)
std::shared_ptr< weld::Dialog > m_xDialog
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button &, void)
void RepaintToBuffer(bool bUseDimmed=false, bool bPaintHilight=false)
BitmapEx maParentDialogBitmap
virtual std::unique_ptr< TextView > weld_text_view(const OString &id)=0
void SetAntialiasing(AntialiasingFlags nMode)
std::unique_ptr< ScreenshotAnnotationDlg_Impl > m_pImpl
std::unique_ptr< weld::Builder > m_xBuilder
bool Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
std::vector< ScreenShotEntry > ScreenShotCollection
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
bool removeExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
virtual VclPtr< VirtualDevice > screenshot()=0
void DrawPolyLine(const tools::Polygon &rPoly)
bool setExtension(std::u16string_view rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString maMainMarkupText
virtual ScreenShotCollection collect_screenshot_data()=0
AntialiasingFlags GetAntialiasing() const
unsigned int uniform_uint_distribution(unsigned int a, unsigned int b)
weld::ScreenShotCollection maAllChildren
OUString PathToFileName() const
static OutputDevice * GetDefaultDevice()
constexpr tools::Long Width() const
weld::ScreenShotEntry * mpHilighted
bool MouseMove(const MouseEvent &rMouseEvent)
bool IsEnterWindow() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTRED
void PaintScreenShotEntry(const weld::ScreenShotEntry &rEntry, const Color &rColor, double fLineWidth, double fTransparency)
bool DrawPolyLineDirect(const basegfx::B2DHomMatrix &rObjectTransform, const basegfx::B2DPolygon &rB2DPolygon, double fLineWidth=0.0, double fTransparency=0.0, const std::vector< double > *=nullptr, basegfx::B2DLineJoin eLineJoin=basegfx::B2DLineJoin::NONE, css::drawing::LineCap eLineCap=css::drawing::LineCap_BUTT, double fMiterMinimumAngle=basegfx::deg2rad(15.0))
OUString CuiResId(TranslateId aKey)
Point GetOffsetInPicture() const
bool IsLeaveWindow() const
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
std::unique_ptr< weld::CustomWeld > mxPicture
bool Write(SvStream &rStream)
std::set< weld::ScreenShotEntry * > maSelected
const basegfx::B2IRange & getB2IRange() const
Size GetOutputSizePixel() const
~ScreenshotAnnotationDlg_Impl()
ScreenshotAnnotationDlg(const ScreenshotAnnotationDlg &)=delete
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void Paint(vcl::RenderContext &rRenderContext)
weld::Window * mpParentWindow
std::unique_ptr< weld::TextView > mxText
void RepaintPictureElement()
constexpr tools::Long Height() const
std::unique_ptr< weld::Button > mxSave
virtual std::unique_ptr< Button > weld_button(const OString &id)=0
ScreenshotAnnotationDlg_Impl(weld::Window *pParent, weld::Builder &rParent, weld::Dialog &rParentDialog)
static VclPtr< reference_type > Create(Arg &&...arg)
BitmapEx maDimmedDialogBitmap
bool isInside(const Tuple2D< sal_Int32 > &rTuple) const
const Point & GetPosPixel() const
weld::Dialog & mrParentDialog
VclPtr< VirtualDevice > mxVirtualBufferDevice
const Size & GetSizePixel() const
sal_uInt16 GetTransparentSelectionPercent()
static OUString maLastFolderURL
virtual ~ScreenshotAnnotationDlg() override
#define SAL_NEWLINE_STRING
weld::ScreenShotEntry * CheckHit(const basegfx::B2IPoint &rPosition)
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool m_bDetectedRangeSegmentation false