Author: orw
Date: Wed Sep 11 15:33:53 2013
New Revision: 1521908

URL: http://svn.apache.org/r1521908
Log:
123144: ODF import/export of current database settings:
        - assure certain order on export for former versions
        - assure certain order on setting these properties on import to be 
independent of order in ODF

        cherry-picked from trunk


Modified:
    openoffice/branches/AOO401/   (props changed)
    openoffice/branches/AOO401/main/   (props changed)
    openoffice/branches/AOO401/main/sw/source/filter/xml/xmlexp.cxx
    openoffice/branches/AOO401/main/sw/source/filter/xml/xmlimp.cxx

Propchange: openoffice/branches/AOO401/
------------------------------------------------------------------------------
  Merged /openoffice/trunk:r1521899

Propchange: openoffice/branches/AOO401/main/
------------------------------------------------------------------------------
  Merged /openoffice/trunk/main:r1521899

Modified: openoffice/branches/AOO401/main/sw/source/filter/xml/xmlexp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sw/source/filter/xml/xmlexp.cxx?rev=1521908&r1=1521907&r2=1521908&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sw/source/filter/xml/xmlexp.cxx (original)
+++ openoffice/branches/AOO401/main/sw/source/filter/xml/xmlexp.cxx Wed Sep 11 
15:33:53 2013
@@ -64,10 +64,7 @@
 #include <vcl/svapp.hxx>
 #include <vos/mutex.hxx>
 
-// --> OD 2007-03-30 #i73788#
 #include <pausethreadstarting.hxx>
-// <--
-
 
 using ::rtl::OUString;
 using namespace ::com::sun::star;
@@ -538,13 +535,54 @@ void SwXMLExport::GetViewSettings(Sequen
 
 void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps)
 {
-       Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
-       if( xFac.is() )
-       {
-               Reference< XPropertySet > xProps( xFac->createInstance( 
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), 
UNO_QUERY );
-               if( xProps.is() )
-                       SvXMLUnitConverter::convertPropertySet( rProps, xProps 
);
-       }
+    Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
+    if( xFac.is() )
+    {
+        Reference< XPropertySet > xProps( xFac->createInstance( OUString( 
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY 
);
+        if( xProps.is() )
+        {
+            // property CurrentDatabaseDataSource needs to be exported before 
CurrentDatabaseCommand and CurrentDatabaseCommandType
+            // in order to assure that AOO/OOo versions (before AOO 4.0.1) are 
able to apply the current database settings correct
+            // Thus, put CurrentDatabaseDataSource as the first one into the 
Sequence
+//            SvXMLUnitConverter::convertPropertySet( rProps, xProps );
+            uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = 
xProps->getPropertySetInfo();
+            if (xPropertySetInfo.is())
+            {
+                uno::Sequence< beans::Property > aProps = 
xPropertySetInfo->getProperties();
+                const sal_Int32 nCount(aProps.getLength());
+                if (nCount)
+                {
+                    rProps.realloc(nCount);
+                    beans::PropertyValue* pProps = rProps.getArray();
+
+                    static ::rtl::OUString csCurrentDatabaseSource = 
::rtl::OUString::createFromAscii("CurrentDatabaseDataSource");
+                    const sal_Bool bHasCurrentDatabaseSource = 
xPropertySetInfo->hasPropertyByName( csCurrentDatabaseSource );
+                    if ( bHasCurrentDatabaseSource )
+                    {
+                        beans::Property aProp = 
xPropertySetInfo->getPropertyByName( csCurrentDatabaseSource );
+                        pProps->Name = aProp.Name;
+                        pProps->Value = xProps->getPropertyValue(aProp.Name);
+                        ++pProps;
+                    }
+
+                    for (sal_Int32 i = 0; i < nCount; i++ )
+                    {
+                        if ( bHasCurrentDatabaseSource
+                             && aProps[i].Name.compareTo( 
csCurrentDatabaseSource ) == 0 )
+                        {
+                            // nothing to do - already added as first item - 
see above
+                        }
+                        else
+                        {
+                            pProps->Name = aProps[i].Name;
+                            pProps->Value = 
xProps->getPropertyValue(aProps[i].Name);
+                            ++pProps;
+                        }
+                    }
+                }
+            }
+        }
+    }
 }
 
 sal_Int32 SwXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup 
>& _out_rSettings )

Modified: openoffice/branches/AOO401/main/sw/source/filter/xml/xmlimp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sw/source/filter/xml/xmlimp.cxx?rev=1521908&r1=1521907&r2=1521908&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sw/source/filter/xml/xmlimp.cxx (original)
+++ openoffice/branches/AOO401/main/sw/source/filter/xml/xmlimp.cxx Wed Sep 11 
15:33:53 2013
@@ -1164,21 +1164,20 @@ void SwXMLImport::SetViewSettings(const 
 void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & 
aConfigProps)
 {
     // this method will modify the document directly -> lock SolarMutex
-       vos::OGuard aGuard(Application::GetSolarMutex());
+    vos::OGuard aGuard(Application::GetSolarMutex());
 
-       Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
-       if( !xFac.is() )
-               return;
+    Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
+    if( !xFac.is() )
+        return;
 
-       Reference< XPropertySet > xProps( xFac->createInstance( OUString( 
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY 
);
-       if( !xProps.is() )
-               return;
+    Reference< XPropertySet > xProps( xFac->createInstance( OUString( 
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY 
);
+    if( !xProps.is() )
+        return;
 
-       Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
-       if( !xInfo.is() )
-               return;
+    Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
+    if( !xInfo.is() )
+        return;
 
-    // #111955#
     hash_set< String, StringHashRef, StringEqRef > aSet;
     aSet.insert(String("ForbiddenCharacters", RTL_TEXTENCODING_ASCII_US));
     aSet.insert(String("IsKernAsianPunctuation", RTL_TEXTENCODING_ASCII_US));
@@ -1204,16 +1203,14 @@ void SwXMLImport::SetConfigurationSettin
     aSet.insert(String("PrintSingleJobs", RTL_TEXTENCODING_ASCII_US));
     aSet.insert(String("UpdateFromTemplate", RTL_TEXTENCODING_ASCII_US));
     aSet.insert(String("PrinterIndependentLayout", RTL_TEXTENCODING_ASCII_US));
-    // --> FME 2005-12-13 #b6354161#
     aSet.insert(String("PrintEmptyPages", RTL_TEXTENCODING_ASCII_US));
-    // <--
 
-       sal_Int32 nCount = aConfigProps.getLength();
-       const PropertyValue* pValues = aConfigProps.getConstArray();
+    sal_Int32 nCount = aConfigProps.getLength();
+    const PropertyValue* pValues = aConfigProps.getConstArray();
 
-       SvtSaveOptions aSaveOpt;
-       sal_Bool bIsUserSetting = aSaveOpt.IsLoadUserSettings(),
-                bSet = bIsUserSetting;
+    SvtSaveOptions aSaveOpt;
+    sal_Bool bIsUserSetting = aSaveOpt.IsLoadUserSettings();
+    sal_Bool bSet = bIsUserSetting;
 
     // for some properties we don't want to use the application
     // default if they're missing. So we watch for them in the loop
@@ -1236,36 +1233,59 @@ void SwXMLImport::SetConfigurationSettin
     bool bUnixForceZeroExtLeading = false;
     bool bUseOldPrinterMetrics = false;
 
-       OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM( 
"RedlineProtectionKey" ) );
+    static const OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM( 
"RedlineProtectionKey" ) );
+
+    // Set current database properties in certain order
+    // Thus, keep these properties during loop and set them afterwards in 
valid order
+    static const OUString sCurrentDatabaseDataSource( 
RTL_CONSTASCII_USTRINGPARAM( "CurrentDatabaseDataSource" ) );
+    uno::Any aCurrentDatabaseDataSource;
+    static const OUString sCurrentDatabaseCommand( 
RTL_CONSTASCII_USTRINGPARAM( "CurrentDatabaseCommand" ) );
+    uno::Any aCurrentDatabaseCommand;
+    static const OUString sCurrentDatabaseCommandType( 
RTL_CONSTASCII_USTRINGPARAM( "CurrentDatabaseCommandType" ) );
+    uno::Any aCurrentDatabaseCommandType;
 
     while( nCount-- )
-       {
-               if( !bIsUserSetting )
-               {
-                       // test over the hash value if the entry is in the 
table.
+    {
+        if( !bIsUserSetting )
+        {
+            // test over the hash value if the entry is in the table.
             String aStr(pValues->Name);
 
             bSet = aSet.find(aStr) == aSet.end();
-               }
+        }
 
-               if( bSet )
-               {
-                       try
-                       {
-                               if( xInfo->hasPropertyByName( pValues->Name ) )
-                               {
-                                       if( pValues->Name.equals( 
sRedlineProtectionKey ) )
-                                       {
-                                               Sequence<sal_Int8> aKey;
-                                               pValues->Value >>= aKey;
-                                               
GetTextImport()->SetChangesProtectionKey( aKey );
-                                       }
-                                       else
-                                       {
-                                               xProps->setPropertyValue( 
pValues->Name,
-                                                                               
                  pValues->Value );
-                                       }
-                               }
+        if( bSet )
+        {
+            try
+            {
+                if( xInfo->hasPropertyByName( pValues->Name ) )
+                {
+                    if( pValues->Name.equals( sRedlineProtectionKey ) )
+                    {
+                        Sequence<sal_Int8> aKey;
+                        pValues->Value >>= aKey;
+                        GetTextImport()->SetChangesProtectionKey( aKey );
+                    }
+                    else if ( !aCurrentDatabaseDataSource.hasValue()
+                              && pValues->Name.equals( 
sCurrentDatabaseDataSource ) )
+                    {
+                        aCurrentDatabaseDataSource = pValues->Value;
+                    }
+                    else if ( !aCurrentDatabaseCommand.hasValue()
+                              && pValues->Name.equals( sCurrentDatabaseCommand 
) )
+                    {
+                        aCurrentDatabaseCommand = pValues->Value;
+                    }
+                    else if ( !aCurrentDatabaseCommandType.hasValue()
+                              && pValues->Name.equals( 
sCurrentDatabaseCommandType ) )
+                    {
+                        aCurrentDatabaseCommandType = pValues->Value;
+                    }
+                    else
+                    {
+                        xProps->setPropertyValue( pValues->Name, 
pValues->Value );
+                    }
+                }
 
                 // did we find any of the non-default cases?
                 if( 
pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("PrinterIndependentLayout"))
 )
@@ -1303,19 +1323,34 @@ void SwXMLImport::SetConfigurationSettin
                 else if( 
pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseOldPrinterMetrics")) )
                     bUseOldPrinterMetrics = true;
             }
-                       catch( Exception& )
-                       {
-                               DBG_ERROR( 
"SwXMLImport::SetConfigurationSettings: Exception!" );
-                       }
-               }
-               pValues++;
-       }
+            catch( Exception& )
+            {
+                DBG_ERROR( "SwXMLImport::SetConfigurationSettings: Exception!" 
);
+            }
+        }
+        pValues++;
+    }
+
+    // apply current database properties
+    {
+        if ( aCurrentDatabaseDataSource.hasValue() )
+        {
+            xProps->setPropertyValue( sCurrentDatabaseDataSource, 
aCurrentDatabaseDataSource );
+        }
+        if ( aCurrentDatabaseCommand.hasValue() )
+        {
+            xProps->setPropertyValue( sCurrentDatabaseCommand, 
aCurrentDatabaseCommand );
+        }
+        if ( aCurrentDatabaseCommandType.hasValue() )
+        {
+            xProps->setPropertyValue( sCurrentDatabaseCommandType, 
aCurrentDatabaseCommandType );
+        }
+    }
 
     // finally, treat the non-default cases
-    // --> OD 2006-04-18 #b6402800#
+
     // introduce boolean, that indicates a document, written by version prior 
SO8.
     const bool bDocumentPriorSO8 = !bConsiderWrapOnObjPos;
-    // <--
 
     if( ! bPrinterIndependentLayout )
     {
@@ -1345,14 +1380,12 @@ void SwXMLImport::SetConfigurationSettin
             OUString( 
RTL_CONSTASCII_USTRINGPARAM("UseFormerObjectPositioning")), makeAny( true ) );
     }
 
-    if( !bUseOldNumbering ) // #111955#
+    if( !bUseOldNumbering )
     {
         Any aAny;
         sal_Bool bOldNum = true;
         aAny.setValue(&bOldNum, ::getBooleanCppuType());
-        xProps->setPropertyValue
-            (OUString( RTL_CONSTASCII_USTRINGPARAM("UseOldNumbering")),
-                       aAny );
+        xProps->setPropertyValue( OUString( 
RTL_CONSTASCII_USTRINGPARAM("UseOldNumbering")), aAny );
     }
 
     if( !bOutlineLevelYieldsOutlineRule )
@@ -1418,8 +1451,7 @@ void SwXMLImport::SetConfigurationSettin
 
     if ( !bLoadReadonly )
     {
-        xProps->setPropertyValue(
-                       OUString( RTL_CONSTASCII_USTRINGPARAM("LoadReadonly") 
), makeAny( false ) );
+        xProps->setPropertyValue( OUString( 
RTL_CONSTASCII_USTRINGPARAM("LoadReadonly") ), makeAny( false ) );
     }
 
     // This flag has to be set for all documents < SO8
@@ -1450,27 +1482,27 @@ void SwXMLImport::SetConfigurationSettin
     // <--
 
     Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
-       Reference < XText > xText = xTextDoc->getText();
-       Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
-       ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" );
-       if( xTextTunnel.is() )
-       {
-               SwXText *pText = reinterpret_cast< SwXText *>(
-                               sal::static_int_cast< sal_IntPtr >( 
xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
-               ASSERT( pText, "SwXText missing" );
-               if( pText )
-               {
-                       SwDoc *pDoc = pText->GetDoc();
-                       if( pDoc )
-                       {
+    Reference < XText > xText = xTextDoc->getText();
+    Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
+    ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" );
+    if( xTextTunnel.is() )
+    {
+        SwXText *pText = reinterpret_cast< SwXText *>(
+            sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( 
SwXText::getUnoTunnelId() )));
+        ASSERT( pText, "SwXText missing" );
+        if( pText )
+        {
+            SwDoc *pDoc = pText->GetDoc();
+            if( pDoc )
+            {
                 SfxPrinter *pPrinter = pDoc->getPrinter( false );
-                               if( pPrinter )
+                if( pPrinter )
                 {
-                               // If the printer is known, then the OLE 
objects will
-                               // already have correct sizes, and we don't 
have to call
-                               // PrtOLENotify again. Otherwise we have to 
call it.
-                               // The flag might be set from setting the 
printer, so it
-                                   // it is required to clear it.
+                    // If the printer is known, then the OLE objects will
+                    // already have correct sizes, and we don't have to call
+                    // PrtOLENotify again. Otherwise we have to call it.
+                    // The flag might be set from setting the printer, so it
+                    // it is required to clear it.
                     pDoc->SetOLEPrtNotifyPending( !pPrinter->IsKnown() );
 
                     // FME 2007-05-14 #147385# old printer metrics 
compatibility
@@ -1481,9 +1513,9 @@ void SwXMLImport::SetConfigurationSettin
                         pDoc->GetDocShell()->UpdateFontList();
                     }
                 }
-                       }
-               }
-       }
+            }
+        }
+    }
 }
 
 


Reply via email to