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),
204 mpHilighted(nullptr),
207 maSaveAsText(
CuiResId(RID_SVXSTR_SAVE_SCREENSHOT_AS))
246 maPicture.SetOutputSizePixel(maParentDialogSize);
247 mxPicture->set_size_request(maParentDialogSize.Width(), maParentDialogSize.Height());
256 mxText->set_size_request(400,
mxText->get_height_rows(10));
261 mxText->set_editable(
false);
281 OString aDerivedFileName = mrParentDialog.get_buildable_name();
283 auto xFileDlg = std::make_unique<sfx2::FileDialogHelper>(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
284 FileDialogFlags::NONE, mpParentWindow);
286 const uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = xFileDlg->GetFilePicker();
288 xFilePicker->setTitle(maSaveAsText);
290 if (!maLastFolderURL.isEmpty())
292 xFilePicker->setDisplayDirectory(maLastFolderURL);
295 xFilePicker->appendFilter(
"*.png",
"*.png");
296 xFilePicker->setCurrentFilter(
"*.png");
297 xFilePicker->setDefaultName(OStringToOUString(aDerivedFileName, RTL_TEXTENCODING_UTF8));
298 xFilePicker->setMultiSelectionMode(
false);
300 if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
303 maLastFolderURL = xFilePicker->getDisplayDirectory();
304 const uno::Sequence< OUString > files(xFilePicker->getSelectedFiles());
306 if (!files.hasElements())
309 OUString aConfirmedName = files[0];
311 if (aConfirmedName.isEmpty())
315 OUString aCurrentExtension(aConfirmedURL.
getExtension());
317 if (!aCurrentExtension.isEmpty() && aCurrentExtension !=
"png")
320 aCurrentExtension.clear();
323 if (aCurrentExtension.isEmpty())
340 mxVirtualBufferDevice->GetBitmapEx(
342 mxVirtualBufferDevice->GetOutputSizePixel()));
346 aPNGWriter.
Write(aNew);
355 if (rCandidate.getB2IRange().isInside(rPosition))
362 pRetval = &rCandidate;
367 pRetval = &rCandidate;
379 double fTransparency)
388 static const double fGrowTopLeft(1.5);
389 static const double fGrowBottomRight(0.5);
390 aB2DRange.expand(aB2DRange.getMinimum() -
basegfx::B2DPoint(fGrowTopLeft, fGrowTopLeft));
391 aB2DRange.expand(aB2DRange.getMaximum() +
basegfx::B2DPoint(fGrowBottomRight, fGrowBottomRight));
395 static const double fEdgeRoundPixel(8.0);
399 fEdgeRoundPixel / aB2DRange.getWidth(),
400 fEdgeRoundPixel / aB2DRange.getHeight()));
445 const bool bIsAntiAliasing(aSvtOptionsDrawinglayer.
IsAntiAliasing());
456 static const double fLineWidthEntries(5.0);
463 static const double fLineWidthHilight(7.0);
492 m_pDialog->Paint(rRenderContext);
497 bool bRepaint(
false);
508 if (pHit && pOldHit != pHit)
533 m_bMouseOver =
false;
534 return m_pDialog->MouseMove(rMouseEvent);
540 bool bRepaint(
false);
552 OUString aHelpId = OStringToOUString( rCandidate->GetHelpId(), RTL_TEXTENCODING_UTF8 );
553 aBookmarks.append(lcl_Bookmark( aHelpId ));
556 mxText->set_text( aBookmarks.makeStringAndClear() );
570 return m_pDialog->MouseButtonUp();
574 : GenericDialogController(&rParentDialog,
"cui/ui/screenshotannotationdialog.ui",
"ScreenshotAnnotationDialog")
#define LINK(Instance, Class, Member)
std::shared_ptr< weld::Dialog > m_xDialog
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)
sal_uInt16 GetTransparentSelectionPercent() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
#define DECL_LINK(Member, ArgType, RetType)
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)
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()
bool setExtension(OUString const &rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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))
Point GetOffsetInPicture() const
bool IsLeaveWindow() const
bool isInside(const B2ITuple &rTuple) const
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
std::unique_ptr< weld::CustomWeld > mxPicture
tools::Long Width() const
bool Write(SvStream &rStream)
std::set< weld::ScreenShotEntry * > maSelected
const basegfx::B2IRange & getB2IRange() const
Size GetOutputSizePixel() const
~ScreenshotAnnotationDlg_Impl()
OUString CuiResId(const char *pKey)
ScreenshotAnnotationDlg(const ScreenshotAnnotationDlg &)=delete
Point PixelToLogic(const Point &rDevicePt) const
void Paint(vcl::RenderContext &rRenderContext)
weld::Window * mpParentWindow
std::unique_ptr< weld::TextView > mxText
void RepaintPictureElement()
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
tools::Long Height() const
const Point & GetPosPixel() const
bool IsAntiAliasing() const
weld::Dialog & mrParentDialog
VclPtr< VirtualDevice > mxVirtualBufferDevice
const Size & GetSizePixel() const
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
Color getHilightColor() const