incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mba...@apache.org
Subject svn commit: r1172360 - /incubator/ooo/trunk/main/sfx2/source/appl/appuno.cxx
Date Sun, 18 Sep 2011 21:17:26 GMT
Author: mbauer
Date: Sun Sep 18 21:17:26 2011
New Revision: 1172360

URL: http://svn.apache.org/viewvc?rev=1172360&view=rev
Log:
cws mba34issues01: #i117024#: rework parameter conversion for load/save slots

Modified:
    incubator/ooo/trunk/main/sfx2/source/appl/appuno.cxx

Modified: incubator/ooo/trunk/main/sfx2/source/appl/appuno.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sfx2/source/appl/appuno.cxx?rev=1172360&r1=1172359&r2=1172360&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sfx2/source/appl/appuno.cxx (original)
+++ incubator/ooo/trunk/main/sfx2/source/appl/appuno.cxx Sun Sep 18 21:17:26 2011
@@ -138,6 +138,35 @@ using namespace ::com::sun::star::io;
 #define FRAMELOADER_SERVICENAME         "com.sun.star.frame.FrameLoader"
 #define PROTOCOLHANDLER_SERVICENAME     "com.sun.star.frame.ProtocolHandler"
 
+#include <sfxslots.hxx>
+
+// needs to be converted to a better data structure
+SfxFormalArgument aArgs[] = 
+{
+    SFX_ARGUMENT(SID_DEFAULTFILENAME,"SuggestedSaveAsName",SfxStringItem),
+    SFX_ARGUMENT(SID_DEFAULTFILEPATH,"SuggestedSaveAsDir",SfxStringItem),
+    SFX_ARGUMENT(SID_DOCINFO_AUTHOR,"VersionAuthor",SfxStringItem),
+    SFX_ARGUMENT(SID_DOCINFO_COMMENTS,"VersionComment",SfxStringItem),
+    SFX_ARGUMENT(SID_FILE_FILTEROPTIONS,"FilterOptions",SfxStringItem),
+    SFX_ARGUMENT(SID_FILTER_NAME,"FilterName",SfxStringItem),
+//    SFX_ARGUMENT(SID_FILE_NAME,"FileName",SfxStringItem),
+    SFX_ARGUMENT(SID_FILE_NAME,"URL",SfxStringItem),
+    SFX_ARGUMENT(SID_OPTIONS,"OpenFlags",SfxStringItem),
+    SFX_ARGUMENT(SID_OVERWRITE,"Overwrite",SfxBoolItem),
+    SFX_ARGUMENT(SID_PASSWORD,"Password",SfxStringItem),
+    SFX_ARGUMENT(SID_PASSWORDINTERACTION,"PasswordInteraction",SfxBoolItem),
+    SFX_ARGUMENT(SID_REFERER,"Referer",SfxStringItem),
+    SFX_ARGUMENT(SID_SAVETO,"SaveTo",SfxBoolItem),
+    SFX_ARGUMENT(SID_TEMPLATE_NAME,"TemplateName",SfxStringItem),
+    SFX_ARGUMENT(SID_TEMPLATE_REGIONNAME,"TemplateRegion",SfxStringItem),
+//    SFX_ARGUMENT(SID_TEMPLATE_REGIONNAME,"Region",SfxStringItem),
+//    SFX_ARGUMENT(SID_TEMPLATE_NAME,"Name",SfxStringItem),
+    SFX_ARGUMENT(SID_UNPACK,"Unpacked",SfxBoolItem),
+    SFX_ARGUMENT(SID_VERSION,"Version",SfxInt16Item),
+};
+
+static sal_uInt16 nMediaArgsCount = sizeof(aArgs) / sizeof (SfxFormalArgument);
+
 static char const sTemplateRegionName[] = "TemplateRegionName";
 static char const sTemplateName[] = "TemplateName";
 static char const sAsTemplate[] = "AsTemplate";
@@ -189,7 +218,13 @@ static char const sModifyPasswordInfo[] 
 static char const sSuggestedSaveAsDir[] = "SuggestedSaveAsDir";
 static char const sSuggestedSaveAsName[] = "SuggestedSaveAsName";
 static char const sEncryptionData[] = "EncryptionData";
+static char const sFailOnWarning[] = "FailOnWarning";
 
+bool isMediaDescriptor( sal_uInt16 nSlotId )
+{
+	return ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC
|| nSlotId == SID_SAVEDOC ||
+             nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF
);
+}
 
 void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>&
rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot )
 {
@@ -209,7 +244,7 @@ void TransformParameters( sal_uInt16 nSl
         return;
 
     const ::com::sun::star::beans::PropertyValue* pPropsVal = rArgs.getConstArray();
-    if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
+	if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
     {
         // slot is a property
         const SfxType* pType = pSlot->GetType();
@@ -328,9 +363,11 @@ void TransformParameters( sal_uInt16 nSl
         sal_Int32 nFoundArgs = 0;
 #endif
         // slot is a method
-        for ( sal_uInt16 nArgs=0; nArgs<pSlot->nArgDefCount; nArgs++ )
+		bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
+		sal_uInt16 nMaxArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
+        for ( sal_uInt16 nArgs=0; nArgs<nMaxArgs; nArgs++ )
         {
-            const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArgs );
+			const SfxFormalArgument &rArg = bIsMediaDescriptor ? aArgs[nArgs] : pSlot->GetFormalArgument(
nArgs );
             SfxPoolItem* pItem = rArg.CreateItem();
             if ( !pItem )
             {
@@ -480,8 +517,7 @@ void TransformParameters( sal_uInt16 nSl
                 }
             }
         }
-        else if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC
|| nSlotId == SID_SAVEDOC ||
-                  nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF
)
+        else if ( bIsMediaDescriptor )
         {
             for ( sal_uInt16 n=0; n<nCount; n++ )
             {
@@ -503,17 +539,17 @@ void TransformParameters( sal_uInt16 nSl
                 else if ( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sStatusInd)) )
                 {
                     Reference< ::com::sun::star::task::XStatusIndicator > xVal;
-                    sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
+                    sal_Bool bOK = (rProp.Value >>= xVal);
                     DBG_ASSERT( bOK, "invalid type for StatusIndicator" );
-                    if (bOK)
+                    if (bOK && xVal.is())
                         rSet.Put( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, rProp.Value
) );
                 }
                 else if ( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sInteractionHdl))
)
                 {
                     Reference< ::com::sun::star::task::XInteractionHandler > xVal;
-                    sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
+                    sal_Bool bOK = (rProp.Value >>= xVal);
                     DBG_ASSERT( bOK, "invalid type for InteractionHandler" );
-                    if (bOK)
+                    if (bOK && xVal.is())
                         rSet.Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, rProp.Value ) );
                 }
                 else if ( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sViewData)) )
@@ -584,6 +620,14 @@ void TransformParameters( sal_uInt16 nSl
                     if (bOK)
                         rSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, bVal ) );
                 }
+                else if ( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sFailOnWarning))
)
+                {
+                    sal_Bool bVal = sal_False;
+                    sal_Bool bOK = (rProp.Value >>= bVal);
+                    DBG_ASSERT( bOK, "invalid type for FailOnWarning" );
+                    if (bOK)
+                        rSet.Put( SfxBoolItem( SID_FAIL_ON_WARNING, bVal ) );
+                }
                 else if ( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sViewId)) )
                 {
                     sal_Int16 nVal = -1;
@@ -964,11 +1008,13 @@ void TransformItems( sal_uInt16 nSlotId,
     else
     {
         // slot is a method
-        sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
+		bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
+		sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->GetFormalArgumentCount();
         for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
         {
             // check every formal argument of the method
             const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
+
             sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
             if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
             {
@@ -987,8 +1033,7 @@ void TransformItems( sal_uInt16 nSlotId,
         }
 
         // special treatment for slots that are *not* meant to be recorded as slots (except
SaveAs/To)
-        if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC
||  nSlotId == SID_SAVEDOC ||
-             nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF
)
+        if ( bIsMediaDescriptor )
         {
             sal_Int32 nAdditional=0;
             if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL ) == SFX_ITEM_SET )
@@ -1017,6 +1062,8 @@ void TransformItems( sal_uInt16 nSlotId,
                 nAdditional++;
             if ( rSet.GetItemState( SID_OPEN_NEW_VIEW ) == SFX_ITEM_SET )
                 nAdditional++;
+            if ( rSet.GetItemState( SID_FAIL_ON_WARNING ) == SFX_ITEM_SET )
+                nAdditional++;
             if ( rSet.GetItemState( SID_VIEW_ID ) == SFX_ITEM_SET )
                 nAdditional++;
             if ( rSet.GetItemState( SID_VIEW_DATA ) == SFX_ITEM_SET )
@@ -1116,11 +1163,12 @@ void TransformItems( sal_uInt16 nSlotId,
                 if ( !pSlot->IsMode(SFX_SLOT_METHOD) && nId == rSet.GetPool()->GetWhich(
pSlot->GetSlotId() ) )
                     continue;
 
-                sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
+				bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
+				sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
                 sal_uInt16 nArg;
                 for ( nArg=0; nArg<nFormalArgs; ++nArg )
                 {
-                    const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg
);
+					const SfxFormalArgument &rArg = bIsMediaDescriptor ? aArgs[nArg] : pSlot->GetFormalArgument(
nArg );
                     sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
                     if ( nId == nWhich )
                         break;
@@ -1129,8 +1177,7 @@ void TransformItems( sal_uInt16 nSlotId,
                 if ( nArg<nFormalArgs )
                     continue;
 
-                if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC
||  nSlotId == SID_SAVEDOC ||
-                     nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId ==
SID_DIRECTEXPORTDOCASPDF )
+                if ( bIsMediaDescriptor )
                 {
                     if ( nId == SID_DOCFRAME )
                         continue;
@@ -1440,6 +1487,11 @@ void TransformItems( sal_uInt16 nSlotId,
                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sOpenNewView));
                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue()
);
             }
+            if ( rSet.GetItemState( SID_FAIL_ON_WARNING, sal_False, &pItem ) == SFX_ITEM_SET
)
+            {
+                pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sFailOnWarning));
+                pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue()
);
+            }
             if ( rSet.GetItemState( SID_VIEW_ID, sal_False, &pItem ) == SFX_ITEM_SET
)
             {
                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sViewId));



Mime
View raw message