📄 fuqexport4odseditor.pas
字号:
laBorderWidth.Enabled := Condition;
edBorderWidth.Enabled := Condition;
cbBackground.Enabled := Condition;
pbBackColor.Enabled := Condition;
sbBackgroundColor.Enabled := Condition;
end;
procedure TfmQExport4ODSEditor.cbODSFontChange(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
FCurrStyle.Font.Name := cbODSFont.Text;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.cbODSFontSizeChange(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
FCurrStyle.Font.Size := StrToIntDef(cbODSFontSize.Text, 10);
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.cbODSFontSizeEnter(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
cbODSFontSize.Text := IntToStr(FCurrStyle.Font.Size);
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.cbODSFontSizeExit(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
cbODSFontSize.Text := IntToStr(FCurrStyle.Font.Size);
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.bMoveUpClick(Sender: TObject);
var
TempStyle: TODSCellParagraphStyle;
begin
TempStyle := TODSCellParagraphStyle.Create(nil);
try
TempStyle.Assign(SStylesList.Items[lvSStyles.ItemFocused.Index]);
SStylesList.Items[lvSStyles.ItemFocused.Index].Assign(SStylesList.Items[lvSStyles.ItemFocused.Index - 1]);
SStylesList.Items[lvSStyles.ItemFocused.Index - 1].Assign(TempStyle);
finally
TempStyle.Free;
end;
lvSStyles.Items[lvSStyles.ItemFocused.Index - 1].Selected := true;
lvSStyles.Items[lvSStyles.ItemFocused.Index - 1].Focused := true;
end;
procedure TfmQExport4ODSEditor.bMoveDownClick(Sender: TObject);
var
TempStyle: TODSCellParagraphStyle;
begin
TempStyle := TODSCellParagraphStyle.Create(nil);
try
TempStyle.Assign(SStylesList.Items[lvSStyles.ItemFocused.Index]);
SStylesList.Items[lvSStyles.ItemFocused.Index].Assign(SStylesList.Items[lvSStyles.ItemFocused.Index + 1]);
SStylesList.Items[lvSStyles.ItemFocused.Index + 1].Assign(TempStyle);
finally
TempStyle.Free;
end;
lvSStyles.Items[lvSStyles.ItemFocused.Index + 1].Selected := true;
lvSStyles.Items[lvSStyles.ItemFocused.Index + 1].Focused := true;
end;
procedure TfmQExport4ODSEditor.pbBorderTopPaint(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if FCurrStyle.Border.BorderStyle = bsODFNone then Exit;
PaintStandardColors(pbBorderTop, FCurrStyle.Border.BorderColor);
end;
procedure TfmQExport4ODSEditor.TuneOptionsList;
begin
if not (csDestroying in ComponentState) then
begin
if not Assigned(FCurrStyle) then Exit;
cbODSFont.ItemIndex := cbODSFont.Items.IndexOf(FCurrStyle.Font.Name);
cbODSFontSize.Text := IntToStr(FCurrStyle.Font.Size);
TuneBorderControls(FCurrStyle.Border.BorderStyle = bsODFSolid);
TuneBackgroundControls(FCurrStyle.AllowBackground);
btnVerticalTop.Down := FCurrStyle.VerticalAligment = taODFTop;
btnVerticalCenter.Down := FCurrStyle.VerticalAligment = taODFMiddle;
btnVerticalBottom.Down := FCurrStyle.VerticalAligment = taODFBottom;
btnHorizontalLeft.Down := FCurrStyle.Alignment = taODFLeft;
btnHorizontalRight.Down := FCurrStyle.Alignment = taODFRight;
btnHorizontalCenter.Down := FCurrStyle.Alignment = taODFCenter;
btnHorizontalJustify.Down := FCurrStyle.Alignment = taODFJustify;
btnFontBold.Down := fsBold in FCurrStyle.Font.Style;
btnFontItalic.Down := fsItalic in FCurrStyle.Font.Style;
btnUnderlineSingle.Down := fsUnderline in FCurrStyle.Font.Style;
btnFontStrikeOut.Down := fsStrikeOut in FCurrStyle.Font.Style;
pbFontColor.Repaint;
pbSampleText.Repaint;
end;
end;
procedure TfmQExport4ODSEditor.btnBorderTopColorMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
IncLeftAndTop(pbBorderTop);
end;
procedure TfmQExport4ODSEditor.btnBorderTopColorMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
DecLeftAndTop(pbBorderTop);
end;
procedure TfmQExport4ODSEditor.btnBorderTopColorClick(Sender: TObject);
begin
if ColorDialog.Execute then
if ColorDialog.Color <> -1 then
FCurrStyle.Border.BorderColor := ColorDialog.Color
else
FCurrStyle.Border.BorderColor := clBlack;
pbBorderTop.Repaint;
end;
procedure TfmQExport4ODSEditor.cbUseBorderClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if cbUseBorder.Checked then
FCurrStyle.Border.BorderStyle := bsODFSolid
else
FCurrStyle.Border.BorderStyle := bsODFNone;
TuneBorderControls(cbUseBorder.Checked);
end;
procedure TfmQExport4ODSEditor.TuneBorderControls(Condition: Boolean);
begin
laBorderColor.Enabled := Condition;
pbBorderTop.Enabled := Condition;
btnBorderTopColor.Enabled := Condition;
laBorderWidth.Enabled := Condition;
edBorderWidth.Enabled := Condition;
cbUseBorder.Checked := Condition;
if Condition then
begin
pbBorderTop.Repaint;
edBorderWidth.Text := IntToStr(FCurrStyle.Border.BorderWidth);
end;
end;
procedure TfmQExport4ODSEditor.edBorderWidthChange(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if StrToIntDef(edBorderWidth.Text, 1) <> FCurrStyle.Border.BorderWidth then
FCurrStyle.Border.BorderWidth := StrToIntDef(edBorderWidth.Text, 1);
end;
procedure TfmQExport4ODSEditor.edBorderWidthEnter(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if StrToIntDef(edBorderWidth.Text, 1) <> FCurrStyle.Border.BorderWidth then
edBorderWidth.Text := IntToStr(FCurrStyle.Border.BorderWidth);
end;
procedure TfmQExport4ODSEditor.edBorderWidthExit(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if StrToIntDef(edBorderWidth.Text, 1) <> FCurrStyle.Border.BorderWidth then
edBorderWidth.Text := IntToStr(FCurrStyle.Border.BorderWidth);
end;
procedure TfmQExport4ODSEditor.btnHorizontalLeftClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnHorizontalLeft.Down then
FCurrStyle.Alignment := taODFLeft;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnHorizontalCenterClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnHorizontalCenter.Down then
FCurrStyle.Alignment := taODFCenter;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnHorizontalRightClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnHorizontalRight.Down then
FCurrStyle.Alignment := taODFRight;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnHorizontalJustifyClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnHorizontalJustify.Down then
FCurrStyle.Alignment := taODFJustify;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnVerticalTopClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnVerticalTop.Down then
FCurrStyle.VerticalAligment := taODFTop;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnVerticalCenterClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnVerticalCenter.Down then
FCurrStyle.VerticalAligment := taODFMiddle;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnVerticalBottomClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnVerticalBottom.Down then
FCurrStyle.VerticalAligment := taODFBottom;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnFontBoldClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnFontBold.Down then
FCurrStyle.Font.Style := FCurrStyle.Font.Style + [fsBold]
else
FCurrStyle.Font.Style := FCurrStyle.Font.Style - [fsBold];
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnFontItalicClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnFontItalic.Down then
FCurrStyle.Font.Style := FCurrStyle.Font.Style + [fsItalic]
else
FCurrStyle.Font.Style := FCurrStyle.Font.Style - [fsItalic];
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnFontStrikeOutClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnFontStrikeOut.Down then
FCurrStyle.Font.Style := FCurrStyle.Font.Style + [fsStrikeOut]
else
FCurrStyle.Font.Style := FCurrStyle.Font.Style - [fsStrikeOut];
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.btnUnderlineSingleClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if btnUnderlineSingle.Down then
FCurrStyle.Font.Style := FCurrStyle.Font.Style + [fsUnderline]
else
FCurrStyle.Font.Style := FCurrStyle.Font.Style - [fsUnderline];
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.pbBackColorPaint(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if not FCurrStyle.AllowBackground then Exit;
PaintStandardColors(pbBackColor, FCurrStyle.BackgroundColor);
end;
procedure TfmQExport4ODSEditor.sbBackgroundColorMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
IncLeftAndTop(pbBackColor);
end;
procedure TfmQExport4ODSEditor.sbBackgroundColorMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
DecLeftAndTop(pbBackColor);
end;
procedure TfmQExport4ODSEditor.sbBackgroundColorClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
if ColorDialog.Execute then
if FCurrStyle.AllowBackground then
if ColorDialog.Color <> -1 then
FCurrStyle.BackgroundColor := ColorDialog.Color
else
FCurrStyle.BackgroundColor := clWhite;
pbBackColor.Repaint;
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.TuneBackgroundControls(Condition: Boolean);
begin
cbBackground.Checked := Condition;
sbBackgroundColor.Enabled := Condition;
pbBackColor.Enabled := Condition;
if Condition then
pbBackColor.Repaint;
end;
procedure TfmQExport4ODSEditor.cbBackgroundClick(Sender: TObject);
begin
if not Assigned(FCurrStyle) then Exit;
FCurrStyle.AllowBackground := cbBackground.Checked;
TuneBackgroundControls(cbBackground.Checked);
pbSampleText.Repaint;
end;
procedure TfmQExport4ODSEditor.NumberKeyPress(Sender: TObject;
var Key: Char);
begin
if not (Key in ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', #8])
then Key := #0;
end;
procedure TfmQExport4ODSEditor.pbSampleTextPaint(Sender: TObject);
begin
if FCurrStyle = nil then Exit;
DrawODSSample(pbSampleText, FCurrStyle);
end;
procedure TfmQExport4ODSEditor.bResetItemClick(Sender: TObject);
begin
FCurrStyle := nil;
if pcStyleEditor.ActivePage = tsOptions then
begin
tsBorder.TabVisible := true;
if not assigned(lvOptions.Items[lvOptions.ItemFocused.Index]) then
Exit;
if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
{$IFDEF WIN32}QExportLoadStr(QED_ODS_Header){$ENDIF}
{$IFDEF LINUX}QED_ODS_Header{$ENDIF} then
begin
HrStyle.SetDefault;
FCurrStyle := HrStyle;
end;
if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
{$IFDEF WIN32}QExportLoadStr(QED_ODS_Footer){$ENDIF}
{$IFDEF LINUX}QED_ODS_Footer{$ENDIF} then
begin
FrStyle.SetDefault;
FCurrStyle := FrStyle;
end;
if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
{$IFDEF WIN32}QExportLoadStr(QED_ODS_CaptionRow){$ENDIF}
{$IFDEF LINUX}QED_ODS_CaptionRow{$ENDIF} then
begin
CRStyle.SetDefault;
FCurrStyle := CRStyle;
end;
if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
{$IFDEF WIN32}QExportLoadStr(QED_ODS_Data){$ENDIF}
{$IFDEF LINUX}QED_ODS_Data{$ENDIF} then
begin
DStyle.SetDefault;
FCurrStyle := DStyle;
end;
end;
if pcStyleEditor.ActivePage = tsStripStyles then
begin
tsBorder.TabVisible := false;
if not assigned(lvSStyles.Items[lvSStyles.ItemFocused.Index]) then
Exit;
SStylesList[lvSStyles.ItemFocused.Index].SetDefault;
FCurrStyle := SStylesList[lvSStyles.ItemFocused.Index];
end;
SetCurrentStatus;
end;
procedure TfmQExport4ODSEditor.bResetAllClick(Sender: TObject);
var
i: Integer;
begin
if pcStyleEditor.ActivePage = tsOptions then
begin
tsBorder.TabVisible := true;
HrStyle.SetDefault;
FrStyle.SetDefault;
CRStyle.SetDefault;
DStyle.SetDefault;
end;
if pcStyleEditor.ActivePage = tsStripStyles then
begin
tsBorder.TabVisible := false;
for i := 0 to SStylesList.Count - 1 do
SStylesList[i].SetDefault;
end;
GetCurrentStyle;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -