diff options
author | Mathias Bauer <mba@openoffice.org> | 2010-01-05 14:46:45 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2010-01-05 14:46:45 +0100 |
commit | 62b69e958ced6717e908f541cc84a83ec94242f3 (patch) | |
tree | fe6b6fb4e2763c706de7d6ef17b4cbfe2fefff4a /sfx2 | |
parent | 6fa6f4fa24eac5b3530360bc485edc7d596e26bd (diff) | |
parent | 0de34b05f3c1a0409d23b63b9e69d4d7abbe1090 (diff) |
merge commit for m68
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/dinfdlg.hxx | 66 | ||||
-rw-r--r-- | sfx2/inc/sfx2/docfile.hxx | 3 | ||||
-rw-r--r-- | sfx2/qa/complex/DocumentMetaData.java | 50 | ||||
-rw-r--r-- | sfx2/source/appl/shutdownicon.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/control/makefile.mk | 6 | ||||
-rw-r--r-- | sfx2/source/dialog/dialog.hrc | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 353 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.hrc | 22 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.src | 222 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 132 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 166 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 14 | ||||
-rwxr-xr-x | sfx2/source/doc/sfxacldetect.cxx | 216 | ||||
-rw-r--r-- | sfx2/source/inc/helpid.hrc | 3 | ||||
-rw-r--r-- | sfx2/source/inc/sfxlocal.hrc | 5 |
16 files changed, 1003 insertions, 304 deletions
diff --git a/sfx2/inc/sfx2/dinfdlg.hxx b/sfx2/inc/sfx2/dinfdlg.hxx index c8acf929b089..2c8448d6bca0 100644 --- a/sfx2/inc/sfx2/dinfdlg.hxx +++ b/sfx2/inc/sfx2/dinfdlg.hxx @@ -46,7 +46,7 @@ #include <svtools/headbar.hxx> #include <unotools/syslocale.hxx> #include <svl/zforlist.hxx> - +#include <com/sun/star/util/Duration.hpp> #include "tabdlg.hxx" namespace com { namespace sun { namespace star { @@ -358,6 +358,55 @@ public: inline CustomPropertyLine* GetLine() const { return m_pLine; } }; +class CustomPropertiesDateField : public DateField +{ +private: + CustomPropertyLine* m_pLine; + +public: + inline CustomPropertiesDateField( + Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) : + DateField( pParent, rResId ), m_pLine( pLine ) {} + + inline CustomPropertyLine* GetLine() const { return m_pLine; } +}; +class CustomPropertiesTimeField : public TimeField +{ +private: + CustomPropertyLine* m_pLine; + +public: + inline CustomPropertiesTimeField( + Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) : + TimeField( pParent, rResId ), m_pLine( pLine ) {} + + inline CustomPropertyLine* GetLine() const { return m_pLine; } +}; +class CustomPropertiesDurationField : public Edit +{ + CustomPropertyLine* m_pLine; + com::sun::star::util::Duration m_aDuration; +protected: + virtual void RequestHelp(const HelpEvent& rEvt); +public: + CustomPropertiesDurationField( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ); + ~CustomPropertiesDurationField(); + + void SetDuration( const com::sun::star::util::Duration& rDuration ); + const com::sun::star::util::Duration& GetDuration() const { return m_aDuration; } +}; + +class CustomPropertiesEditButton : public PushButton +{ + CustomPropertyLine* m_pLine; + +public: + CustomPropertiesEditButton( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ); + ~CustomPropertiesEditButton(); + + DECL_LINK(ClickHdl, PushButton*); +}; + class CustomPropertiesRemoveButton : public ImageButton { private: @@ -394,9 +443,18 @@ struct CustomPropertyLine ComboBox m_aNameBox; CustomPropertiesTypeBox m_aTypeBox; CustomPropertiesEdit m_aValueEdit; + CustomPropertiesDateField m_aDateField; + CustomPropertiesTimeField m_aTimeField; + const String m_sDurationFormat; + CustomPropertiesDurationField m_aDurationField; + CustomPropertiesEditButton m_aEditButton; CustomPropertiesYesNoButton m_aYesNoButton; CustomPropertiesRemoveButton m_aRemoveButton; + Point m_aDatePos; + Point m_aTimePos; + Size m_aDateTimeSize; + bool m_bIsRemoved; bool m_bTypeLostFocus; @@ -413,6 +471,10 @@ private: ComboBox m_aNameBox; ListBox m_aTypeBox; Edit m_aValueEdit; + DateField m_aDateField; + TimeField m_aTimeField; + Edit m_aDurationField; + PushButton m_aEditButton; CustomPropertiesYesNoButton m_aYesNoButton; ImageButton m_aRemoveButton; @@ -430,6 +492,8 @@ private: DECL_LINK( RemoveHdl, CustomPropertiesRemoveButton* ); DECL_LINK( EditLoseFocusHdl, CustomPropertiesEdit* ); DECL_LINK( BoxLoseFocusHdl, CustomPropertiesTypeBox* ); + //add lose focus handlers of Date/TimeField? + DECL_LINK( EditTimeoutHdl, Timer* ); DECL_LINK( BoxTimeoutHdl, Timer* ); diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 5488bb4e87e4..c322ee4afc0a 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -229,7 +229,7 @@ public: sal_Int8 ShowLockedDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock ); sal_Bool LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ); - void UnlockFile(); + void UnlockFile( sal_Bool bReleaseLockStream ); ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorage( sal_Bool bCreateTempIfNo = sal_True ); ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetOutputStorage(); @@ -290,6 +290,7 @@ public: SAL_DLLPRIVATE void Init_Impl(); SAL_DLLPRIVATE void ForceSynchronStream_Impl( sal_Bool bSynchron ); + SAL_DLLPRIVATE void GetLockingStream_Impl(); SAL_DLLPRIVATE void GetMedium_Impl(); SAL_DLLPRIVATE sal_Bool TryDirectTransfer( const ::rtl::OUString& aURL, SfxItemSet& aTargetSet ); SAL_DLLPRIVATE void Transfer_Impl(); diff --git a/sfx2/qa/complex/DocumentMetaData.java b/sfx2/qa/complex/DocumentMetaData.java index 8ecf28f37a5f..54b0f7afd3be 100644 --- a/sfx2/qa/complex/DocumentMetaData.java +++ b/sfx2/qa/complex/DocumentMetaData.java @@ -41,8 +41,10 @@ import com.sun.star.lang.XSingleServiceFactory; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.Locale; import com.sun.star.lang.EventObject; -import com.sun.star.util.Time; +import com.sun.star.util.Date; import com.sun.star.util.DateTime; +import com.sun.star.util.Time; +import com.sun.star.util.Duration; import com.sun.star.util.XModifyListener; import com.sun.star.util.XModifyBroadcaster; import com.sun.star.beans.XPropertyContainer; @@ -351,14 +353,30 @@ public class DocumentMetaData extends ComplexTestCase // differently some day... boolean b = true; double d = 3.1415; + // note that Time is only supported for backward compatibilty! Time t = new Time(); t.Hours = 1; t.Minutes = 16; + Date date = new Date(); + date.Year = 2071; + date.Month = 2; + date.Day = 3; dt.Year = 2065; + Duration dur = new Duration(); + dur.Negative = true; + dur.Years = 1001; + dur.Months = 999; + dur.Days = 888; + dur.Hours = 777; + dur.Minutes = 666; + dur.Seconds = 555; + dur.HundredthSeconds = 444; udpc.addProperty("Frobnicate", PropertyAttribute.REMOVEABLE, new Boolean(b)); - udpc.addProperty("FrobDuration", PropertyAttribute.REMOVEABLE, t); + udpc.addProperty("FrobDuration", PropertyAttribute.REMOVEABLE, dur); + udpc.addProperty("FrobDuration2", PropertyAttribute.REMOVEABLE, t); + udpc.addProperty("FrobEndDate", PropertyAttribute.REMOVEABLE, date); udpc.addProperty("FrobStartTime", PropertyAttribute.REMOVEABLE, dt); udpc.addProperty("Pi", PropertyAttribute.REMOVEABLE, new Double(d)); udpc.addProperty("Foo", PropertyAttribute.REMOVEABLE, "bar"); @@ -383,9 +401,13 @@ public class DocumentMetaData extends ComplexTestCase assure ("UserDefined bool", new Boolean(b).equals( udps.getPropertyValue("Frobnicate"))); - assure ("UserDefined time", eqTime(t, (Time) + assure ("UserDefined duration", eqDuration(dur, (Duration) udps.getPropertyValue("FrobDuration"))); - assure ("UserDefined date", eqDateTime(dt, (DateTime) + assure ("UserDefined time", eqTime(t, (Time) + udps.getPropertyValue("FrobDuration2"))); + assure ("UserDefined date", eqDate(date, (Date) + udps.getPropertyValue("FrobEndDate"))); + assure ("UserDefined datetime", eqDateTime(dt, (DateTime) udps.getPropertyValue("FrobStartTime"))); assure ("UserDefined float", new Double(d).equals( udps.getPropertyValue("Pi"))); @@ -423,9 +445,13 @@ public class DocumentMetaData extends ComplexTestCase assure ("UserDefined bool", new Boolean(b).equals( udps.getPropertyValue("Frobnicate"))); - assure ("UserDefined time", eqTime(t, (Time) + assure ("UserDefined duration", eqDuration(dur, (Duration) udps.getPropertyValue("FrobDuration"))); - assure ("UserDefined date", eqDateTime(dt, (DateTime) + assure ("UserDefined time", eqTime(t, (Time) + udps.getPropertyValue("FrobDuration2"))); + assure ("UserDefined date", eqDate(date, (Date) + udps.getPropertyValue("FrobEndDate"))); + assure ("UserDefined datetime", eqDateTime(dt, (DateTime) udps.getPropertyValue("FrobStartTime"))); assure ("UserDefined float", new Double(d).equals( udps.getPropertyValue("Pi"))); @@ -474,12 +500,24 @@ public class DocumentMetaData extends ComplexTestCase && a.HundredthSeconds == b.HundredthSeconds; } + boolean eqDate(Date a, Date b) { + return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day; + } + boolean eqTime(Time a, Time b) { return a.Hours == b.Hours && a.Minutes == b.Minutes && a.Seconds == b.Seconds && a.HundredthSeconds == b.HundredthSeconds; } + boolean eqDuration(Duration a, Duration b) { + return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days + && a.Hours == b.Hours && a.Minutes == b.Minutes + && a.Seconds == b.Seconds + && a.HundredthSeconds == b.HundredthSeconds + && a.Negative == b.Negative; + } + java.util.Collection fromArray(Object[] os) { java.util.Collection ret = new java.util.HashSet(); for (int i = 0; i < os.length; ++i) { diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 995b8250e072..52805082de38 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -69,6 +69,7 @@ #include <unistd.h> #include <errno.h> #endif +#include <vcl/timer.hxx> #include "sfxresid.hxx" @@ -186,6 +187,23 @@ bool ShutdownIcon::LoadModule( osl::Module **pModule, return true; } +class IdleUnloader : Timer +{ + ::osl::Module *m_pModule; +public: + IdleUnloader (::osl::Module **pModule) : + m_pModule (*pModule) + { + *pModule = NULL; + Start(); + } + virtual void Timeout() + { + delete m_pModule; + delete this; + } +}; + void ShutdownIcon::initSystray() { if (m_bInitialized) @@ -201,15 +219,15 @@ void ShutdownIcon::deInitSystray() { if (!m_bInitialized) return; + if (m_pDeInitSystray) m_pDeInitSystray(); m_bVeto = false; m_pInitSystray = 0; m_pDeInitSystray = 0; - if (m_pPlugin) - delete m_pPlugin; - m_pPlugin = 0; + new IdleUnloader (&m_pPlugin); + delete m_pFileDlg; m_pFileDlg = NULL; m_bInitialized = false; @@ -233,6 +251,7 @@ ShutdownIcon::ShutdownIcon( Reference< XMultiServiceFactory > aSMgr ) : ShutdownIcon::~ShutdownIcon() { deInitSystray(); + new IdleUnloader (&m_pPlugin); } // --------------------------------------------------------------------------- @@ -853,9 +872,11 @@ void ShutdownIcon::SetAutostart( bool bActivate ) ::osl::File::getFileURLFromSystemPath( aShortcut, aShortcutUrl ); ::osl::File::remove( aShortcutUrl ); #ifdef UNX - ShutdownIcon *pIcon = getInstance(); - if( pIcon ) + if (pShutdownIcon) + { + ShutdownIcon *pIcon = getInstance(); pIcon->deInitSystray(); + } #endif } #elif defined OS2 diff --git a/sfx2/source/control/makefile.mk b/sfx2/source/control/makefile.mk index 6de7b1e59ae6..a64cd08cd3ed 100644 --- a/sfx2/source/control/makefile.mk +++ b/sfx2/source/control/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -47,6 +47,10 @@ CFLAGS+=-Od .ENDIF .ENDIF +.IF "$(COM)"=="GCC" +CFLAGS+=-O0 +.ENDIF + # --- Files -------------------------------------------------------- SLOFILES = \ diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc index 72cc8c659bc4..44d9c7e346cf 100644 --- a/sfx2/source/dialog/dialog.hrc +++ b/sfx2/source/dialog/dialog.hrc @@ -109,6 +109,8 @@ #define STR_PDF_EXPORT_SEND ( RC_DIALOG_BEGIN + 120 ) #define STR_RECHECK_DOCUMENT ( RC_DIALOG_BEGIN + 121 ) #define IMG_INFO ( RC_DIALOG_BEGIN + 122 ) +#define RID_EDIT_DURATIONS ( RC_DIALOG_BEGIN + 123 ) +#define SFX_PB_EDIT ( RC_DIALOG_BEGIN + 124 ) #endif // #ifndef _SFX_DIALOG_HRC diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 60defa3f0b79..fe03231c6db7 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -54,7 +54,10 @@ #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertyContainer.hpp> +#include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/Duration.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <vcl/timer.hxx> @@ -73,6 +76,8 @@ #include <sfx2/sfx.hrc> #include "dinfdlg.hrc" #include "sfxlocal.hrc" +#include <dialog.hrc> +#include <vcl/help.hxx> #include <algorithm> @@ -1577,7 +1582,168 @@ CustomPropertiesYesNoButton::CustomPropertiesYesNoButton( Window* pParent, const m_aYesButton.SetBackground( aWall ); m_aNoButton.SetBackground( aWall ); } +class DurationDialog_Impl : public ModalDialog +{ + FixedLine aDurationFL; + + OKButton aOKPB; + CancelButton aCancelPB; + HelpButton aHelpPB; + + CheckBox aNegativeCB; + FixedText aYearFT; + NumericField aYearNF; + FixedText aMonthFT; + NumericField aMonthNF; + FixedText aDayFT; + NumericField aDayNF; + FixedText aHourFT; + NumericField aHourNF; + FixedText aMinuteFT; + NumericField aMinuteNF; + FixedText aSecondFT; + NumericField aSecondNF; + FixedText aHSecondFT; + NumericField aHSecondNF; + +public: + + DurationDialog_Impl( Window* pParent, const util::Duration& rDuration ); + ~DurationDialog_Impl(); + util::Duration GetDuration() const; +}; +/*-- 20.11.2009 15:40:46--------------------------------------------------- + + -----------------------------------------------------------------------*/ +DurationDialog_Impl::DurationDialog_Impl( Window* pParent, const util::Duration& rDuration ) : + ModalDialog( pParent, SfxResId( RID_EDIT_DURATIONS ) ), + aDurationFL(this, SfxResId( FL_DURATION )), + aOKPB( this, SfxResId( PB_OK )), + aCancelPB( this, SfxResId( PB_CANCEL )), + aHelpPB( this, SfxResId( PB_HELP )), + aNegativeCB(this, SfxResId( CB_NEGATIVE )), + aYearFT( this, SfxResId( FT_YEAR )), + aYearNF( this, SfxResId( ED_YEAR )), + aMonthFT( this, SfxResId( FT_MONTH )), + aMonthNF( this, SfxResId( ED_MONTH )), + aDayFT( this, SfxResId( FT_DAY )), + aDayNF( this, SfxResId( ED_DAY )), + aHourFT( this, SfxResId( FT_HOUR )), + aHourNF( this, SfxResId( ED_HOUR )), + aMinuteFT( this, SfxResId( FT_MINUTE )), + aMinuteNF( this, SfxResId( ED_MINUTE )), + aSecondFT( this, SfxResId( FT_SECOND )), + aSecondNF( this, SfxResId( ED_SECOND )), + aHSecondFT( this, SfxResId( FT_HSECOND )), + aHSecondNF( this, SfxResId( ED_HSECOND )) +{ + FreeResource(); + aNegativeCB.Check(rDuration.Negative); + aYearNF.SetValue(rDuration.Years); + aMonthNF.SetValue(rDuration.Months ); + aDayNF.SetValue(rDuration.Days ); + aHourNF.SetValue(rDuration.Hours ); + aMinuteNF.SetValue(rDuration.Minutes); + aSecondNF.SetValue(rDuration.Seconds); + aHSecondNF.SetValue(rDuration.HundredthSeconds); +} +/*-- 20.11.2009 16:08:55--------------------------------------------------- + + -----------------------------------------------------------------------*/ +DurationDialog_Impl::~DurationDialog_Impl() +{ +} +/*-- 20.11.2009 15:41:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +util::Duration DurationDialog_Impl::GetDuration() const +{ + util::Duration aRet; + aRet.Negative = aNegativeCB.IsChecked(); + aRet.Years = aYearNF.GetValue(); + aRet.Months = aMonthNF.GetValue( ); + aRet.Days = aDayNF.GetValue( ); + aRet.Hours = aHourNF.GetValue( ); + aRet.Minutes = aMinuteNF.GetValue(); + aRet.Seconds = aSecondNF.GetValue(); + aRet.HundredthSeconds = aHSecondNF.GetValue(); + return aRet; +} + +/*-- 20.11.2009 15:30:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +CustomPropertiesDurationField::CustomPropertiesDurationField( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) : + Edit( pParent, rResId ), m_pLine( pLine ) + +{ + SetDuration( util::Duration(false, 0, 0, 0, 0, 0, 0, 0) ); +} +/*-- 23.11.2009 08:46:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +CustomPropertiesDurationField::~CustomPropertiesDurationField() +{ +} +/*-- 23.11.2009 09:23:35--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void CustomPropertiesDurationField::RequestHelp( const HelpEvent& rHEvt ) +{ + if( rHEvt.GetMode() & HELPMODE_QUICK ) + { + Size aSize( GetSizePixel() ); + Rectangle aItemRect( rHEvt.GetMousePosPixel(), aSize ); + if(Help::IsBalloonHelpEnabled()) + Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), GetText() ); + else + Help::ShowQuickHelp( this, aItemRect, GetText(), + QUICKHELP_LEFT|QUICKHELP_VCENTER ); + } +} +/*-- 20.11.2009 15:30:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void CustomPropertiesDurationField::SetDuration( const util::Duration& rDuration ) +{ + m_aDuration = rDuration; + String sText(rDuration.Negative ? '-' : '+'); + sText += m_pLine->m_sDurationFormat; + sText.SearchAndReplace(String::CreateFromAscii( "%1"), String::CreateFromInt32( rDuration.Years ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%2"), String::CreateFromInt32( rDuration.Months ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%3"), String::CreateFromInt32( rDuration.Days ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%4"), String::CreateFromInt32( rDuration.Hours ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%5"), String::CreateFromInt32( rDuration.Minutes) ); + sText.SearchAndReplace(String::CreateFromAscii( "%6"), String::CreateFromInt32( rDuration.Seconds) ); + SetText( sText ); +} +/*-- 23.11.2009 08:51:15--------------------------------------------------- + + -----------------------------------------------------------------------*/ +CustomPropertiesEditButton::CustomPropertiesEditButton( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) : + PushButton( pParent, rResId ), m_pLine( pLine ) +{ + SetClickHdl( LINK( this, CustomPropertiesEditButton, ClickHdl )); +} +/*-- 23.11.2009 08:51:15--------------------------------------------------- + + -----------------------------------------------------------------------*/ +CustomPropertiesEditButton::~CustomPropertiesEditButton() +{ +} +/*-- 23.11.2009 08:47:37--------------------------------------------------- + + -----------------------------------------------------------------------*/ +IMPL_LINK( CustomPropertiesEditButton, ClickHdl, PushButton*, EMPTYARG ) +{ + DurationDialog_Impl* pDurationDlg = new DurationDialog_Impl( this, m_pLine->m_aDurationField.GetDuration() ); + if( RET_OK == pDurationDlg->Execute() ) + m_pLine->m_aDurationField.SetDuration( pDurationDlg->GetDuration() ); + delete pDurationDlg; + return 1; +} +//-------------------------------------------------------------------------- void CustomPropertiesYesNoButton::Resize() { const long nWidth = GetSizePixel().Width(); @@ -1598,12 +1764,20 @@ CustomPropertyLine::CustomPropertyLine( Window* pParent ) : m_aNameBox ( pParent, SfxResId( SFX_CB_PROPERTY_NAME ) ), m_aTypeBox ( pParent, SfxResId( SFX_LB_PROPERTY_TYPE ), this ), m_aValueEdit ( pParent, SfxResId( SFX_ED_PROPERTY_VALUE ), this ), + m_aDateField ( pParent, SfxResId( SFX_FLD_DATE), this), + m_aTimeField ( pParent, SfxResId( SFX_FLD_TIME), this), + m_sDurationFormat( SfxResId( SFX_ST_DURATION_FORMAT )), + m_aDurationField( pParent, SfxResId( SFX_FLD_DURATION), this), + m_aEditButton( pParent, SfxResId( SFX_PB_EDIT ), this), m_aYesNoButton ( pParent, SfxResId( SFX_WIN_PROPERTY_YESNO ) ), m_aRemoveButton ( pParent, SfxResId( SFX_PB_PROPERTY_REMOVE ), this ), m_bIsRemoved ( false ), m_bTypeLostFocus( false ) { + m_aTimeField.SetExtFormat( EXTTIMEF_24H_LONG ); + m_aDateField.SetExtDateFormat( XTDATEF_SYSTEM_SHORT_YYYY ); + m_aRemoveButton.SetModeImage( SfxResId( SFX_IMG_PROPERTY_REMOVE ), BMP_COLOR_NORMAL ); m_aRemoveButton.SetModeImage( SfxResId( SFX_IMG_PROPERTY_REMOVE_HC ), BMP_COLOR_HIGHCONTRAST ); } @@ -1615,6 +1789,10 @@ void CustomPropertyLine::SetRemoved() m_aNameBox.Hide(); m_aTypeBox.Hide(); m_aValueEdit.Hide(); + m_aDateField.Hide(); + m_aTimeField.Hide(); + m_aDurationField.Hide(); + m_aEditButton.Hide(); m_aYesNoButton.Hide(); m_aRemoveButton.Hide(); } @@ -1627,6 +1805,10 @@ CustomPropertiesWindow::CustomPropertiesWindow( Window* pParent, const ResId& rR m_aNameBox ( this, SfxResId( SFX_CB_PROPERTY_NAME ) ), m_aTypeBox ( this, SfxResId( SFX_LB_PROPERTY_TYPE ) ), m_aValueEdit ( this, SfxResId( SFX_ED_PROPERTY_VALUE ) ), + m_aDateField ( this, SfxResId( SFX_FLD_DATE) ), + m_aTimeField ( this, SfxResId( SFX_FLD_TIME) ), + m_aDurationField( this, SfxResId( SFX_FLD_DURATION) ), + m_aEditButton( this, SfxResId( SFX_PB_EDIT )), m_aYesNoButton ( this, SfxResId( SFX_WIN_PROPERTY_YESNO ) ), m_aRemoveButton ( this, SfxResId( SFX_PB_PROPERTY_REMOVE ) ), m_nScrollPos (0), @@ -1651,9 +1833,23 @@ IMPL_LINK( CustomPropertiesWindow, TypeHdl, CustomPropertiesTypeBox*, pBox ) { sal_Int64 nType = sal_Int64( (long)pBox->GetEntryData( pBox->GetSelectEntryPos() ) ); CustomPropertyLine* pLine = pBox->GetLine(); - BOOL bBooleanType = ( CUSTOM_TYPE_BOOLEAN == nType ); - pLine->m_aValueEdit.Show( !bBooleanType ); - pLine->m_aYesNoButton.Show( bBooleanType ); + pLine->m_aValueEdit.Show( (CUSTOM_TYPE_TEXT == nType) || (CUSTOM_TYPE_NUMBER == nType) ); + pLine->m_aDateField.Show( (CUSTOM_TYPE_DATE == nType) || (CUSTOM_TYPE_DATETIME == nType) ); + pLine->m_aTimeField.Show( CUSTOM_TYPE_DATETIME == nType ); + pLine->m_aDurationField.Show( CUSTOM_TYPE_DURATION == nType ); + pLine->m_aEditButton.Show( CUSTOM_TYPE_DURATION == nType ); + pLine->m_aYesNoButton.Show( CUSTOM_TYPE_BOOLEAN == nType ); + //adjust positions of date and time controls + if( nType == CUSTOM_TYPE_DATE ) + { + pLine->m_aDateField.SetPosSizePixel(pLine->m_aValueEdit.GetPosPixel(), pLine->m_aValueEdit.GetSizePixel()); + } + else if( nType == CUSTOM_TYPE_DATETIME) + { + pLine->m_aDateField.SetPosSizePixel( pLine->m_aDatePos, pLine->m_aDateTimeSize ); + pLine->m_aTimeField.SetPosSizePixel(pLine->m_aTimePos, pLine->m_aDateTimeSize ); + } + return 0; } @@ -1675,6 +1871,8 @@ IMPL_LINK( CustomPropertiesWindow, RemoveHdl, CustomPropertiesRemoveButton*, pBu continue; Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit, + &pLine->m_aDateField, &pLine->m_aTimeField, + &pLine->m_aDurationField, &pLine->m_aEditButton, &pLine->m_aYesNoButton, &pLine->m_aRemoveButton, NULL }; Window** pCurrent = pWindows; while ( *pCurrent ) @@ -1784,6 +1982,10 @@ void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBa m_aNameBox.Hide(); m_aTypeBox.Hide(); m_aValueEdit.Hide(); + m_aDateField.Hide(); + m_aTimeField.Hide(); + m_aDurationField.Hide(); + m_aEditButton.Hide(); m_aYesNoButton.Hide(); m_aRemoveButton.Hide(); @@ -1815,11 +2017,23 @@ void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBa if ( *pCurrent == &m_aValueEdit ) { + Point aDurationPos( aPos ); + m_aDurationField.SetPosPixel( aDurationPos ); + Size aDurationSize(aSize); + aDurationSize.Width() -= (m_aEditButton.GetSizePixel().Width() + 3 ); + m_aDurationField.SetSizePixel(aDurationSize); + aDurationPos.X() = aPos.X() - m_aEditButton.GetSizePixel().Width() + aSize.Width(); + m_aEditButton.SetPosPixel(aDurationPos); aSize = m_aYesNoButton.GetSizePixel(); aPos = m_aYesNoButton.GetPosPixel(); aSize.Width() = nWidth; aPos.X() = aRect.getX() + ( nOffset / 2 ); m_aYesNoButton.SetPosSizePixel( aPos, aSize ); + aSize.Width() /= 2; + aSize.Width() -= 2; + m_aDateField.SetPosSizePixel( aPos, aSize ); + aPos.X() += aSize.Width() + 4; + m_aTimeField.SetPosSizePixel( aPos, aSize ); } pCurrent++; @@ -1849,13 +2063,19 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny ) pNewLine->m_aTypeBox.SetSelectHdl( LINK( this, CustomPropertiesWindow, TypeHdl ) ); pNewLine->m_aRemoveButton.SetClickHdl( LINK( this, CustomPropertiesWindow, RemoveHdl ) ); pNewLine->m_aValueEdit.SetLoseFocusHdl( LINK( this, CustomPropertiesWindow, EditLoseFocusHdl ) ); + //add lose focus handlers of date/time fields + pNewLine->m_aTypeBox.SetLoseFocusHdl( LINK( this, CustomPropertiesWindow, BoxLoseFocusHdl ) ); long nPos = GetVisibleLineCount() * GetLineHeight(); m_aCustomPropertiesLines.push_back( pNewLine ); Window* pWindows[] = { &m_aNameBox, &m_aTypeBox, &m_aValueEdit, + &m_aDateField, &m_aTimeField, + &m_aDurationField, &m_aEditButton, &m_aYesNoButton, &m_aRemoveButton, NULL }; Window* pNewWindows[] = { &pNewLine->m_aNameBox, &pNewLine->m_aTypeBox, &pNewLine->m_aValueEdit, + &pNewLine->m_aDateField, &pNewLine->m_aTimeField, + &pNewLine->m_aDurationField, &pNewLine->m_aEditButton, &pNewLine->m_aYesNoButton, &pNewLine->m_aRemoveButton, NULL }; Window** pCurrent = pWindows; Window** pNewCurrent = pNewWindows; @@ -1870,11 +2090,17 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny ) pCurrent++; pNewCurrent++; } + // + pNewLine->m_aDatePos = pNewLine->m_aDateField.GetPosPixel(); + pNewLine->m_aTimePos = pNewLine->m_aTimeField.GetPosPixel(); + pNewLine->m_aDateTimeSize = pNewLine->m_aDateField.GetSizePixel(); double nTmpValue = 0; bool bTmpValue = false; ::rtl::OUString sTmpValue; - util::DateTime aTmpDate; + util::DateTime aTmpDateTime; + util::Date aTmpDate; + util::Duration aTmpDuration; SvtSysLocale aSysLocale; const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData(); pNewLine->m_aNameBox.SetText( sName ); @@ -1885,6 +2111,7 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny ) { sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue ); + pNewLine->m_aValueEdit.SetText( sValue ); nType = CUSTOM_TYPE_NUMBER; } else if ( rAny >>= bTmpValue ) @@ -1894,50 +2121,26 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny ) } else if ( rAny >>= sTmpValue ) { - sValue = String( sTmpValue ); + pNewLine->m_aValueEdit.SetText( sTmpValue ); nType = CUSTOM_TYPE_TEXT; } else if ( rAny >>= aTmpDate ) { - DateFormat eFormat = rLocaleWrapper.getDateFormat(); - sal_Unicode cDateSep = rLocaleWrapper.getDateSep().GetChar(0); - switch ( eFormat ) - { - case MDY : - { - sValue = String::CreateFromInt32( aTmpDate.Month ); - sValue += cDateSep; - sValue += String::CreateFromInt32( aTmpDate.Day ); - sValue += cDateSep; - if ( aTmpDate.Year < 10 ) - sValue += '0'; - sValue += String::CreateFromInt32( aTmpDate.Year ); - break; - } - case DMY : - { - sValue = String::CreateFromInt32( aTmpDate.Day ); - sValue += cDateSep; - sValue += String::CreateFromInt32( aTmpDate.Month ); - sValue += cDateSep; - if ( aTmpDate.Year < 10 ) - sValue += '0'; - sValue += String::CreateFromInt32( aTmpDate.Year ); - break; - } - case YMD : - { - if ( aTmpDate.Year < 10 ) - sValue += '0'; - sValue += String::CreateFromInt32( aTmpDate.Year ); - sValue += cDateSep; - sValue += String::CreateFromInt32( aTmpDate.Month ); - sValue += cDateSep; - sValue += String::CreateFromInt32( aTmpDate.Day ); - break; - } - } nType = CUSTOM_TYPE_DATE; + pNewLine->m_aDateField.SetDate( Date( aTmpDate.Day, aTmpDate.Month, aTmpDate.Year ) ); + + } + else if ( rAny >>= aTmpDuration ) + { + nType = CUSTOM_TYPE_DURATION; + pNewLine->m_aDurationField.SetDuration( aTmpDuration ); + } + else if ( rAny >>= aTmpDateTime ) + { + pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) ); + pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.HundredthSeconds ) ); + + nType = CUSTOM_TYPE_DATETIME; } if ( nType != CUSTOM_TYPE_UNKNOWN ) @@ -1949,8 +2152,6 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny ) else pNewLine->m_aYesNoButton.CheckNo(); } - else - pNewLine->m_aValueEdit.SetText( sValue ); pNewLine->m_aTypeBox.SelectEntryPos( m_aTypeBox.GetEntryPos( (void*)nType ) ); } @@ -2001,7 +2202,7 @@ void CustomPropertiesWindow::DoScroll( sal_Int32 nNewPos ) if ( pLine->m_bIsRemoved ) continue; - Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit, + Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit, &pLine->m_aDurationField, &pLine->m_aYesNoButton, &pLine->m_aRemoveButton, NULL }; Window** pCurrent = pWindows; while ( *pCurrent ) @@ -2065,52 +2266,24 @@ Sequence< beans::PropertyValue > CustomPropertiesWindow::GetCustomProperties() c bool bValue = pLine->m_aYesNoButton.IsYesChecked(); aPropertiesSeq[i].Value <<= makeAny( bValue ); } + else if ( CUSTOM_TYPE_DATETIME == nType ) + { + Date aTmpDate = pLine->m_aDateField.GetDate(); + Time aTmpTime = pLine->m_aTimeField.GetTime(); + util::DateTime aDateTime(aTmpTime.Get100Sec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(), + aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear() ); + aPropertiesSeq[i].Value <<= aDateTime; + } + else if ( CUSTOM_TYPE_DURATION == nType ) + { + aPropertiesSeq[i].Value <<= pLine->m_aDurationField.GetDuration(); + } else if ( CUSTOM_TYPE_DATE == nType ) { - const LocaleDataWrapper& rLocaleWrapper = SvtSysLocale().GetLocaleData(); - DateFormat eFormat = rLocaleWrapper.getDateFormat(); - sal_Unicode cDateSep = rLocaleWrapper.getDateSep().GetChar(0); - String sValue( pLine->m_aValueEdit.GetText() ); - if ( sValue.GetTokenCount( cDateSep ) == 3 ) - { - xub_StrLen nTokenDay = STRING_NOTFOUND; - xub_StrLen nTokenMonth = STRING_NOTFOUND; - xub_StrLen nTokenYear = STRING_NOTFOUND; - - switch ( eFormat ) - { - case MDY : - { - nTokenDay = 1; - nTokenMonth = 0; - nTokenYear = 2; - break; - } - case DMY : - { - nTokenDay = 0; - nTokenMonth = 1; - nTokenYear = 2; - break; - } - case YMD : - { - nTokenDay = 2; - nTokenMonth = 1; - nTokenYear = 0; - break; - } - } - - if ( nTokenDay != STRING_NOTFOUND ) - { - util::DateTime aDateTime( 0, 0, 0, 0, - sal_uInt16( sValue.GetToken( nTokenDay, cDateSep ).ToInt32() ), - sal_uInt16( sValue.GetToken( nTokenMonth, cDateSep ).ToInt32() ), - sal_uInt16( sValue.GetToken( nTokenYear, cDateSep ).ToInt32() ) ); - aPropertiesSeq[i].Value <<= makeAny( aDateTime ); - } - } + Date aTmpDate = pLine->m_aDateField.GetDate(); + util::Date aDate(aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear()); + aPropertiesSeq[i].Value <<= aDate; + } else { diff --git a/sfx2/source/dialog/dinfdlg.hrc b/sfx2/source/dialog/dinfdlg.hrc index 94bfb9ba16b6..49647c40e3ee 100644 --- a/sfx2/source/dialog/dinfdlg.hrc +++ b/sfx2/source/dialog/dinfdlg.hrc @@ -39,6 +39,8 @@ #define CUSTOM_TYPE_NUMBER 2 #define CUSTOM_TYPE_DATE 3 #define CUSTOM_TYPE_BOOLEAN 4 +#define CUSTOM_TYPE_DURATION 5 +#define CUSTOM_TYPE_DATETIME 6 // 4 TP_DOCINFORELOAD #define PAGE_WIDTH 260 @@ -154,5 +156,25 @@ #define STR_HEADER_VALUE 92 #define STR_HEADER_ACTION 93 +#define PB_OK 100 +#define PB_CANCEL 101 +#define PB_HELP 102 +#define CB_NEGATIVE 103 +#define FT_YEAR 104 +#define ED_YEAR 105 +#define FT_MONTH 106 +#define ED_MONTH 107 +#define FT_DAY 108 +#define ED_DAY 109 +#define FT_HOUR 110 +#define ED_HOUR 111 +#define FT_MINUTE 112 +#define ED_MINUTE 113 +#define FT_SECOND 114 +#define ED_SECOND 115 +#define FT_HSECOND 116 +#define ED_HSECOND 117 +#define FL_DURATION 118 + #endif diff --git a/sfx2/source/dialog/dinfdlg.src b/sfx2/source/dialog/dinfdlg.src index d8bf2085a5d9..3cad63ecb565 100644 --- a/sfx2/source/dialog/dinfdlg.src +++ b/sfx2/source/dialog/dinfdlg.src @@ -34,6 +34,7 @@ #include "helpid.hrc" #include "sfxlocal.hrc" #include "dinfdlg.hrc" +#include <dialog.hrc> // TP_DOCINFODESC -------------------------------------------------------- String STR_SFX_NEWOFFICEDOC @@ -579,14 +580,16 @@ ComboBox SFX_CB_PROPERTY_NAME ListBox SFX_LB_PROPERTY_TYPE { Pos = MAP_APPFONT ( 63 , 2 ) ; - Size = MAP_APPFONT ( 60 , 50 ) ; + Size = MAP_APPFONT ( 60 , 80 ) ; DropDown = TRUE; Border = TRUE; CurPos = 0; StringList [ en-US ] = { < "Text" ; CUSTOM_TYPE_TEXT ; > ; + < "DateTime" ; CUSTOM_TYPE_DATETIME ; > ; < "Date" ; CUSTOM_TYPE_DATE ; > ; + < "Duration" ; CUSTOM_TYPE_DURATION ; > ; < "Number" ; CUSTOM_TYPE_NUMBER ; > ; < "Yes or no" ; CUSTOM_TYPE_BOOLEAN ; > ; }; @@ -599,6 +602,44 @@ Edit SFX_ED_PROPERTY_VALUE TabStop = TRUE ; Left = TRUE ; }; +DateField SFX_FLD_DATE +{ + Border = TRUE ; + Pos = MAP_APPFONT ( 127 , 2 ) ; + Size = MAP_APPFONT ( 29 , RSC_CD_TEXTBOX_HEIGHT ) ; + TabStop = TRUE ; + Left = TRUE ; + Spin = TRUE; +}; +TimeField SFX_FLD_TIME +{ + Border = TRUE ; + Pos = MAP_APPFONT ( 159 , 2 ) ; + Size = MAP_APPFONT ( 29 , RSC_CD_TEXTBOX_HEIGHT ) ; + TabStop = TRUE ; + Left = TRUE ; + Spin = TRUE; +}; + +Edit SFX_FLD_DURATION +{ + Readonly = TRUE; + Border = TRUE ; + Pos = MAP_APPFONT ( 159 , 2 ) ; + Size = MAP_APPFONT ( 61 - RSC_CD_TEXTBOX_HEIGHT - 2, RSC_CD_TEXTBOX_HEIGHT ) ; + TabStop = TRUE ; +}; +PushButton SFX_PB_EDIT +{ + Pos = MAP_APPFONT ( 159 , 2 ) ; + Size = MAP_APPFONT ( RSC_CD_TEXTBOX_HEIGHT , RSC_CD_TEXTBOX_HEIGHT ) ; + Text = "..."; +}; +String SFX_ST_DURATION_FORMAT +{ + Text [en-US] = " Y: %1 M: %2 D: %3 H: %4 M: %5 S: %6"; +}; + Control SFX_WIN_PROPERTY_YESNO { HelpId = HID_CTRL_CUSTOMPROPS_YES_NO; @@ -684,3 +725,182 @@ TabDialog SID_DOCINFO }; }; +ModalDialog RID_EDIT_DURATIONS +{ + HelpId = HID_DLG_CUSTOMPROPS_DURATION; + OutputSize = TRUE ; + Size = MAP_APPFONT ( 176 , 140 ) ; + Text [ en-US ] = "Edit Duration" ; + Moveable = TRUE ; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 120 , 7 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + DefButton = TRUE; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 120 , 24 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 120 , 48 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + }; + FixedLine FL_DURATION + { + Pos = MAP_APPFONT ( 6 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; + Text [ en-US ] = "Duration" ; + }; + CheckBox CB_NEGATIVE + { + Pos = MAP_APPFONT ( 6 , 21 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "~Negative" ; + }; + FixedText FT_YEAR + { + Pos = MAP_APPFONT ( 6 , 38 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Left = TRUE ; + Text [ en-US ] = "~Years" ; + }; + NumericField ED_YEAR + { + Border = TRUE ; + Pos = MAP_APPFONT ( 70 , 36 ) ; + Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + Value = 0 ; + }; + FixedText FT_MONTH + { + Pos = MAP_APPFONT ( 6 , 52 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Left = TRUE ; + Text [ en-US ] = "~Months" ; + }; + NumericField ED_MONTH + { + Border = TRUE ; + Pos = MAP_APPFONT ( 70 , 50 ) ; + Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + Value = 0 ; + }; + FixedText FT_DAY + { + Pos = MAP_APPFONT ( 6 , 66 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Left = TRUE ; + Text [ en-US ] = "~Days" ; + }; + NumericField ED_DAY + { + Border = TRUE ; + Pos = MAP_APPFONT ( 70 , 64 ) ; + Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + Value = 0 ; + }; + FixedText FT_HOUR + { + Pos = MAP_APPFONT ( 6 , 80 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Left = TRUE ; + Text [ en-US ] = "H~ours" ; + }; + NumericField ED_HOUR + { + Border = TRUE ; + Pos = MAP_APPFONT ( 70 , 78 ) ; + Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + Value = 0 ; + }; + FixedText FT_MINUTE + { + Pos = MAP_APPFONT ( 6 , 94 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Left = TRUE ; + Text [ en-US ] = "Min~utes" ; + }; + NumericField ED_MINUTE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 70, 92) ; + Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + Value = 0 ; + }; + FixedText FT_SECOND + { + Pos = MAP_APPFONT ( 6, 108 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Left = TRUE ; + Text [ en-US ] = "~Seconds" ; + }; + NumericField ED_SECOND + { + Border = TRUE ; + Pos = MAP_APPFONT ( 70 , 106 ) ; + Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + Value = 0 ; + }; + FixedText FT_HSECOND + { + Pos = MAP_APPFONT ( 6 , 122 ) ; + Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Left = TRUE ; + Text [ en-US ] = "1/100 se~conds" ; + }; + NumericField ED_HSECOND + { + Border = TRUE ; + Pos = MAP_APPFONT ( 70 , 120 ) ; + Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + Value = 0 ; + }; + + + +}; diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index ef36831ab681..476d6f5186a5 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -66,6 +66,7 @@ #include "com/sun/star/xml/xpath/XXPathAPI.hpp" #include "com/sun/star/util/Date.hpp" #include "com/sun/star/util/Time.hpp" +#include "com/sun/star/util/Duration.hpp" #include "SfxDocumentMetaData.hxx" #include "rtl/ustrbuf.hxx" @@ -469,6 +470,11 @@ const char* s_nsODFMeta = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; const char* s_metaXml = "meta.xml"; +bool isValidDate(const css::util::Date & i_rDate) +{ + return i_rDate.Month > 0; +} + bool isValidDateTime(const css::util::DateTime & i_rDateTime) { return i_rDateTime.Month > 0; @@ -500,16 +506,25 @@ getQualifier(const char* i_name) { return ::rtl::OUString::createFromAscii(ns); } +bool SAL_CALL +textToDateOrDateTime(css::util::Date & io_rd, css::util::DateTime & io_rdt, + bool & o_rIsDateTime, ::rtl::OUString i_text) throw () +{ + if (::sax::Converter::convertDateOrDateTime( + io_rd, io_rdt, o_rIsDateTime, i_text)) { + return true; + } else { + DBG_WARNING1("SfxDocumentMetaData: invalid date: %s", + OUStringToOString(i_text, RTL_TEXTENCODING_UTF8).getStr()); + return false; + } +} + // convert string to date/time bool SAL_CALL textToDateTime(css::util::DateTime & io_rdt, ::rtl::OUString i_text) throw () { if (::sax::Converter::convertDateTime(io_rdt, i_text)) { - // NB: there may be rounding errors; handle these here - if (io_rdt.HundredthSeconds > 0) { - io_rdt.Seconds++; - io_rdt.HundredthSeconds = 0; - } return true; } else { DBG_WARNING1("SfxDocumentMetaData: invalid date: %s", @@ -528,6 +543,20 @@ textToDateTimeDefault(::rtl::OUString i_text) throw () return dt; } +// convert date to string +::rtl::OUString SAL_CALL +dateToText(css::util::Date const& i_rd) throw () +{ + if (isValidDate(i_rd)) { + ::rtl::OUStringBuffer buf; + ::sax::Converter::convertDate(buf, i_rd); + return buf.makeStringAndClear(); + } else { + return ::rtl::OUString(); + } +} + + // convert date/time to string ::rtl::OUString SAL_CALL dateTimeToText(css::util::DateTime const& i_rdt) throw () @@ -542,60 +571,48 @@ dateTimeToText(css::util::DateTime const& i_rdt) throw () } // convert string to duration -bool SAL_CALL -textToDuration(css::util::Time& io_rut, ::rtl::OUString i_text) throw () +bool +textToDuration(css::util::Duration& io_rDur, ::rtl::OUString const& i_rText) +throw () { - css::util::DateTime dt; - if (::sax::Converter::convertTime(dt, i_text)) { - // NB: there may be rounding errors; handle these here - if (dt.HundredthSeconds > 0) { - dt.Seconds++; - dt.HundredthSeconds = 0; - } - io_rut.Hours = dt.Hours; - io_rut.Minutes = dt.Minutes; - io_rut.Seconds = dt.Seconds; - io_rut.HundredthSeconds = dt.HundredthSeconds; + if (::sax::Converter::convertDuration(io_rDur, i_rText)) { return true; } else { DBG_WARNING1("SfxDocumentMetaData: invalid duration: %s", - OUStringToOString(i_text, RTL_TEXTENCODING_UTF8).getStr()); + OUStringToOString(i_rText, RTL_TEXTENCODING_UTF8).getStr()); return false; } } -sal_Int32 SAL_CALL textToDuration(::rtl::OUString i_text) throw () +sal_Int32 textToDuration(::rtl::OUString const& i_rText) throw () { - css::util::Time t; - if (textToDuration(t, i_text)) { - return t.Hours * 3600 + t.Minutes * 60 + t.Seconds; + css::util::Duration d; + if (textToDuration(d, i_rText)) { + return (d.Days * (24*3600)) + + (d.Hours * 3600) + (d.Minutes * 60) + d.Seconds; } else { return 0; // default } } // convert duration to string -::rtl::OUString SAL_CALL durationToText(css::util::Time const& i_rut) throw () +::rtl::OUString durationToText(css::util::Duration const& i_rDur) throw () { - css::util::DateTime dt; - dt.Hours = i_rut.Hours; - dt.Minutes = i_rut.Minutes; - dt.Seconds = i_rut.Seconds; - dt.HundredthSeconds = i_rut.HundredthSeconds; ::rtl::OUStringBuffer buf; - ::sax::Converter::convertTime(buf, dt); + ::sax::Converter::convertDuration(buf, i_rDur); return buf.makeStringAndClear(); } // convert duration to string ::rtl::OUString SAL_CALL durationToText(sal_Int32 i_value) throw () { - css::util::Time ut; - ut.Hours = static_cast<sal_Int16>(i_value / 3600); - ut.Minutes = static_cast<sal_Int16>((i_value % 3600) / 60); - ut.Seconds = static_cast<sal_Int16>(i_value % 60); - ut.HundredthSeconds = 0; - return durationToText(ut); + css::util::Duration ud; + ud.Days = static_cast<sal_Int16>(i_value / (24 * 3600)); + ud.Hours = static_cast<sal_Int16>((i_value % (24 * 3600)) / 3600); + ud.Minutes = static_cast<sal_Int16>((i_value % 3600) / 60); + ud.Seconds = static_cast<sal_Int16>(i_value % 60); + ud.HundredthSeconds = 0; + return durationToText(ud); } // extract base URL (necessary for converting relative links) @@ -922,17 +939,26 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet) } else if (type == ::cppu::UnoType<css::util::Date>::get()) { css::util::Date d; any >>= d; - css::util::DateTime dt; - dt.Year = d.Year; - dt.Month = d.Month; - dt.Day = d.Day; - values.push_back(dateTimeToText(dt)); + values.push_back(dateToText(d)); as.push_back(std::make_pair(vt, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date")))); } else if (type == ::cppu::UnoType<css::util::Time>::get()) { + // #i97029#: replaced by Duration + // Time is supported for backward compatibility with OOo 3.x, x<=2 css::util::Time ut; any >>= ut; - values.push_back(durationToText(ut)); + css::util::Duration ud; + ud.Hours = ut.Hours; + ud.Minutes = ut.Minutes; + ud.Seconds = ut.Seconds; + ud.HundredthSeconds = ut.HundredthSeconds; + values.push_back(durationToText(ud)); + as.push_back(std::make_pair(vt, + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time")))); + } else if (type == ::cppu::UnoType<css::util::Duration>::get()) { + css::util::Duration ud; + any >>= ud; + values.push_back(durationToText(ud)); as.push_back(std::make_pair(vt, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time")))); } else if (::cppu::UnoType<double>::get().isAssignableFrom(type)) { @@ -1250,18 +1276,24 @@ void SAL_CALL SfxDocumentMetaData::init( continue; } } else if (type.equalsAscii("date")) { + bool isDateTime; + css::util::Date d; css::util::DateTime dt; - if (textToDateTime(dt, text)) { - any <<= dt; + if (textToDateOrDateTime(d, dt, isDateTime, text)) { + if (isDateTime) { + any <<= dt; + } else { + any <<= d; + } } else { DBG_WARNING1("SfxDocumentMetaData: invalid date: %s", OUStringToOString(text, RTL_TEXTENCODING_UTF8).getStr()); continue; } } else if (type.equalsAscii("time")) { - css::util::Time ut; - if (textToDuration(ut, text)) { - any <<= ut; + css::util::Duration ud; + if (textToDuration(ud, text)) { + any <<= ud; } else { DBG_WARNING1("SfxDocumentMetaData: invalid time: %s", OUStringToOString(text, RTL_TEXTENCODING_UTF8).getStr()); @@ -2251,17 +2283,19 @@ void SfxDocumentMetaData::createUserDefined() // values of allowed types if ( !m_xUserDefined.is() ) { - css::uno::Sequence<css::uno::Type> types(10); + css::uno::Sequence<css::uno::Type> types(11); types[0] = ::cppu::UnoType<bool>::get(); types[1] = ::cppu::UnoType< ::rtl::OUString>::get(); types[2] = ::cppu::UnoType<css::util::DateTime>::get(); types[3] = ::cppu::UnoType<css::util::Date>::get(); - types[4] = ::cppu::UnoType<css::util::Time>::get(); + types[4] = ::cppu::UnoType<css::util::Duration>::get(); types[5] = ::cppu::UnoType<float>::get(); types[6] = ::cppu::UnoType<double>::get(); types[7] = ::cppu::UnoType<sal_Int16>::get(); types[8] = ::cppu::UnoType<sal_Int32>::get(); types[9] = ::cppu::UnoType<sal_Int64>::get(); + // Time is supported for backward compatibility with OOo 3.x, x<=2 + types[10] = ::cppu::UnoType<css::util::Time>::get(); css::uno::Sequence<css::uno::Any> args(2); args[0] <<= css::beans::NamedValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowedTypes")), diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 00bad511b10c..108c9f27858a 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -383,6 +383,8 @@ public: Reference < XInputStream > xInputStream; Reference < XStream > xStream; + uno::Reference< io::XStream > m_xLockingStream; + sal_uInt32 nLastStorageError; ::rtl::OUString aCharset; @@ -590,11 +592,14 @@ sal_Bool SfxMedium::DocNeedsFileDateCheck() //------------------------------------------------------------------ util::DateTime SfxMedium::GetInitFileDate( sal_Bool bIgnoreOldValue ) { - if ( ( bIgnoreOldValue || !pImp->m_bGotDateTime ) && GetContent().is() ) + if ( ( bIgnoreOldValue || !pImp->m_bGotDateTime ) && aLogicName.Len() ) { try { - pImp->aContent.getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DateModified" )) ) >>= pImp->m_aDateTime; + uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > xDummyEnv; + ::ucbhelper::Content aContent( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); + + aContent.getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DateModified" )) ) >>= pImp->m_aDateTime; pImp->m_bGotDateTime = sal_True; } catch ( ::com::sun::star::uno::Exception& ) @@ -1111,6 +1116,13 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) // otherwise the document should be opened readonly // if user cancel the loading the ERROR_ABORT is set + if ( pImp->m_bLocked && bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ) + { + // if the document is already locked the system locking might be temporarely off after storing + // check whether the system file locking should be taken again + GetLockingStream_Impl(); + } + sal_Bool bResult = pImp->m_bLocked; if ( !bResult ) @@ -1122,21 +1134,18 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) if ( !bResult && !IsReadOnly() ) { - // check whether the file is readonly in fs - // the check is only necessary if - // do it only for loading, some contents still might have problems with this property, let them not affect the saving sal_Bool bContentReadonly = sal_False; - if ( bLoading && ::utl::LocalFileHelper::IsLocalFile( aLogicName ) ) + if ( bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ) { - // let the stream be opened to check the possibility to open it for editing - GetMedium_Impl(); + // let the original document be opened to check the possibility to open it for editing + // and to let the writable stream stay open to hold the lock on the document + GetLockingStream_Impl(); } // "IsReadOnly" property does not allow to detect whether the file is readonly always // so we try always to open the file for editing // the file is readonly only in case the read-write stream can not be opened - SFX_ITEMSET_ARG( pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, sal_False); - if ( bLoading && !pWriteStreamItem ) + if ( bLoading && !pImp->m_xLockingStream.is() ) { try { @@ -2267,6 +2276,45 @@ void SfxMedium::ClearBackup_Impl() } //---------------------------------------------------------------- +void SfxMedium::GetLockingStream_Impl() +{ + if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) + && !pImp->m_xLockingStream.is() ) + { + SFX_ITEMSET_ARG( pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, sal_False); + if ( pWriteStreamItem ) + pWriteStreamItem->GetValue() >>= pImp->m_xLockingStream; + + if ( !pImp->m_xLockingStream.is() ) + { + // open the original document + uno::Sequence< beans::PropertyValue > xProps; + TransformItems( SID_OPENDOC, *GetItemSet(), xProps ); + comphelper::MediaDescriptor aMedium( xProps ); + + aMedium.addInputStreamOwnLock(); + + uno::Reference< io::XInputStream > xInputStream; + aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= pImp->m_xLockingStream; + aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream; + + if ( !pImp->pTempFile && !aName.Len() ) + { + // the medium is still based on the original file, it makes sence to initialize the streams + if ( pImp->m_xLockingStream.is() ) + pImp->xStream = pImp->m_xLockingStream; + + if ( xInputStream.is() ) + pImp->xInputStream = xInputStream; + + if ( !pImp->xInputStream.is() && pImp->xStream.is() ) + pImp->xInputStream = pImp->xStream->getInputStream(); + } + } + } +} + +//---------------------------------------------------------------- void SfxMedium::GetMedium_Impl() { if ( !pInStream ) @@ -2332,27 +2380,36 @@ void SfxMedium::GetMedium_Impl() TransformItems( SID_OPENDOC, *GetItemSet(), xProps ); comphelper::MediaDescriptor aMedium( xProps ); - if ( bFromTempFile ) + if ( pImp->m_xLockingStream.is() && !bFromTempFile ) { - aMedium[comphelper::MediaDescriptor::PROP_URL()] <<= ::rtl::OUString( aFileName ); - aMedium.erase( comphelper::MediaDescriptor::PROP_READONLY() ); - aMedium.addInputStream(); - } - else if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ) - { - // use the special locking approach only for file URLs - aMedium.addInputStreamOwnLock(); + // the medium is not based on the temporary file, so the original stream can be used + pImp->xStream = pImp->m_xLockingStream; } else - aMedium.addInputStream(); + { + if ( bFromTempFile ) + { + aMedium[comphelper::MediaDescriptor::PROP_URL()] <<= ::rtl::OUString( aFileName ); + aMedium.erase( comphelper::MediaDescriptor::PROP_READONLY() ); + aMedium.addInputStream(); + } + else if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ) + { + // use the special locking approach only for file URLs + aMedium.addInputStreamOwnLock(); + } + else + aMedium.addInputStream(); - // the ReadOnly property set in aMedium is ignored - // the check is done in LockOrigFileOnDemand() for file and non-file URLs + // the ReadOnly property set in aMedium is ignored + // the check is done in LockOrigFileOnDemand() for file and non-file URLs + + //TODO/MBA: what happens if property is not there?! + aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= pImp->xStream; + aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= pImp->xInputStream; + } - //TODO/MBA: what happens if property is not there?! GetContent(); - aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= pImp->xStream; - aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= pImp->xInputStream; if ( !pImp->xInputStream.is() && pImp->xStream.is() ) pImp->xInputStream = pImp->xStream->getInputStream(); } @@ -2661,7 +2718,7 @@ void SfxMedium::Close() CloseStreams_Impl(); - UnlockFile(); + UnlockFile( sal_False ); } void SfxMedium::CloseAndRelease() @@ -2694,11 +2751,31 @@ void SfxMedium::CloseAndRelease() CloseAndReleaseStreams_Impl(); - UnlockFile(); + UnlockFile( sal_True ); } -void SfxMedium::UnlockFile() +void SfxMedium::UnlockFile( sal_Bool bReleaseLockStream ) { + if ( pImp->m_xLockingStream.is() ) + { + if ( bReleaseLockStream ) + { + try + { + uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream(); + uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream(); + if ( xInStream.is() ) + xInStream->closeInput(); + if ( xOutStream.is() ) + xOutStream->closeOutput(); + } + catch( uno::Exception& ) + {} + } + + pImp->m_xLockingStream = uno::Reference< io::XStream >(); + } + if ( pImp->m_bLocked ) { try @@ -2720,8 +2797,14 @@ void SfxMedium::CloseAndReleaseStreams_Impl() uno::Reference< io::XInputStream > xInToClose = pImp->xInputStream; uno::Reference< io::XOutputStream > xOutToClose; if ( pImp->xStream.is() ) + { xOutToClose = pImp->xStream->getOutputStream(); + // if the locking stream is closed here the related member should be cleaned + if ( pImp->xStream == pImp->m_xLockingStream ) + pImp->m_xLockingStream = uno::Reference< io::XStream >(); + } + // The probably exsisting SvStream wrappers should be closed first CloseStreams_Impl(); @@ -3433,13 +3516,14 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace ) if ( !( nStorOpenMode & STREAM_TRUNC ) ) { + sal_Bool bTransferSuccess = sal_False; + if ( GetContent().is() && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) && ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ) { // if there is already such a document, we should copy it // if it is a file system use OS copy process - sal_Bool bTransferSuccess = sal_False; try { uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv; @@ -3460,16 +3544,14 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace ) catch( uno::Exception& ) {} - if ( !bTransferSuccess ) + if ( bTransferSuccess ) { - SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); - return; + CloseOutStream(); + CloseInStream(); } - - CloseOutStream(); - CloseInStream(); } - else if ( pInStream ) + + if ( !bTransferSuccess && pInStream ) { // the case when there is no URL-access available or this is a remote protocoll // but there is an input stream @@ -3489,13 +3571,25 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace ) pOutStream->Write( pBuf, nRead ); } + bTransferSuccess = sal_True; delete[] pBuf; CloseInStream(); } CloseOutStream_Impl(); } else + { + // Quite strange design, but currently it is expected that in this case no transfer happens + // TODO/LATER: get rid of this inconsistent part of the call design + bTransferSuccess = sal_True; CloseInStream(); + } + + if ( !bTransferSuccess ) + { + SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); + return; + } } CloseStorage(); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 09943f5cca38..3c78bad9220e 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -2538,12 +2538,20 @@ void SfxObjectShell::StoreLog() if ( pImp->m_xLogRing.is() ) { - ::rtl::OUString aFileURL = - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}" ) ); +#ifdef WNT + ::rtl::OUString aFileURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}" ) ); +#else + ::rtl::OUString aFileURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}" ) ); +#endif + ::rtl::Bootstrap::expandMacros( aFileURL ); - ::rtl::OUString aBuildID = - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/setup.ini:buildid}" ) ); +#ifdef WNT + ::rtl::OUString aBuildID = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/setup.ini:buildid}" ) ); +#else + ::rtl::OUString aBuildID = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/setuprc:buildid}" ) ); +#endif + ::rtl::Bootstrap::expandMacros( aBuildID ); if ( aFileURL.getLength() ) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 287cb5b96179..ead9a7c9fd9a 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1871,7 +1871,19 @@ sal_Bool SfxObjectShell::DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMediu { uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY_THROW ); ::rtl::OUString aBackupURL = rTargetMedium.GetBackup_Impl(); - if ( aBackupURL.getLength() ) + if ( !aBackupURL.getLength() ) + { + // the backup could not be created, try to disconnect the storage and close the source SfxMedium + // in this case the optimization is not possible, connect storage to a temporary file + rTargetMedium.ResetError(); + xOptStorage->writeAndAttachToStream( uno::Reference< io::XStream >() ); + rSrcMedium.CanDisposeStorage_Impl( sal_False ); + rSrcMedium.Close(); + + // now try to create the backup + rTargetMedium.GetBackup_Impl(); + } + else { // the following call will only compare stream sizes // TODO/LATER: this is a very risky part, since if the URL contents are different from the storage diff --git a/sfx2/source/doc/sfxacldetect.cxx b/sfx2/source/doc/sfxacldetect.cxx index 94370e9a1c52..b156d409c9be 100755 --- a/sfx2/source/doc/sfxacldetect.cxx +++ b/sfx2/source/doc/sfxacldetect.cxx @@ -1,108 +1,108 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: shutdowniconw32.cxx,v $
- * $Revision: 1.48 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifdef WNT
-
-// necessary to include system headers without warnings
-#ifdef _MSC_VER
-#pragma warning(disable:4668 4917)
-#endif
-
-#include <windows.h>
-#include <lmaccess.h>
-#include <sal/types.h>
-
-sal_Bool IsReadonlyAccordingACL( const sal_Unicode* pFilePath )
-{
- sal_Bool bResult = sal_False;
-
- sal_uInt32 nFDSize = 0;
- GetFileSecurityW( pFilePath, DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, NULL, 0, &nFDSize );
- if ( nFDSize )
- {
- PSECURITY_DESCRIPTOR pFileDescr = reinterpret_cast< PSECURITY_DESCRIPTOR >( malloc( nFDSize ) );
- if ( GetFileSecurityW( pFilePath, DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, pFileDescr, nFDSize, &nFDSize ) )
- {
- HANDLE hToken = NULL;
- if ( OpenThreadToken( GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken )
- || OpenProcessToken( GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken) )
- {
- HANDLE hImpersonationToken = NULL;
- if ( DuplicateToken( hToken, SecurityImpersonation, &hImpersonationToken) )
- {
- sal_uInt32 nDesiredAccess = ACCESS_WRITE;
- GENERIC_MAPPING aGenericMapping = { ACCESS_READ, ACCESS_WRITE, 0, ACCESS_READ | ACCESS_WRITE };
- MapGenericMask( &nDesiredAccess, &aGenericMapping );
-
- PRIVILEGE_SET aPrivilegeSet;
- sal_uInt32 nPrivilegeSetSize = sizeof( PRIVILEGE_SET );
-
- sal_uInt32 nGrantedAccess;
- BOOL bAccessible = TRUE;
- if ( AccessCheck( pFileDescr,
- hImpersonationToken,
- nDesiredAccess,
- &aGenericMapping,
- &aPrivilegeSet,
- &nPrivilegeSetSize,
- &nGrantedAccess,
- &bAccessible ) )
- {
- bResult = !bAccessible;
- }
-
- CloseHandle( hImpersonationToken );
- }
-
- CloseHandle( hToken );
- }
- }
-
- free( pFileDescr );
- }
-
- return bResult;
-}
-
-#else // this is UNX
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sfx2.hxx"
-
-
-#include <sal/types.h>
-
-sal_Bool IsReadonlyAccordingACL( const sal_Unicode* )
-{
- // to be implemented
- return sal_False;
-}
-
-#endif
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: shutdowniconw32.cxx,v $ + * $Revision: 1.48 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef WNT + +// necessary to include system headers without warnings +#ifdef _MSC_VER +#pragma warning(disable:4668 4917) +#endif + +#include <windows.h> +#include <lmaccess.h> +#include <sal/types.h> + +sal_Bool IsReadonlyAccordingACL( const sal_Unicode* pFilePath ) +{ + sal_Bool bResult = sal_False; + + sal_uInt32 nFDSize = 0; + GetFileSecurityW( reinterpret_cast< LPCWSTR >(pFilePath), DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, NULL, 0, &nFDSize ); + if ( nFDSize ) + { + PSECURITY_DESCRIPTOR pFileDescr = reinterpret_cast< PSECURITY_DESCRIPTOR >( malloc( nFDSize ) ); + if ( GetFileSecurityW( reinterpret_cast< LPCWSTR >(pFilePath), DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, pFileDescr, nFDSize, &nFDSize ) ) + { + HANDLE hToken = NULL; + if ( OpenThreadToken( GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken ) + || OpenProcessToken( GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken) ) + { + HANDLE hImpersonationToken = NULL; + if ( DuplicateToken( hToken, SecurityImpersonation, &hImpersonationToken) ) + { + sal_uInt32 nDesiredAccess = ACCESS_WRITE; + GENERIC_MAPPING aGenericMapping = { ACCESS_READ, ACCESS_WRITE, 0, ACCESS_READ | ACCESS_WRITE }; + MapGenericMask( &nDesiredAccess, &aGenericMapping ); + + PRIVILEGE_SET aPrivilegeSet; + sal_uInt32 nPrivilegeSetSize = sizeof( PRIVILEGE_SET ); + + sal_uInt32 nGrantedAccess; + BOOL bAccessible = TRUE; + if ( AccessCheck( pFileDescr, + hImpersonationToken, + nDesiredAccess, + &aGenericMapping, + &aPrivilegeSet, + &nPrivilegeSetSize, + &nGrantedAccess, + &bAccessible ) ) + { + bResult = !bAccessible; + } + + CloseHandle( hImpersonationToken ); + } + + CloseHandle( hToken ); + } + } + + free( pFileDescr ); + } + + return bResult; +} + +#else // this is UNX +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sfx2.hxx" + + +#include <sal/types.h> + +sal_Bool IsReadonlyAccordingACL( const sal_Unicode* ) +{ + // to be implemented + return sal_False; +} + +#endif + diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc index d9ae996bf603..b8beacafee3a 100644 --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -346,8 +346,9 @@ #define HID_TP_CUSTOMPROPERTIES (HID_SFX_START + 324) #define HID_CTRL_CUSTOMPROPERTIES (HID_SFX_START + 325) #define HID_CTRL_CUSTOMPROPS_YES_NO (HID_SFX_START + 326) +#define HID_DLG_CUSTOMPROPS_DURATION (HID_SFX_START + 327) -#define ACT_SFX_HID_END HID_CTRL_CUSTOMPROPS_YES_NO +#define ACT_SFX_HID_END HID_DLG_CUSTOMPROPS_DURATION // "Uberlaufpr"ufung -------------------------------------------------------- diff --git a/sfx2/source/inc/sfxlocal.hrc b/sfx2/source/inc/sfxlocal.hrc index 2ad3670ab014..bc7d267d75d8 100644 --- a/sfx2/source/inc/sfxlocal.hrc +++ b/sfx2/source/inc/sfxlocal.hrc @@ -60,6 +60,11 @@ #define SFX_QB_WRONG_TYPE (RID_SFX_SFXLOCAL_START + 7) #define SFX_IMG_PROPERTY_REMOVE (RID_SFX_SFXLOCAL_START + 8) #define SFX_IMG_PROPERTY_REMOVE_HC (RID_SFX_SFXLOCAL_START + 9) +#define SFX_FLD_DATE (RID_SFX_SFXLOCAL_START + 10) +#define SFX_FLD_TIME (RID_SFX_SFXLOCAL_START + 11) +#define SFX_FLD_DURATION (RID_SFX_SFXLOCAL_START + 12) +#define SFX_ST_DURATION_FORMAT (RID_SFX_SFXLOCAL_START + 13) + #endif |