uno: new InteropGrabBag UNO prop in OfficeDocument

Added the new InteropGrabBag property to the OfficeDocument service
and modified the JUnit UNO unit tests for it.

Added specific implementation in the sfx2 module for the SfxBaseModel
class.

Added specific inherited implementations in the sc, sd, starmath and
sw modules for the ScModelObj, SdXImpressDocument, SmModel, and
SwXTextDocument classes.

This new property is intended by now for its usage on preserving OOX's
theming although the aim is to be able to re-create the theming in the
future from saved properties.

It could also be used for preserving other attributes for
interoperability among document formats.

Change-Id: Ia822856293c70ae22911afa794e3e38bcaa31f86
Reviewed-on: https://gerrit.libreoffice.org/6000
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
Andres Gomez 2013-09-17 18:30:17 +03:00 committed by Miklos Vajna
parent 652b0b6d18
commit bee6b8f2ba
16 changed files with 98 additions and 3 deletions

View File

@ -1411,6 +1411,11 @@ protected:
/* returns true if the document signatures are valid, otherwise false */
sal_Bool hasValidSignatures() const;
/* GrabBagItem for interim interop purposes */
void getGrabBagItem(com::sun::star::uno::Any& rVal) const;
void setGrabBagItem(const com::sun::star::uno::Any& rVal);
//________________________________________________________________________________________________________
// private methods
//________________________________________________________________________________________________________

View File

@ -155,6 +155,17 @@ published service OfficeDocument
may get a different id every time it gets loaded.</p>
*/
[property, optional, readonly] string RuntimeUID;
/** Grab bag of document properties, used as a string-any map for
interim interop purposes.
@since LibreOffice 4.2
<p>This property is intentionally not handled by the ODF
filter. Any member that should be handled there should be
first moved out from this grab bag to a separate property.</p>
*/
[optional, property] sequence<com::sun::star::beans::PropertyValue> InteropGrabBag;
};

View File

@ -76,6 +76,7 @@
"ScModelObj";"com::sun::star::document::OfficeDocument";"AutomaticControlFocus#optional"
"ScModelObj";"com::sun::star::document::OfficeDocument";"ApplyFormDesignMode#optional"
"ScModelObj";"com::sun::star::document::OfficeDocument";"RuntimeUID#optional"
"ScModelObj";"com::sun::star::document::OfficeDocument";"InteropGrabBag#optional"
"ScModelObj";"com::sun::star::frame::XModel";"attachResource()"
"ScModelObj";"com::sun::star::frame::XModel";"getURL()"
"ScModelObj";"com::sun::star::frame::XModel";"getArgs()"

1 ScModelObj com::sun::star::drawing::XDrawPagesSupplier getDrawPages()
76 ScModelObj com::sun::star::document::OfficeDocument AutomaticControlFocus#optional
77 ScModelObj com::sun::star::document::OfficeDocument ApplyFormDesignMode#optional
78 ScModelObj com::sun::star::document::OfficeDocument RuntimeUID#optional
79 ScModelObj com::sun::star::document::OfficeDocument InteropGrabBag#optional
80 ScModelObj com::sun::star::frame::XModel attachResource()
81 ScModelObj com::sun::star::frame::XModel getURL()
82 ScModelObj com::sun::star::frame::XModel getArgs()

View File

@ -43,6 +43,7 @@
"SdXImpressDocument";"com::sun::star::document::OfficeDocument";"AutomaticControlFocus#optional"
"SdXImpressDocument";"com::sun::star::document::OfficeDocument";"ApplyFormDesignMode#optional"
"SdXImpressDocument";"com::sun::star::document::OfficeDocument";"RuntimeUID#optional"
"SdXImpressDocument";"com::sun::star::document::OfficeDocument";"InteropGrabBag#optional"
"SdXImpressDocument";"com::sun::star::frame::XModel";"attachResource()"
"SdXImpressDocument";"com::sun::star::frame::XModel";"getURL()"
"SdXImpressDocument";"com::sun::star::frame::XModel";"getArgs()"

1 SdXImpressDocument com::sun::star::drawing::XDrawPagesSupplier getDrawPages()
43 SdXImpressDocument com::sun::star::document::OfficeDocument AutomaticControlFocus#optional
44 SdXImpressDocument com::sun::star::document::OfficeDocument ApplyFormDesignMode#optional
45 SdXImpressDocument com::sun::star::document::OfficeDocument RuntimeUID#optional
46 SdXImpressDocument com::sun::star::document::OfficeDocument InteropGrabBag#optional
47 SdXImpressDocument com::sun::star::frame::XModel attachResource()
48 SdXImpressDocument com::sun::star::frame::XModel getURL()
49 SdXImpressDocument com::sun::star::frame::XModel getArgs()

