Kaydet (Commit) c041db6f authored tarafından Florent Gallaire's avatar Florent Gallaire Kaydeden (comit) Eike Rathke

fdo#45664 EasyHack: Add a "Save cell formulas" checkbox to the CSV Export panel.

üst d88493ad
...@@ -315,6 +315,7 @@ void ScAsciiOptions::ReadFromString( const String& rString ) ...@@ -315,6 +315,7 @@ void ScAsciiOptions::ReadFromString( const String& rString )
bDetectSpecialNumber = sal_True; // default of versions that didn't add the parameter bDetectSpecialNumber = sal_True; // default of versions that didn't add the parameter
// 9th token is used for "Save as shown" in export options // 9th token is used for "Save as shown" in export options
// 10th token is used for "Save cell formulas" in export options
} }
...@@ -403,6 +404,7 @@ String ScAsciiOptions::WriteToString() const ...@@ -403,6 +404,7 @@ String ScAsciiOptions::WriteToString() const
aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false"); aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false");
// 9th token is used for "Save as shown" in export options // 9th token is used for "Save as shown" in export options
// 10th token is used for "Save cell formulas" in export options
return aOutStr; return aOutStr;
} }
......
...@@ -54,6 +54,7 @@ ScImportOptions::ScImportOptions( const String& rStr ) ...@@ -54,6 +54,7 @@ ScImportOptions::ScImportOptions( const String& rStr )
eCharSet = RTL_TEXTENCODING_DONTKNOW; eCharSet = RTL_TEXTENCODING_DONTKNOW;
bSaveAsShown = sal_True; // "true" if not in string (after CSV import) bSaveAsShown = sal_True; // "true" if not in string (after CSV import)
bQuoteAllText = false; bQuoteAllText = false;
bSaveFormulas = false;
xub_StrLen nTokenCount = comphelper::string::getTokenCount(rStr, ','); xub_StrLen nTokenCount = comphelper::string::getTokenCount(rStr, ',');
if ( nTokenCount >= 3 ) if ( nTokenCount >= 3 )
{ {
...@@ -80,6 +81,8 @@ ScImportOptions::ScImportOptions( const String& rStr ) ...@@ -80,6 +81,8 @@ ScImportOptions::ScImportOptions( const String& rStr )
bQuoteAllText = rStr.GetToken(6, ',').EqualsAscii("true"); bQuoteAllText = rStr.GetToken(6, ',').EqualsAscii("true");
if ( nTokenCount >= 9 ) if ( nTokenCount >= 9 )
bSaveAsShown = rStr.GetToken(8, ',').EqualsAscii("true"); bSaveAsShown = rStr.GetToken(8, ',').EqualsAscii("true");
if ( nTokenCount >= 10 )
bSaveFormulas = rStr.GetToken(9, ',').EqualsAscii("true");
} }
} }
} }
...@@ -103,6 +106,8 @@ String ScImportOptions::BuildString() const ...@@ -103,6 +106,8 @@ String ScImportOptions::BuildString() const
aResult.AppendAscii(bQuoteAllText ? "true" : "false"); // same as "quoted field as text" in ScAsciiOptions aResult.AppendAscii(bQuoteAllText ? "true" : "false"); // same as "quoted field as text" in ScAsciiOptions
aResult.AppendAscii( ",true," ); // "detect special numbers" aResult.AppendAscii( ",true," ); // "detect special numbers"
aResult.AppendAscii(bSaveAsShown ? "true" : "false"); // "save as shown": not in ScAsciiOptions aResult.AppendAscii(bSaveAsShown ? "true" : "false"); // "save as shown": not in ScAsciiOptions
aResult.AppendAscii( "," );
aResult.AppendAscii(bSaveFormulas ? "true" : "false"); // "save formulas": not in ScAsciiOptions
return aResult; return aResult;
} }
......
...@@ -40,4 +40,5 @@ ...@@ -40,4 +40,5 @@
#define CB_FIXEDWIDTH 12 #define CB_FIXEDWIDTH 12
#define CB_SAVESHOWN 13 #define CB_SAVESHOWN 13
#define CB_QUOTEALL 14 #define CB_QUOTEALL 14
#define CB_FORMULAS 15
...@@ -116,6 +116,13 @@ ModalDialog RID_SCDLG_IMPORTOPT ...@@ -116,6 +116,13 @@ ModalDialog RID_SCDLG_IMPORTOPT
Hide = TRUE; Hide = TRUE;
Text [ en-US ] = "~Quote all text cells"; Text [ en-US ] = "~Quote all text cells";
}; };
CheckBox CB_FORMULAS
{
Pos = MAP_APPFONT( 12, 105 );
Size = MAP_APPFONT( 172, 10 );
Hide = TRUE;
Text [ en-US ] = "Save cell fo~rmulas";
};
OKButton BTN_OK OKButton BTN_OK
{ {
Pos = MAP_APPFONT ( 202 , 6 ) ; Pos = MAP_APPFONT ( 202 , 6 ) ;
......
...@@ -136,6 +136,7 @@ ScImportOptionsDlg::ScImportOptionsDlg( ...@@ -136,6 +136,7 @@ ScImportOptionsDlg::ScImportOptionsDlg(
aCbQuoteAll ( this, ScResId( CB_QUOTEALL ) ), aCbQuoteAll ( this, ScResId( CB_QUOTEALL ) ),
aCbShown ( this, ScResId( CB_SAVESHOWN ) ), aCbShown ( this, ScResId( CB_SAVESHOWN ) ),
aCbFixed ( this, ScResId( CB_FIXEDWIDTH ) ), aCbFixed ( this, ScResId( CB_FIXEDWIDTH ) ),
aCbFormulas ( this, ScResId( CB_FORMULAS ) ),
aBtnOk ( this, ScResId( BTN_OK ) ), aBtnOk ( this, ScResId( BTN_OK ) ),
aBtnCancel ( this, ScResId( BTN_CANCEL ) ), aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
aBtnHelp ( this, ScResId( BTN_HELP ) ) aBtnHelp ( this, ScResId( BTN_HELP ) )
...@@ -207,7 +208,7 @@ ScImportOptionsDlg::ScImportOptionsDlg( ...@@ -207,7 +208,7 @@ ScImportOptionsDlg::ScImportOptionsDlg(
if( bAscii ) if( bAscii )
{ {
Size aWinSize( GetSizePixel() ); Size aWinSize( GetSizePixel() );
aWinSize.Height() = aCbFixed.GetPosPixel().Y() + aCbFixed.GetSizePixel().Height(); aWinSize.Height() = aCbFormulas.GetPosPixel().Y() + aCbFormulas.GetSizePixel().Height();
Size aDiffSize( LogicToPixel( Size( 0, 6 ), MapMode( MAP_APPFONT ) ) ); Size aDiffSize( LogicToPixel( Size( 0, 6 ), MapMode( MAP_APPFONT ) ) );
aWinSize.Height() += aDiffSize.Height(); aWinSize.Height() += aDiffSize.Height();
SetSizePixel( aWinSize ); SetSizePixel( aWinSize );
...@@ -218,6 +219,9 @@ ScImportOptionsDlg::ScImportOptionsDlg( ...@@ -218,6 +219,9 @@ ScImportOptionsDlg::ScImportOptionsDlg(
aCbShown.Check( sal_True ); aCbShown.Check( sal_True );
aCbQuoteAll.Show(); aCbQuoteAll.Show();
aCbQuoteAll.Check( false ); aCbQuoteAll.Check( false );
aCbFormulas.Show();
aCbFormulas.SetClickHdl( LINK( this, ScImportOptionsDlg, SaveFormulasHdl ) );
aCbFormulas.Check( false );
} }
else else
{ {
...@@ -230,6 +234,7 @@ ScImportOptionsDlg::ScImportOptionsDlg( ...@@ -230,6 +234,7 @@ ScImportOptionsDlg::ScImportOptionsDlg(
aCbFixed.Hide(); aCbFixed.Hide();
aCbShown.Hide(); aCbShown.Hide();
aCbQuoteAll.Hide(); aCbQuoteAll.Hide();
aCbFormulas.Hide();
aLbFont.GrabFocus(); aLbFont.GrabFocus();
aLbFont.SetDoubleClickHdl( LINK( this, ScImportOptionsDlg, DoubleClickHdl ) ); aLbFont.SetDoubleClickHdl( LINK( this, ScImportOptionsDlg, DoubleClickHdl ) );
} }
...@@ -265,6 +270,7 @@ void ScImportOptionsDlg::GetImportOptions( ScImportOptions& rOptions ) const ...@@ -265,6 +270,7 @@ void ScImportOptionsDlg::GetImportOptions( ScImportOptions& rOptions ) const
rOptions.bFixedWidth = aCbFixed.IsChecked(); rOptions.bFixedWidth = aCbFixed.IsChecked();
rOptions.bSaveAsShown = aCbShown.IsChecked(); rOptions.bSaveAsShown = aCbShown.IsChecked();
rOptions.bQuoteAllText = aCbQuoteAll.IsChecked(); rOptions.bQuoteAllText = aCbQuoteAll.IsChecked();
rOptions.bSaveFormulas = aCbFormulas.IsChecked();
} }
} }
...@@ -313,6 +319,16 @@ IMPL_LINK( ScImportOptionsDlg, FixedWidthHdl, CheckBox*, pCheckBox ) ...@@ -313,6 +319,16 @@ IMPL_LINK( ScImportOptionsDlg, FixedWidthHdl, CheckBox*, pCheckBox )
return 0; return 0;
} }
IMPL_LINK( ScImportOptionsDlg, SaveFormulasHdl, CheckBox*, pCheckBox )
{
if( pCheckBox == &aCbFormulas )
{
sal_Bool bEnable = !aCbFormulas.IsChecked();
aCbShown.Enable( bEnable );
}
return 0;
}
IMPL_LINK( ScImportOptionsDlg, DoubleClickHdl, ListBox*, pLb ) IMPL_LINK( ScImportOptionsDlg, DoubleClickHdl, ListBox*, pLb )
{ {
if ( pLb == &aLbFont ) if ( pLb == &aLbFont )
......
...@@ -1706,6 +1706,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1706,6 +1706,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
CharSet eCharSet = rAsciiOpt.eCharSet; CharSet eCharSet = rAsciiOpt.eCharSet;
bool bFixedWidth = rAsciiOpt.bFixedWidth; bool bFixedWidth = rAsciiOpt.bFixedWidth;
bool bSaveAsShown = rAsciiOpt.bSaveAsShown; bool bSaveAsShown = rAsciiOpt.bSaveAsShown;
bool bShowFormulas = rAsciiOpt.bSaveFormulas;
CharSet eOldCharSet = rStream.GetStreamCharSet(); CharSet eOldCharSet = rStream.GetStreamCharSet();
rStream.SetStreamCharSet( eCharSet ); rStream.SetStreamCharSet( eCharSet );
...@@ -1752,11 +1753,6 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1752,11 +1753,6 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
rtl::OUString aString; rtl::OUString aString;
ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
const ScViewOptions& rOpt = (pViewSh)
? pViewSh->GetViewData()->GetOptions()
: aDocument.GetViewOptions();
bool bShowFormulas = rOpt.GetOption( VOPT_FORMULAS );
bool bTabProtect = aDocument.IsTabProtected( nTab ); bool bTabProtect = aDocument.IsTabProtected( nTab );
SCCOL nCol; SCCOL nCol;
......
...@@ -46,18 +46,18 @@ public: ...@@ -46,18 +46,18 @@ public:
ScImportOptions() ScImportOptions()
: nFieldSepCode(0), nTextSepCode(0), : nFieldSepCode(0), nTextSepCode(0),
eCharSet(RTL_TEXTENCODING_DONTKNOW), bFixedWidth(false), eCharSet(RTL_TEXTENCODING_DONTKNOW), bFixedWidth(false),
bSaveAsShown(false), bQuoteAllText(false) bSaveAsShown(false), bQuoteAllText(false), bSaveFormulas(false)
{} {}
ScImportOptions( const String& rStr ); ScImportOptions( const String& rStr );
ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, const String& rStr ) ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, const String& rStr )
: nFieldSepCode(nFieldSep), nTextSepCode(nTextSep), aStrFont(rStr), : nFieldSepCode(nFieldSep), nTextSepCode(nTextSep), aStrFont(rStr),
bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false) bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false), bSaveFormulas(false)
{ eCharSet = ScGlobal::GetCharsetValue(aStrFont); } { eCharSet = ScGlobal::GetCharsetValue(aStrFont); }
ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, rtl_TextEncoding nEnc ) ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, rtl_TextEncoding nEnc )
: nFieldSepCode(nFieldSep), nTextSepCode(nTextSep), : nFieldSepCode(nFieldSep), nTextSepCode(nTextSep),
bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false) bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false), bSaveFormulas(false)
{ SetTextEncoding( nEnc ); } { SetTextEncoding( nEnc ); }
ScImportOptions( const ScImportOptions& rCpy ) ScImportOptions( const ScImportOptions& rCpy )
...@@ -67,7 +67,8 @@ public: ...@@ -67,7 +67,8 @@ public:
eCharSet (rCpy.eCharSet), eCharSet (rCpy.eCharSet),
bFixedWidth (rCpy.bFixedWidth), bFixedWidth (rCpy.bFixedWidth),
bSaveAsShown (rCpy.bSaveAsShown), bSaveAsShown (rCpy.bSaveAsShown),
bQuoteAllText (rCpy.bQuoteAllText) bQuoteAllText (rCpy.bQuoteAllText),
bSaveFormulas (rCpy.bSaveFormulas)
{} {}
ScImportOptions& operator=( const ScImportOptions& rCpy ) ScImportOptions& operator=( const ScImportOptions& rCpy )
...@@ -79,6 +80,7 @@ public: ...@@ -79,6 +80,7 @@ public:
bFixedWidth = rCpy.bFixedWidth; bFixedWidth = rCpy.bFixedWidth;
bSaveAsShown = rCpy.bSaveAsShown; bSaveAsShown = rCpy.bSaveAsShown;
bQuoteAllText = rCpy.bQuoteAllText; bQuoteAllText = rCpy.bQuoteAllText;
bSaveFormulas = rCpy.bSaveFormulas;
return *this; return *this;
} }
...@@ -91,7 +93,8 @@ public: ...@@ -91,7 +93,8 @@ public:
&& aStrFont == rCmp.aStrFont && aStrFont == rCmp.aStrFont
&& bFixedWidth == rCmp.bFixedWidth && bFixedWidth == rCmp.bFixedWidth
&& bSaveAsShown == rCmp.bSaveAsShown && bSaveAsShown == rCmp.bSaveAsShown
&& bQuoteAllText == rCmp.bQuoteAllText; && bQuoteAllText == rCmp.bQuoteAllText
&& bSaveFormulas == rCmp.bSaveFormulas;
} }
String BuildString() const; String BuildString() const;
...@@ -104,6 +107,7 @@ public: ...@@ -104,6 +107,7 @@ public:
sal_Bool bFixedWidth; sal_Bool bFixedWidth;
sal_Bool bSaveAsShown; sal_Bool bSaveAsShown;
sal_Bool bQuoteAllText; sal_Bool bQuoteAllText;
sal_Bool bSaveFormulas;
}; };
......
...@@ -62,6 +62,7 @@ private: ...@@ -62,6 +62,7 @@ private:
CheckBox aCbQuoteAll; CheckBox aCbQuoteAll;
CheckBox aCbShown; CheckBox aCbShown;
CheckBox aCbFixed; CheckBox aCbFixed;
CheckBox aCbFormulas;
OKButton aBtnOk; OKButton aBtnOk;
CancelButton aBtnCancel; CancelButton aBtnCancel;
HelpButton aBtnHelp; HelpButton aBtnHelp;
...@@ -73,6 +74,7 @@ private: ...@@ -73,6 +74,7 @@ private:
sal_uInt16 GetCodeFromCombo( const ComboBox& rEd ) const; sal_uInt16 GetCodeFromCombo( const ComboBox& rEd ) const;
DECL_LINK( FixedWidthHdl, CheckBox* ); DECL_LINK( FixedWidthHdl, CheckBox* );
DECL_LINK( SaveFormulasHdl, CheckBox* );
DECL_LINK( DoubleClickHdl, ListBox* ); DECL_LINK( DoubleClickHdl, ListBox* );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment