[PATCH] purposed patch for bug 39168

Gabor Jenei jengab at elte.hu
Mon Aug 8 02:30:51 PDT 2011


---
 desktop/source/deployment/gui/dp_gui_dialog.src |    2 +-
 sfx2/source/dialog/filedlghelper.cxx            |   11 +--
 sfx2/source/doc/guisaveas.cxx                   |  102 +++++++++++++++++++---
 3 files changed, 94 insertions(+), 21 deletions(-)

diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src
index 12b6acb..28962fc 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog.src
+++ b/desktop/source/deployment/gui/dp_gui_dialog.src
@@ -1,4 +1,4 @@
-/*************************************************************************
+/*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 996e181..32cf0a1 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1655,12 +1655,12 @@ OUString FileDialogHelper_Impl::getPath() const
 {
     OUString aPath;
 
-    if ( mxFileDlg.is() )
+    if ( mxFileDlg.is() ){
         aPath = mxFileDlg->getDisplayDirectory();
-
-    if ( !aPath.getLength() )
+    }
+    if ( !aPath.getLength() ){
         aPath = maPath;
-
+    }
     return aPath;
 }
 
@@ -2496,9 +2496,8 @@ void FileDialogHelper::SetTitle( const String& rNewTitle )
 String FileDialogHelper::GetPath() const
 {
     OUString aPath;
-
     if ( mpImp->mlLastURLs.size() > 0)
-        return mpImp->mlLastURLs[0];
+        aPath=mpImp->mlLastURLs[0];
 
     if ( mpImp->mxFileDlg.is() )
     {
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 783d623..f09c2a4 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -77,6 +77,7 @@
 #include <vcl/msgbox.hxx>
 #include <vcl/window.hxx>
 #include <toolkit/awt/vclxwindow.hxx>
+#include <svtools/FilterConfigItem.hxx>
 
 #include <sfx2/sfxsids.hrc>
 #include <doc.hrc>
@@ -95,18 +96,18 @@
 #define DOCPROPSNUM 17
 
 // flags that specify requested operation
-#define EXPORT_REQUESTED 			1
-#define PDFEXPORT_REQUESTED			2
-#define PDFDIRECTEXPORT_REQUESTED	4
-#define WIDEEXPORT_REQUESTED		8
-#define SAVE_REQUESTED				16
-#define SAVEAS_REQUESTED			32
+#define EXPORT_REQUESTED                        1
+#define PDFEXPORT_REQUESTED                     2
+#define PDFDIRECTEXPORT_REQUESTED       4
+#define WIDEEXPORT_REQUESTED            8
+#define SAVE_REQUESTED                          16
+#define SAVEAS_REQUESTED                        32
 
 // possible statuses of save operation
-#define STATUS_NO_ACTION			0
-#define STATUS_SAVE					1
-#define STATUS_SAVEAS				2
-#define STATUS_SAVEAS_STANDARDNAME	3
+#define STATUS_NO_ACTION                        0
+#define STATUS_SAVE                                     1
+#define STATUS_SAVEAS                           2
+#define STATUS_SAVEAS_STANDARDNAME      3
 
 const ::rtl::OUString aFilterNameString(RTL_CONSTASCII_USTRINGPARAM("FilterName"));
 const ::rtl::OUString aFilterOptionsString(RTL_CONSTASCII_USTRINGPARAM("FilterOptions"));
@@ -1013,7 +1014,37 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
     GetMediaDescr() << aPropsFromDialog;
 
     // get the path from the dialog
-    INetURLObject aURL( pFileDlg->GetPath() );
+    String aPath(pFileDlg->GetPath());
+    //we need to convert extension in case of PDFExport and IsAddStream is true
+    FilterConfigItem aCfgItem(String(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Filter/PDF/Export/")));
+    sal_Bool bAddStream=aCfgItem.ReadBool(String(RTL_CONSTASCII_USTRINGPARAM("IsAddStream")),sal_False);
+    if(bAddStream==sal_True){
+        //get the begining of extension: len-3
+        xub_StrLen nIndex=aPath.Len()-3;
+        //modify extension to od*.pdf according to the filter type
+        if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("writer_pdf_Export"))){
+            aPath.Replace(nIndex,3,String::CreateFromAscii("odt"));
+            aPath+=String::CreateFromAscii(".pdf");
+        }
+        if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("calc_pdf_Export"))){
+            aPath.Replace(nIndex,3,String::CreateFromAscii("ods"));
+            aPath+=String::CreateFromAscii(".pdf");
+        }
+        if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("impress_pdf_Export"))){
+            aPath.Replace(nIndex,3,String::CreateFromAscii("odp"));
+            aPath+=String::CreateFromAscii(".pdf");
+        }
+        if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("draw_pdf_Export"))){
+            aPath.Replace(nIndex,3,String::CreateFromAscii("odg"));
+            aPath+=String::CreateFromAscii(".pdf");
+        }
+        if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("math_pdf_Export"))){
+            aPath.Replace(nIndex,3,String::CreateFromAscii("odf"));
+            aPath+=String::CreateFromAscii(".pdf");
+        }
+    }
+
+    INetURLObject aURL( aPath );
     // the path should be provided outside since it might be used for further calls to the dialog
     aSuggestedName = aURL.GetName( INetURLObject::DECODE_WITH_CHARSET );
        aSuggestedDir = pFileDlg->GetDisplayDirectory();
@@ -1492,7 +1523,7 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >&
         if ( aStdDirIter != aModelData.GetMediaDescr().end() )
             aStdDirIter->second >>= sStandardDir;
 
-        ::com::sun::star::uno::Sequence< ::rtl::OUString >	aBlackList;
+        ::com::sun::star::uno::Sequence< ::rtl::OUString >      aBlackList;
 
         ::comphelper::SequenceAsHashMap::const_iterator aBlackListIter =
             aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BlackList")) );
@@ -1580,11 +1611,54 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >&
     if( !( nStoreMode & PDFEXPORT_REQUESTED ) && !bFilterFlagsSet
         && ( ( nStoreMode & EXPORT_REQUESTED ) || bUseFilterOptions ) )
     {
+        FilterConfigItem aCfgItem(String(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Filter/PDF/Export/")));
         // execute filter options dialog
-        if ( aModelData.ExecuteFilterDialog_Impl( aFilterName ) )
+
+        sal_Bool bOldAddStream=aCfgItem.ReadBool(String(RTL_CONSTASCII_USTRINGPARAM("IsAddStream")),sal_False);
+        if ( aModelData.ExecuteFilterDialog_Impl( aFilterName ) ){
             bDialogUsed = sal_True;
+        }
+        //has bAddStream just changed?
+        FilterConfigItem aCfgItem2(String(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Filter/PDF/Export/")));
+        sal_Bool bAddStream=aCfgItem2.ReadBool(String(RTL_CONSTASCII_USTRINGPARAM("IsAddStream")),sal_False);
+        if(bAddStream==sal_True && bOldAddStream!=sal_True){ //AddStream has just been set
+            ::rtl::OUString aPath(aURL.GetURLPath());
+            //the index of .pdf extension
+            sal_Int32 nIndex=aPath.getLength()-3;
+            ::rtl::OUString aNewPath;
+            if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("writer_pdf_Export"))){
+                aNewPath=aPath.replaceAt(nIndex,3,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("odt")));
+                aNewPath+=::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".pdf"));
+            }
+            if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("calc_pdf_Export"))){
+                aNewPath=aPath.replaceAt(nIndex,3,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ods")));
+                aNewPath+=::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".pdf"));
+            }
+            if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("impress_pdf_Export"))){
+                aNewPath=aPath.replaceAt(nIndex,3,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("odp")));
+                aNewPath+=::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".pdf"));
+            }
+            if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("draw_pdf_Export"))){
+                aNewPath=aPath.replaceAt(nIndex,3,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("odg")));
+                aNewPath+=::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".pdf"));
+            }
+            if(aFilterName==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("math_pdf_Export"))){
+                aNewPath=aPath.replaceAt(nIndex,3,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("odf")));
+                aNewPath+=::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".pdf"));
+            }
+            //is it an existing path?
+            bool bExists=false;
+            aURL.SetURLPath(aNewPath);
+        }
+        if(bAddStream==sal_False && bOldAddStream==sal_True){ //need to remove the added .od*
+            ::rtl::OUString aPath(aURL.GetURLPath());
+            //the index of the begining of .od*.pdf 7 chars were inserted
+            sal_Int32 nIndex=aPath.getLength()-7;
+            ::rtl::OUString aNewPath=aPath.copy(0,nIndex);
+            aNewPath+=::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pdf"));
+            aURL.SetURLPath(aNewPath);
+        }
     }
-
     // so the arguments will not change any more and can be stored to the main location
     aArgsSequence = aModelData.GetMediaDescr().getAsConstPropertyValueList();
 
-- 
1.7.2.5


--------------040902070708040104000009--


More information about the LibreOffice mailing list