View File

@ -67,6 +67,7 @@
"SwXTextDocument";"com::sun::star::document::OfficeDocument";"AutomaticControlFocus#optional"
"SwXTextDocument";"com::sun::star::document::OfficeDocument";"ApplyFormDesignMode#optional"
"SwXTextDocument";"com::sun::star::document::OfficeDocument";"RuntimeUID#optional"
"SwXTextDocument";"com::sun::star::document::OfficeDocument";"InteropGrabBag#optional"
"SwXTextDocument";"com::sun::star::frame::XModel";"attachResource()"
"SwXTextDocument";"com::sun::star::frame::XModel";"getURL()"
"SwXTextDocument";"com::sun::star::frame::XModel";"getArgs()"

1 SwXTextDocument com::sun::star::document::XEventBroadcaster#optional addEventListener()
67 SwXTextDocument com::sun::star::document::OfficeDocument AutomaticControlFocus#optional
68 SwXTextDocument com::sun::star::document::OfficeDocument ApplyFormDesignMode#optional
69 SwXTextDocument com::sun::star::document::OfficeDocument RuntimeUID#optional
70 SwXTextDocument com::sun::star::document::OfficeDocument InteropGrabBag#optional
71 SwXTextDocument com::sun::star::frame::XModel attachResource()
72 SwXTextDocument com::sun::star::frame::XModel getURL()
73 SwXTextDocument com::sun::star::frame::XModel getArgs()

View File

@ -507,6 +507,7 @@
#define SC_UNO_ISCHANGEREADONLYENABLED "IsChangeReadOnlyEnabled"
#define SC_UNO_REFERENCEDEVICE "ReferenceDevice"
#define SC_UNO_CODENAME "CodeName"
#define SC_UNO_INTEROPGRABBAG "InteropGrabBag"
// document properties from FormModel
#define SC_UNO_APPLYFMDES "ApplyFormDesignMode"

View File

@ -100,6 +100,14 @@ using namespace com::sun::star;
//------------------------------------------------------------------------
#ifndef SEQTYPE
#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
#define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
#else
#define SEQTYPE(x) &(x)
#endif
#endif
// alles ohne Which-ID, Map nur fuer PropertySetInfo
//! umbenennen, sind nicht mehr nur Options
@ -147,6 +155,7 @@ static const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap()
{MAP_CHAR_LEN(SC_UNO_REFERENCEDEVICE), 0, &getCppuType((uno::Reference<awt::XDevice>*)0), beans::PropertyAttribute::READONLY, 0},
{MAP_CHAR_LEN("BuildId"), 0, &::getCppuType(static_cast< const OUString * >(0)), 0, 0},
{MAP_CHAR_LEN(SC_UNO_CODENAME), 0, &getCppuType(static_cast< const OUString * >(0)), 0, 0},
{MAP_CHAR_LEN(SC_UNO_INTEROPGRABBAG), 0, SEQTYPE(::getCppuType((uno::Sequence< beans::PropertyValue >*)0)), 0, 0},
{0,0,0,0,0,0}
};
@ -1704,6 +1713,10 @@ void SAL_CALL ScModelObj::setPropertyValue(
if ( !aObjName.isEmpty() )
pDoc->RestoreChartListener( aObjName );
}
else if ( aString.EqualsAscii( SC_UNO_INTEROPGRABBAG ) )
{
setGrabBagItem(aValue);
}
if ( aNewOpt != rOldOpt )
{
@ -1883,6 +1896,10 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName )
{
ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL) );
}
else if ( aString.EqualsAscii( SC_UNO_INTEROPGRABBAG ) )
{
getGrabBagItem(aRet);
}
}
return aRet;

View File

@ -127,6 +127,7 @@ const char sUNO_Prop_UserDefinedAttributes[] = "UserDefinedAttributes";
const char sUNO_Prop_BookmarkURL[] = "BookmarkURL";
const char sUNO_Prop_RuntimeUID[] = "RuntimeUID";
const char sUNO_Prop_HasValidSignatures[] = "HasValidSignatures";
const char sUNO_Prop_InteropGrabBag[] = "InteropGrabBag";
// view settings
const char sUNO_View_ViewId[] = "ViewId";

View File

