20#include <osl/file.hxx>
32#include <sfx2/strings.hrc>
33#include <sfx2/sfxsids.hrc>
43 std::shared_ptr<GDIMetaFile> xFile = pObj
45 : std::shared_ptr<GDIMetaFile>();
61 DBG_ASSERT(!aTmpSize.
IsEmpty(),
"size of first page is 0, override GetFirstPageSize or set visible-area!");
67 if (nWidth <= 0 || nHeight <= 0)
70 double dRatio = aTmpSize.
Height() ? (double(aTmpSize.
Width()) / aTmpSize.
Height()) : 1;
71 double dRatioPreV = double(nWidth) / nHeight;
74 if (dRatio > dRatioPreV)
76 aSize =
Size(nWidth, sal_uInt16(nWidth / dRatio));
77 aPoint =
Point(0, sal_uInt16((nHeight - aSize.
Height()) / 2));
81 aSize =
Size(sal_uInt16(nHeight * dRatio), nHeight);
82 aPoint =
Point(sal_uInt16((nWidth - aSize.
Width()) / 2), 0);
84 Point bPoint =
Point(nWidth, nHeight) - aPoint;
103 if (m_xDocShell.Is())
105 if (m_xDocShell->GetProgress())
110 const sal_uInt16 nEntry = GetSelectedTemplatePos();
113 m_xPreviewController->Invalidate();
114 m_xPreviewController->SetObjectShell(
nullptr);
121 OUString aFileName = m_aTemplates.GetPath(m_xRegionLb->get_selected_index(), nEntry - 1);
123 if (aTestObj.
GetProtocol() == INetProtocol::NotValid)
128 osl::FileBase::getFileURLFromSystemPath( aFileName, aTemp );
136 if (pTmp->GetMedium())
145 if (!m_xDocShell.Is())
155 if (!m_xDocShell.Is())
157 m_xPreviewController->SetObjectShell(
nullptr);
162 m_xPreviewController->SetObjectShell(m_xDocShell);
167 if (m_xDocShell.Is() && m_xDocShell->GetProgress())
170 const sal_uInt16 nRegion = rBox.get_selected_index();
171 const sal_uInt16
nCount = m_aTemplates.GetRegionCount() ? m_aTemplates.GetCount(nRegion): 0;
172 m_xTemplateLb->freeze();
173 m_xTemplateLb->clear();
174 OUString aSel = m_xRegionLb->get_selected_text();
175 sal_Int32 nc = aSel.indexOf(
'(');
176 if (nc != -1 && nc != 0)
177 aSel = aSel.replaceAt(nc-1, 1,
u"");
178 if ( aSel.compareToIgnoreAsciiCase(
SfxResId(STR_STANDARD) ) == 0 )
179 m_xTemplateLb->append_text(
SfxResId(STR_NONE));
181 m_xTemplateLb->append_text(m_aTemplates.GetName(nRegion,
i));
182 m_xTemplateLb->thaw();
184 m_xTemplateLb->select(0);
185 TemplateSelect(*m_xTemplateLb);
190 TemplateSelect(*m_xTemplateLb);
196 if (m_xDocShell && m_xDocShell->GetProgress())
199 if (!m_xMoreBt->get_expanded())
211 if (!m_xDocShell.Is() || !m_xDocShell->GetProgress())
222 sal_Int32 nc = aSel.indexOf(
'(');
223 if (nc != -1 && nc != 0)
224 aSel = aSel.replaceAt(nc-1, 1,
u"");
225 if ( aSel.compareToIgnoreAsciiCase(
SfxResId(STR_STANDARD)) != 0 )
232 , m_aPrevIdle(
"SfxNewFileDialog m_aPrevIdle")
235 , m_xRegionLb(m_xBuilder->weld_tree_view(
"categories"))
236 , m_xTemplateLb(m_xBuilder->weld_tree_view(
"templates"))
237 , m_xTextStyleCB(m_xBuilder->weld_check_button(
"text"))
238 , m_xFrameStyleCB(m_xBuilder->weld_check_button(
"frame"))
239 , m_xPageStyleCB(m_xBuilder->weld_check_button(
"pages"))
240 , m_xNumStyleCB(m_xBuilder->weld_check_button(
"numbering"))
241 , m_xMergeStyleCB(m_xBuilder->weld_check_button(
"overwrite"))
242 , m_xLoadFilePB(m_xBuilder->weld_button(
"fromfile"))
243 , m_xMoreBt(m_xBuilder->weld_expander(
"expander"))
244 , m_xPreviewWin(new
weld::CustomWeld(*m_xBuilder,
"image", *m_xPreviewController))
245 , m_xAltTitleFt(m_xBuilder->weld_label(
"alttitle"))
247 const int nWidth =
m_xRegionLb->get_approximate_digit_width() * 32;
248 const int nHeight =
m_xRegionLb->get_height_rows(8);
277 css::uno::Any aUserItem = aDlgOpt.
GetUserItem(
"UserItem");
278 aUserItem >>= sExtraData;
281 bool bExpand = !sExtraData.isEmpty() && sExtraData[0] ==
'Y';
311 aDlgOpt.
SetUserItem(
"UserItem", css::uno::Any(
m_xMoreBt->get_expanded() ? OUString(
"Y") : OUString(
"N")));
SfxApplication * SfxGetpApp()
Reference< XExecutableDialog > m_xDialog
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
INetProtocol GetProtocol() const
Size GetOutputSize() const
void DrawRect(const tools::Rectangle &rRect)
ErrCode LoadTemplate(SfxObjectShellLock &xDoc, const OUString &rFileName, std::unique_ptr< SfxItemSet > pArgs)
OUString GetPath(sal_uInt16 nRegion, sal_uInt16 nIdx) const
void Update()
updates the configuration where the document templates structure is stored.
sal_uInt16 GetRegionCount() const
OUString GetFullRegionName(sal_uInt16 nIdx) const
std::unique_ptr< weld::Expander > m_xMoreBt
std::unique_ptr< weld::Button > m_xLoadFilePB
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
std::unique_ptr< weld::CheckButton > m_xTextStyleCB
SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags)
std::unique_ptr< weld::CheckButton > m_xPageStyleCB
OUString GetTemplateFileName() const
std::unique_ptr< weld::CheckButton > m_xFrameStyleCB
SfxTemplateFlags GetTemplateFlags() const
void SetTemplateFlags(SfxTemplateFlags nSet)
sal_uInt16 GetSelectedTemplatePos() const
std::unique_ptr< weld::TreeView > m_xRegionLb
std::unique_ptr< weld::CheckButton > m_xNumStyleCB
std::unique_ptr< weld::CheckButton > m_xMergeStyleCB
std::unique_ptr< weld::TreeView > m_xTemplateLb
SfxDocumentTemplates m_aTemplates
std::unique_ptr< weld::Label > m_xAltTitleFt
virtual ~SfxNewFileDialog() override
std::shared_ptr< GDIMetaFile > GetPreviewMetaFile(bool bFullContent=false) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static void ImpPaint(vcl::RenderContext &rRenderContext, GDIMetaFile *pFile)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
void SetObjectShell(SfxObjectShell const *pObj)
std::shared_ptr< GDIMetaFile > xMetaFile
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
constexpr tools::Long Height() const
constexpr tools::Long Width() const
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
std::shared_ptr< weld::Dialog > m_xDialog
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer *, void)
IMPL_LINK(SfxNewFileDialog, RegionSelect, weld::TreeView &, rBox, void)
#define ERRCTX_SFX_LOADTEMPLATE
OUString SfxResId(TranslateId aId)