merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0205-always-allow-save-document-sfx2.diff
blob715bede9c524ac624a30065ffb6d4163cbdd57e7
1 diff --git sfx2/inc/sfx2/objsh.hxx sfx2/inc/sfx2/objsh.hxx
2 index f365bbf..c65280b 100644
3 --- sfx2/inc/sfx2/objsh.hxx
4 +++ sfx2/inc/sfx2/objsh.hxx
5 @@ -203,6 +203,10 @@ enum SfxTitleQuery
6 SFX_TITLE_QUERY_SAVE_NAME_PROPOSAL
7 };
9 +enum SfxApplicationFlagType
11 + SFX_APPFLAG_ALWAYS_ALLOW_SAVE
12 +};
14 class SfxToolBoxConfig;
15 struct TransferableObjectDescriptor;
16 @@ -350,6 +354,7 @@ public:
17 virtual sal_Bool SwitchPersistance(
18 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
19 virtual void UpdateLinks();
20 + virtual bool GetApplicationFlag(SfxApplicationFlagType eFlagType);
22 sal_Bool SaveChildren(BOOL bObjectsOnly=FALSE);
23 sal_Bool SaveAsChildren( SfxMedium &rMedium );
24 diff --git sfx2/source/doc/guisaveas.cxx sfx2/source/doc/guisaveas.cxx
25 index 049f9b7..da8f008 100644
26 --- sfx2/source/doc/guisaveas.cxx
27 +++ sfx2/source/doc/guisaveas.cxx
28 @@ -597,6 +597,7 @@ sal_Int8 ModelData_Impl::CheckStateForSave()
29 ::rtl::OUString aAuthorString = ::rtl::OUString::createFromAscii( "Author" );
30 ::rtl::OUString aInteractionHandlerString = ::rtl::OUString::createFromAscii( "InteractionHandler" );
31 ::rtl::OUString aStatusIndicatorString = ::rtl::OUString::createFromAscii( "StatusIndicator" );
32 + ::rtl::OUString aAlwaysSaveString = ::rtl::OUString::createFromAscii("AlwaysAllowSave");
34 if ( GetMediaDescr().find( aVersionCommentString ) != GetMediaDescr().end() )
36 @@ -616,9 +617,26 @@ sal_Int8 ModelData_Impl::CheckStateForSave()
37 if ( GetMediaDescr().size() != aAcceptedArgs.size() )
38 GetMediaDescr() = aAcceptedArgs;
40 - // the document must be modified
41 - if ( !GetModifiable()->isModified() && !bVersInfoNeedsStore )
42 - return STATUS_NO_ACTION;
43 + // the document must be modified unless the always-save flag is set.
44 + sal_Bool bAlwaysAllowSave = sal_False;
45 + uno::Reference<beans::XPropertySet> xPropSet(m_xModel, uno::UNO_QUERY);
46 + if (xPropSet.is())
47 + {
48 + try
49 + {
50 + uno::Any any = xPropSet->getPropertyValue( aAlwaysSaveString );
51 + any >>= bAlwaysAllowSave;
52 + }
53 + catch (const beans::UnknownPropertyException&)
54 + {
55 + // do nothing...
56 + }
57 + }
58 + if (!bAlwaysAllowSave)
59 + {
60 + if ( !GetModifiable()->isModified() && !bVersInfoNeedsStore )
61 + return STATUS_NO_ACTION;
62 + }
64 // if the document is readonly or a new one a SaveAs operation must be used
65 if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() )
66 diff --git sfx2/source/doc/objserv.cxx sfx2/source/doc/objserv.cxx
67 index 1d114cb..204dd55 100644
68 --- sfx2/source/doc/objserv.cxx
69 +++ sfx2/source/doc/objserv.cxx
70 @@ -988,8 +988,9 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
72 case SID_SAVEDOC:
74 - BOOL bMediumRO = IsReadOnlyMedium();
75 - if ( !bMediumRO && GetMedium() && IsModified() )
76 + bool bAllowSave = (GetApplicationFlag(SFX_APPFLAG_ALWAYS_ALLOW_SAVE) || IsModified());
77 + bool bMediumRO = IsReadOnlyMedium();
78 + if ( !bMediumRO && GetMedium() && bAllowSave )
79 rSet.Put(SfxStringItem(
80 nWhich, String(SfxResId(STR_SAVEDOC))));
81 else
82 diff --git sfx2/source/doc/objstor.cxx sfx2/source/doc/objstor.cxx
83 index e82361c..a060ddc 100644
84 --- sfx2/source/doc/objstor.cxx
85 +++ sfx2/source/doc/objstor.cxx
86 @@ -3825,6 +3825,11 @@ void SfxObjectShell::UpdateLinks()
90 +bool SfxObjectShell::GetApplicationFlag(SfxApplicationFlagType eFlagType)
92 + return false;
95 sal_Bool SfxObjectShell::QuerySaveSizeExceededModules_Impl( const uno::Reference< task::XInteractionHandler >& xHandler )
97 if ( !HasBasic() )