summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authortobias <tobias.schulz@hotmail.com>2021-06-03 16:37:54 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-06-04 23:45:05 +0200
commitcb490979ac238011efa27e0fb18fe62c13329d1f (patch)
tree5c2d6d099cd2a6fa6b5a2c2cb2bcabeca1241860 /sw/source
parent5bb06ea6931c0c72df6b0f164bac1c8d00c51bb6 (diff)
tdf#120574 Store Ascii Options for Later Saving
store auto detected/configured ascii options in medium. use stored ascii settings for saving and text encoding settings dialog. Change-Id: I88e2d54923bfcf5d7c460ef3b89c36fc002c5097 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116678 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ascii/parasc.cxx12
-rw-r--r--sw/source/filter/ascii/wrtasc.cxx19
-rw-r--r--sw/source/filter/ascii/wrtasc.hxx1
-rw-r--r--sw/source/ui/dialog/ascfldlg.cxx16
4 files changed, 47 insertions, 1 deletions
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
index 41fc9457a325..8cdfa91ba6b3 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -21,7 +21,9 @@
#include <tools/stream.hxx>
#include <hintids.hxx>
+#include <sfx2/docfile.hxx>
#include <sfx2/printer.hxx>
+#include <sfx2/sfxsids.hrc>
#include <editeng/fontitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/formatbreakitem.hxx>
@@ -53,6 +55,7 @@ class SwASCIIParser
SvStream& m_rInput;
std::unique_ptr<char[]> m_pArr;
const SwAsciiOptions& m_rOpt;
+ SwAsciiOptions m_usedAsciiOptions;
std::unique_ptr<SfxItemSet> m_pItemSet;
tools::Long m_nFileSize;
SvtScriptType m_nScript;
@@ -69,6 +72,7 @@ public:
bool bReadNewDoc, const SwAsciiOptions& rOpts );
ErrCode CallParser();
+ SwAsciiOptions GetUsedAsciiOptions() {return m_usedAsciiOptions;};
};
}
@@ -86,6 +90,12 @@ ErrCode AsciiReader::Read( SwDoc& rDoc, const OUString&, SwPaM &rPam, const OUSt
!m_bInsertMode, m_aOption.GetASCIIOpts() ));
ErrCode nRet = xParser->CallParser();
+ OUString optionsString;
+ xParser->GetUsedAsciiOptions().WriteUserData(optionsString);
+
+ if(m_pMedium != nullptr && m_pMedium->GetItemSet() != nullptr)
+ m_pMedium->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, optionsString));
+
xParser.reset();
// after Read reset the options
m_aOption.ResetASCIIOpts();
@@ -97,6 +107,7 @@ SwASCIIParser::SwASCIIParser(SwDoc& rD, const SwPaM& rCursor, SvStream& rIn, boo
: m_rDoc(rD)
, m_rInput(rIn)
, m_rOpt(rOpts)
+ , m_usedAsciiOptions(rOpts)
, m_nFileSize(0)
, m_nScript(SvtScriptType::NONE)
, m_bNewDoc(bReadNewDoc)
@@ -280,6 +291,7 @@ ErrCode SwASCIIParser::ReadChars()
m_rInput.SeekRel(-(tools::Long(nOrig)));
pUseMe=&aEmpty;
}
+ m_usedAsciiOptions = *pUseMe;
rtl_TextToUnicodeConverter hConverter=nullptr;
rtl_TextToUnicodeContext hContext=nullptr;
diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx
index 2d530e7531b5..f122e51f6d5c 100644
--- a/sw/source/filter/ascii/wrtasc.cxx
+++ b/sw/source/filter/ascii/wrtasc.cxx
@@ -27,6 +27,8 @@
#include <frmfmt.hxx>
#include "wrtasc.hxx"
#include <frameformats.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/sfxsids.hrc>
#include <strings.hrc>
@@ -202,6 +204,23 @@ ErrCode SwASCWriter::WriteStream()
return ERRCODE_NONE;
}
+void SwASCWriter::SetupFilterOptions(SfxMedium& rMedium)
+{
+ const SfxItemSet* pSet = rMedium.GetItemSet();
+ if( nullptr != pSet )
+ {
+ const SfxPoolItem* pItem;
+ if( SfxItemState::SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
+ {
+ SwAsciiOptions aOpt;
+ OUString sItemOpt;
+ sItemOpt = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ aOpt.ReadUserData(sItemOpt);
+ SetAsciiOptions(aOpt);
+ }
+ }
+}
+
void GetASCWriter(
const OUString& rFltNm, [[maybe_unused]] const OUString& /*rBaseURL*/, WriterRef& xRet )
{
diff --git a/sw/source/filter/ascii/wrtasc.hxx b/sw/source/filter/ascii/wrtasc.hxx
index 8be5e5352f61..b2a91c589599 100644
--- a/sw/source/filter/ascii/wrtasc.hxx
+++ b/sw/source/filter/ascii/wrtasc.hxx
@@ -36,6 +36,7 @@ public:
SwASCWriter(const OUString& rFilterName);
virtual ~SwASCWriter() override;
+ void SetupFilterOptions(SfxMedium& rMedium) override;
const OUString& GetLineEnd() const { return m_sLineEnd; }
};
diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index afd6f1892474..c46faff19fde 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -29,6 +29,7 @@
#include <unotools/viewoptions.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/printer.hxx>
+#include <sfx2/docfile.hxx>
#include <svl/languageoptions.hxx>
#include <editeng/langitem.hxx>
#include <swtypes.hxx>
@@ -77,6 +78,16 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( weld::Window* pParent, SwDocShell& rDocSh,
aUserItem >>= m_sExtraData;
}
+ const SfxPoolItem* pItem;
+ OUString sAsciiOptions;
+ if( rDocSh.GetMedium() != nullptr &&
+ rDocSh.GetMedium()->GetItemSet() != nullptr &&
+ SfxItemState::SET == rDocSh.GetMedium()->GetItemSet()->GetItemState(
+ SID_FILE_FILTEROPTIONS, true, &pItem ))
+ {
+ sAsciiOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ }
+
const OUString sFindNm = OUString::createFromAscii(
pStream ? sDialogImpExtraData
: sDialogExpExtraData);
@@ -87,11 +98,14 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( weld::Window* pParent, SwDocShell& rDocSh,
sal_Int32 nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, nStt );
if( -1 != nEnd )
{
- aOpt.ReadUserData(m_sExtraData.copy(nStt, nEnd - nStt));
+ if(sAsciiOptions.isEmpty())
+ sAsciiOptions = m_sExtraData.copy(nStt, nEnd - nStt);
nStt -= nDialogExtraDataLen;
m_sExtraData = m_sExtraData.replaceAt(nStt, nEnd - nStt + 1, "");
}
}
+ if(!sAsciiOptions.isEmpty())
+ aOpt.ReadUserData(sAsciiOptions);
}
// read the first chars and check the charset, (language - with L&H)