@ -173,6 +173,7 @@ const sal_Int32 WID_MODEL_BUILDID = 10;
const sal_Int32 WID_MODEL_HASVALIDSIGNATURES = 11;
const sal_Int32 WID_MODEL_DIALOGLIBS = 12;
const sal_Int32 WID_MODEL_FONTS = 13;
const sal_Int32 WID_MODEL_INTEROPGRABBAG = 14;
#ifndef SEQTYPE
#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
@ -200,6 +201,7 @@ const SvxItemPropertySet* ImplGetDrawModelPropertySet()
{ MAP_CHAR_LEN(sUNO_Prop_RuntimeUID), WID_MODEL_RUNTIMEUID, &::getCppuType(static_cast< const OUString * >(0)), beans::PropertyAttribute::READONLY, 0 },
{ MAP_CHAR_LEN(sUNO_Prop_HasValidSignatures), WID_MODEL_HASVALIDSIGNATURES, &::getCppuType(static_cast< const sal_Bool * >(0)), beans::PropertyAttribute::READONLY, 0 },
{ MAP_CHAR_LEN("Fonts"), WID_MODEL_FONTS, SEQTYPE(::getCppuType((uno::Sequence<uno::Any>*)0)), beans::PropertyAttribute::READONLY, 0},
{ MAP_CHAR_LEN(sUNO_Prop_InteropGrabBag), WID_MODEL_INTEROPGRABBAG, SEQTYPE(::getCppuType((uno::Sequence< beans::PropertyValue >*)0)), 0, 0},
{ 0,0,0,0,0,0 }
};
static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
@ -1264,6 +1266,9 @@ void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyNam
case WID_MODEL_DIALOGLIBS:
case WID_MODEL_FONTS:
throw beans::PropertyVetoException();
case WID_MODEL_INTEROPGRABBAG:
setGrabBagItem(aValue);
break;
default:
throw beans::UnknownPropertyException();
}
@ -1386,6 +1391,9 @@ uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& Property
aAny <<= aSeq;
break;
}
case WID_MODEL_INTEROPGRABBAG:
getGrabBagItem(aAny);
break;
default:
throw beans::UnknownPropertyException();
}

View File

@ -60,6 +60,7 @@
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
#include <svl/grabbagitem.hxx>
#include <basic/sbx.hxx>
#include <basic/sbuno.hxx>
#include <tools/urlobj.hxx>
@ -213,6 +214,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
Reference< rdf::XDocumentMetadataAccess> m_xDocumentMetadata;
::rtl::Reference< ::sfx2::DocumentUndoManager > m_pDocumentUndoManager;
Sequence< document::CmisProperty> m_cmisProperties;
SfxGrabBagItem* m_pGrabBagItem ;
IMPL_SfxBaseModel_DataContainer( ::osl::Mutex& rMutex, SfxObjectShell* pObjectShell )
: m_pObjectShell ( pObjectShell )
@ -231,6 +233,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
, m_xDocumentMetadata () // lazy
, m_pDocumentUndoManager ()
, m_cmisProperties ()
, m_pGrabBagItem ( NULL )
{
// increase global instance counter.
++g_nInstanceCounter;
@ -240,6 +243,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
virtual ~IMPL_SfxBaseModel_DataContainer()
{
delete m_pGrabBagItem;
}
// ::sfx2::IModifiableDocument
@ -3460,6 +3464,24 @@ sal_Bool SfxBaseModel::hasValidSignatures() const
return sal_False;
}
void SfxBaseModel::getGrabBagItem(com::sun::star::uno::Any& rVal) const
{
if (m_pData->m_pGrabBagItem != NULL)
m_pData->m_pGrabBagItem->QueryValue(rVal);
else {
uno::Sequence<beans::PropertyValue> aValue(0);
rVal = uno::makeAny(aValue);
}
}
void SfxBaseModel::setGrabBagItem(const com::sun::star::uno::Any& rVal)
{
if (m_pData->m_pGrabBagItem == NULL)
m_pData->m_pGrabBagItem = new SfxGrabBagItem;
m_pData->m_pGrabBagItem->PutValue(rVal);
}
static void GetCommandFromSequence( OUString& rCommand, sal_Int32& nIndex, const Sequence< beans::PropertyValue >& rSeqPropValue )
{
nIndex = -1;

View File

@ -228,9 +228,18 @@ enum SmModelPropertyHandles
HANDLE_RUNTIME_UID,
HANDLE_LOAD_READONLY, // Security Options
HANDLE_DIALOG_LIBRARIES, // #i73329#
HANDLE_BASELINE
HANDLE_BASELINE,
HANDLE_INTEROP_GRAB_BAG,
};
#ifndef SEQTYPE
#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
#define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
#else
#define SEQTYPE(x) &(x)
#endif
#endif
static PropertySetInfo * lcl_createModelPropertyInfo ()
{
static PropertyMapEntry aModelPropertyInfoMap[] =
@ -302,6 +311,7 @@ static PropertySetInfo * lcl_createModelPropertyInfo ()
{ RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY, &::getBooleanCppuType(), PROPERTY_NONE, 0 },
// #i972#
{ RTL_CONSTASCII_STRINGPARAM( "BaseLine"), HANDLE_BASELINE, &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, 0},
{ RTL_CONSTASCII_STRINGPARAM( "InteropGrabBag" ), HANDLE_INTEROP_GRAB_BAG , SEQTYPE(::getCppuType((uno::Sequence< beans::PropertyValue >*)0)), PROPERTY_NONE, 0 },
{ NULL, 0, 0, NULL, 0, 0 }
};
PropertySetInfo *pInfo = new PropertySetInfo ( aModelPropertyInfoMap );
@ -707,6 +717,9 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
pDocSh->SetLoadReadonly( bReadonly );
break;
}
case HANDLE_INTEROP_GRAB_BAG:
setGrabBagItem(*pValues);
break;
}
}
@ -933,6 +946,9 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu
*pValue <<= static_cast<sal_Int32>( pDocSh->pTree->GetFormulaBaseline() );
}
}
case HANDLE_INTEROP_GRAB_BAG:
getGrabBagItem(*pValue);
break;
break;
}
}

