21#include <com/sun/star/uno/Reference.hxx>
23#include <com/sun/star/document/DocumentProperties.hpp>
24#include <com/sun/star/document/XDocumentProperties.hpp>
25#include <com/sun/star/document/UpdateDocMode.hpp>
35#include <tools/datetime.hxx>
56#include <sfx2/sfxsids.hrc>
57#include <sfx2/strings.hrc>
68bool operator> (
const util::DateTime& i_rLeft,
const util::DateTime& i_rRight)
70 if ( i_rLeft.Year != i_rRight.Year )
71 return i_rLeft.Year > i_rRight.Year;
73 if ( i_rLeft.Month != i_rRight.Month )
74 return i_rLeft.Month > i_rRight.Month;
76 if ( i_rLeft.Day != i_rRight.Day )
77 return i_rLeft.Day > i_rRight.Day;
79 if ( i_rLeft.Hours != i_rRight.Hours )
80 return i_rLeft.Hours > i_rRight.Hours;
82 if ( i_rLeft.Minutes != i_rRight.Minutes )
83 return i_rLeft.Minutes > i_rRight.Minutes;
85 if ( i_rLeft.Seconds != i_rRight.Seconds )
86 return i_rLeft.Seconds > i_rRight.Seconds;
88 if ( i_rLeft.NanoSeconds != i_rRight.NanoSeconds )
89 return i_rLeft.NanoSeconds > i_rRight.NanoSeconds;
94std::shared_ptr<GDIMetaFile>
97 auto xFile = std::make_shared<GDIMetaFile>();
99 pDevice->EnableOutput(
false );
101 return std::shared_ptr<GDIMetaFile>();
108 pDevice->SetAntialiasing(AntialiasingFlags::Enable | pDevice->GetAntialiasing());
111 Size size = pDevice->GetOutputSizePixel();
115 aBitmap.
Scale(
size, BmpScaleFlag::BestQuality);
117 aBitmap.
Convert(BmpConversion::N24Bit);
146 "size of first page is 0, override GetFirstPageSize or set visible-area!" );
161 sal_uInt32 nMaximumExtent = 512;
165 && ( sal::static_int_cast< tools::ULong >(aSizePix.
Width()) >
167 sal::static_int_cast< tools::ULong >(aSizePix.
Height()) >
170 double fWH =
static_cast< double >( aSizePix.
Width() ) / aSizePix.
Height();
178 aSizePix.
setWidth( nMaximumExtent );
208 uno::Reference<document::XDocumentProperties> xDocProps(
getDocProperties());
214 xDocProps->resetUserData( OUString() );
222 if (xDocProps->getAuthor() == aUserName) {
223 xDocProps->setAuthor( OUString() );
225 xDocProps->setModifiedBy( OUString() );
226 if (xDocProps->getPrintedBy() == aUserName) {
227 xDocProps->setPrintedBy( OUString() );
235 xDocProps->setModifiedBy( aUserName );
248 rDur.Minutes += rTime.
GetMin();
249 rDur.Seconds += rTime.
GetSec();
254 const uno::Reference<document::XDocumentProperties> & i_xDocProps)
257 const sal_Int32 secs = i_xDocProps->getEditingDuration();
258 util::Duration editDuration(
false, 0, 0, 0,
259 secs/3600, (secs%3600)/60, secs%60, 0);
295 lcl_add(editDuration, nAddTime);
300 const sal_Int32 newSecs( (editDuration.Hours*3600)
301 + (editDuration.Minutes*60) + editDuration.Seconds);
302 i_xDocProps->setEditingDuration(newSecs);
303 i_xDocProps->setEditingCycles(i_xDocProps->getEditingCycles() + 1);
305 catch (
const lang::IllegalArgumentException &)
314 return std::make_shared<SfxDocumentInfoDialog>(pParent,
rSet);
319 auto it =
pImpl->m_aRecentColors.find(nSlotId);
320 if (it !=
pImpl->m_aRecentColors.end())
328 pImpl->m_aRecentColors[nSlotId] = rColor;
334 std::set<Color> empty;
377 DBG_ASSERT(pSourcePool,
"Source-DocumentShell without StyleSheetPool");
379 DBG_ASSERT(pMyPool,
"Dest-DocumentShell without StyleSheetPool");
381 std::unique_ptr<Styles_Impl[]> pFound(
new Styles_Impl[xIter->Count()]);
382 sal_uInt16 nFound = 0;
395 pFound[nFound].pSource = pSource;
396 pFound[nFound].pDest = pDest;
398 pSource = xIter->Next();
401 for ( sal_uInt16
i = 0;
i < nFound; ++
i )
405 pFound[
i].pDest->SetParent(pFound[
i].pSource->
GetParent());
407 pFound[
i].pDest->SetFollow(pFound[
i].pSource->
GetParent());
418 class QueryTemplateBox
423 QueryTemplateBox(
weld::Window* pParent,
const OUString& rMessage)
448 DBG_ASSERT( pFile,
"cannot UpdateFromTemplate without medium" );
459 uno::Reference< embed::XStorage > xDocStor = pFile->
GetStorage(
false);
466 sal_Int16 bCanUpdateFromTemplate = pUpdateDocItem ? pUpdateDocItem->
GetValue() : document::UpdateDocMode::NO_UPDATE;
469 uno::Reference<document::XDocumentProperties> xDocProps(
getDocProperties());
470 const OUString aTemplName( xDocProps->getTemplateName() );
471 OUString aTemplURL( xDocProps->getTemplateURL() );
474 if ( !aTemplName.isEmpty() || (!aTemplURL.isEmpty() && !
IsReadOnly()) )
481 if (!aTemplURL.isEmpty())
486 }
catch (::rtl::MalformedUriException
const&) {
491 if( aFoundName.isEmpty() && !aTemplName.isEmpty() )
494 aTempl.
GetFull(
u"", aTemplName, aFoundName );
497 if ( aFoundName.isEmpty() )
501 aTemplURL = aFoundName;
511 util::DateTime aTemplDate;
514 Reference<document::XDocumentProperties>
const
515 xTemplateDocProps( document::DocumentProperties::create(
516 ::comphelper::getProcessComponentContext()));
517 xTemplateDocProps->loadFromMedium(aTemplURL,
518 Sequence<beans::PropertyValue>());
519 aTemplDate = xTemplateDocProps->getModificationDate();
531 const util::DateTime aInfoDate( xDocProps->getTemplateDate() );
532 if ( aTemplDate > aInfoDate )
535 if( bCanUpdateFromTemplate == document::UpdateDocMode::QUIET_UPDATE
536 || bCanUpdateFromTemplate == document::UpdateDocMode::FULL_UPDATE )
538 else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG )
540 const OUString
sMessage(
SfxResId(STR_QRYTEMPL_MESSAGE).replaceAll(
"$(ARG1)", aTemplName ) );
567 SfxMedium aMedium( aFoundName, StreamMode::STD_READ );
568 if ( xTemplDoc->
LoadFrom( aMedium ) )
575 xDocProps->setTemplateDate(aTemplDate);
583 return (pFilter && pFilter->GetFilterName() ==
"writer_web_HTML_help");
592 uno::Reference<document::XDocumentProperties> xDocProps(
getDocProperties());
593 xDocProps->setTemplateURL( OUString() );
594 xDocProps->setTemplateName( OUString() );
595 xDocProps->setTemplateDate( util::DateTime() );
596 xDocProps->resetUserData( OUString() );
605 if(
SfxGetpApp()->
Get_Impl()->GetDocumentTemplates()->GetFull(
u"", rTemplateName, aFoundName ) )
609 xDocProps->setTemplateName( rTemplateName );
620 return pImpl->bQueryLoadTemplate;
625 return pImpl->bUseUserData;
630 return pImpl->bUseThumbnailSave;
635 if (
pImpl->bQueryLoadTemplate != bNew )
637 pImpl->bQueryLoadTemplate = bNew;
642 if (
pImpl->bUseUserData != bNew )
644 pImpl->bUseUserData = bNew;
649 if (
pImpl->bUseThumbnailSave != _bNew )
651 pImpl->bUseThumbnailSave = _bNew;
656 return pImpl->bLoadReadonly;
661 return pImpl->bSaveVersionOnClose;
666 if (
pImpl->bLoadReadonly != bNew )
668 pImpl->bLoadReadonly = bNew;
673 if (
pImpl->bSaveVersionOnClose != bNew )
675 pImpl->bSaveVersionOnClose = bNew;
680 return pImpl->m_nModifyPasswordHash;
690 pImpl->m_nModifyPasswordHash = nHash;
699 return pImpl->m_aModifyPasswordInfo;
709 pImpl->m_aModifyPasswordInfo = aInfo;
718 pImpl->m_bModifyPasswordEntered = bEntered;
723 return pImpl->m_bModifyPasswordEntered;
SfxApplication * SfxGetpApp()
std::unique_ptr< weld::MessageDialog > m_xQueryBox
const LanguageTag & GetLanguageTag() const
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static const AllSettings & GetSettings()
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
bool Convert(BmpConversion eConversion)
sal_uInt16 GetValue() const
sal_Int64 GetSecFromDateTime(const Date &rDate) const
css::util::DateTime GetUNODateTime() const
sal_Int32 GetDate() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
LanguageType getLanguageType(bool bResolveSystem=true) const
void SetDigitLanguage(LanguageType)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void Broadcast(const SfxHint &rHint)
bool GetFull(std::u16string_view rRegion, std::u16string_view rName, OUString &rPath)
void PutExtended(const SfxItemSet &, SfxItemState eDontCareAs, SfxItemState eDefaultAs)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const std::shared_ptr< const SfxFilter > & GetFilter() const
SfxItemSet & GetItemSet() const
const OUString & GetName() const
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
SAL_DLLPRIVATE void SetModifyPasswordEntered(bool bEntered=true)
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
void ResetFromTemplate(const OUString &rTemplateName, std::u16string_view rFileName)
virtual sfx::AccessibilityIssueCollection runAccessibilityCheck()
bool SetModifyPasswordInfo(const css::uno::Sequence< css::beans::PropertyValue > &aInfo)
SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice *pDevice, GDIMetaFile *pFile) const
virtual bool LoadFrom(SfxMedium &rMedium)
bool IsLoadReadonly() const
MapUnit GetMapUnit() const
virtual sfx2::StyleManager * GetStyleManager()
sal_uInt32 GetModifyPasswordHash() const
virtual std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rItemSet)
static bool IsOwnStorageFormat(const SfxMedium &)
void SetRecentColor(sal_uInt16 nSlotId, const NamedColor &rColor)
std::shared_ptr< GDIMetaFile > GetPreviewMetaFile(bool bFullContent=false) const
virtual std::shared_ptr< model::ColorSet > GetThemeColors()
virtual SfxObjectFactory & GetFactory() const =0
bool IsUseUserData() const
css::uno::Reference< css::awt::XWindow > GetDialogParent(SfxMedium const *pMedium=nullptr)
bool IsReadOnlyUI() const
static SfxObjectShell * CreateObjectByFactoryName(const OUString &rURL, SfxObjectCreateMode=SfxObjectCreateMode::STANDARD)
SAL_DLLPRIVATE SfxObjectShell_Impl * Get_Impl()
SfxMedium * GetMedium() const
std::optional< NamedColor > GetRecentColor(sal_uInt16 nSlotId)
void SetQueryLoadTemplate(bool b)
virtual std::set< Color > GetDocColors()
void DoDraw(OutputDevice *, const Point &rObjPos, const Size &rSize, const JobSetup &rSetup, sal_uInt16 nAspect=ASPECT_CONTENT, bool bOutputForScreen=false)
virtual void LoadStyles(SfxObjectShell &rSource)
void UpdateDocInfoForSave()
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
SAL_DLLPRIVATE void UpdateFromTemplate_Impl()
BitmapEx GetPreviewBitmap() const
const tools::Rectangle & GetVisArea() const
void SetSaveVersionOnClose(bool bSet)
void SetUseThumbnailSave(bool _bNew)
void SetUseUserData(bool bNew)
Size GetFirstPageSize() const
bool IsUseThumbnailSave() const
bool IsSaveVersionOnClose() const
void SetLoadReadonly(bool _bReadonly)
SAL_DLLPRIVATE bool IsModifyPasswordEntered() const
const css::uno::Sequence< css::beans::PropertyValue > & GetModifyPasswordInfo() const
bool IsHelpDocument() const
bool SetModifyPasswordHash(sal_uInt32 nHash)
virtual void SetModified(bool bModified=true)
SAL_DLLPRIVATE void UpdateTime_Impl(const css::uno::Reference< css::document::XDocumentProperties > &i_xDocProps)
bool IsQueryLoadTemplate() const
const OUString & GetName() const
Returns the name of the Shell object.
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
SfxStyleSearchBits GetMask() const
virtual const OUString & GetParent() const
const OUString & GetName() const
virtual bool HasFollowSupport() const
SfxStyleFamily GetFamily() const
virtual bool HasParentSupport() const
virtual SfxItemSet & GetItemSet()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual SfxPrinter * GetPrinter(bool bCreate=false)
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static TextNumerals GetCTLTextNumerals()
reference_type * get() const
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true, bool bAlphaMaskTransparent=false)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_INFO_EXCEPTION(area, stream)
tools::Long FRound(double fVal)
constexpr OUStringLiteral HID_QUERY_LOAD_TEMPLATE
#define LANGUAGE_ARABIC_SAUDI_ARABIA
def run(arg=None, arg2=-1)
@ DocWarnRemovePersonalInfo
bool IsOptionSet(EOption eOption)
COMPHELPER_DLLPUBLIC bool isFileUrl(std::u16string_view url)
static bool operator>(const util::DateTime &i_rLeft, const util::DateTime &i_rRight)
static void lcl_add(util::Duration &rDur, tools::Time const &rTime)
OUString SfxResId(TranslateId aId)