View File

@ -236,6 +236,7 @@
#define WID_DOC_RUNTIME_UID 1015
#define WID_DOC_LOCK_UPDATES 1016
#define WID_DOC_HAS_VALID_SIGNATURES 1017
#define WID_DOC_INTEROP_GRAB_BAG 1018
#define WID_DOC_BUILDID 1024
#define WID_DOC_ISTEMPLATEID 1025
#define WID_DOC_DEFAULT_PAGE_MODE 1069

View File

@ -838,6 +838,8 @@ enum SwPropNameIds
/* 0772 */ UNO_NAME_CHAR_SHADOW_FORMAT,
/* 0773 */ UNO_NAME_SHADOW_TRANSPARENCE,
/* 0774 */ UNO_NAME_DOC_INTEROP_GRAB_BAG,
SW_PROPNAME_END
// new items in this array must match SwPropNameTab aPropNameTab

View File

@ -1606,6 +1606,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{ SW_PROP_NMID(UNO_NAME_LOCK_UPDATES), WID_DOC_LOCK_UPDATES, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0},
{ SW_PROP_NMID(UNO_NAME_HAS_VALID_SIGNATURES), WID_DOC_HAS_VALID_SIGNATURES, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::READONLY, 0},
{ SW_PROP_NMID(UNO_NAME_BUILDID), WID_DOC_BUILDID, CPPU_E2T(CPPUTYPE_OUSTRING), 0, 0},
{ SW_PROP_NMID(UNO_NAME_DOC_INTEROP_GRAB_BAG), WID_DOC_INTEROP_GRAB_BAG, CPPU_E2T(CPPUTYPE_PROPERTYVALUE), PROPERTY_NONE, 0 }, \
{ SW_PROP_NMID(UNO_NAME_DEFAULT_PAGE_MODE), WID_DOC_DEFAULT_PAGE_MODE, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0},
{0,0,0,0,0,0}
};

View File

@ -801,8 +801,9 @@ const SwPropNameTab aPropNameTab = {
/* 0769 UNO_NAME_CHAR_RIGHT_BORDER_DISTANCE */ {MAP_CHAR_LEN("CharRightBorderDistance")},
/* 0770 UNO_NAME_CHAR_TOP_BORDER_DISTANCE */ {MAP_CHAR_LEN("CharTopBorderDistance")},
/* 0771 UNO_NAME_CHAR_BOTTOM_BORDER_DISTANCE */ {MAP_CHAR_LEN("CharBottomBorderDistance")},
/* 0771 UNO_NAME_CHAR_SHADOW_FORMAT */ {MAP_CHAR_LEN("CharShadowFormat")},
/* 0772 UNO_NAME_SHADOW_TRANSPARENCE */ {MAP_CHAR_LEN("ShadowTransparence")},
/* 0772 UNO_NAME_CHAR_SHADOW_FORMAT */ {MAP_CHAR_LEN("CharShadowFormat")},
/* 0773 UNO_NAME_SHADOW_TRANSPARENCE */ {MAP_CHAR_LEN("ShadowTransparence")},
/* 0774 UNO_NAME_DOC_INTEROP_GRAB_BAG */ {MAP_CHAR_LEN("InteropGrabBag")},
// new items in this array must match enum SwPropNameIds

View File

@ -1998,6 +1998,9 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName,
pDocShell->GetDoc()->SetDefaultPageMode( bDefaultPageMode );
}
break;
case WID_DOC_INTEROP_GRAB_BAG:
setGrabBagItem(aValue);
break;
default:
{
@ -2152,6 +2155,9 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
case WID_DOC_HAS_VALID_SIGNATURES:
aAny <<= hasValidSignatures();
break;
case WID_DOC_INTEROP_GRAB_BAG:
getGrabBagItem(aAny);
break;
default:
{