⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fuqexport4odteditor.pas

📁 Advanced.Export.Component.v4.01.rar,delphi 第三方控件
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  end;
end;

procedure TfmQExport4ODTEditor.bMoveUpClick(Sender: TObject);
var
  TempStyle: TODTCellParagraphStyle;
begin
  TempStyle := TODTCellParagraphStyle.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 TfmQExport4ODTEditor.bMoveDownClick(Sender: TObject);
var
  TempStyle: TODTCellParagraphStyle;
begin
  TempStyle := TODTCellParagraphStyle.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 TfmQExport4ODTEditor.BlockUnBlock(Condition: Boolean);
begin
  laTextFont.Enabled := Condition;
  cbTextFont.Enabled := Condition;
  laTextSize.Enabled := Condition;
  cbTextFontSize.Enabled := Condition;
  btnTextFontColor.Enabled := Condition;
  pbTextFontColor.Enabled := Condition;
  btnTextBold.Enabled := Condition;
  btnTextItalic.Enabled := Condition;
  btnTextStrikeOut.Enabled := Condition;
  btnTextUnderLine.Enabled := Condition;
  btnTextLeft.Enabled := Condition;
  btnTextCenter.Enabled := Condition;
  btnTextRight.Enabled := Condition;
  btnTextJustify.Enabled := Condition;
  cbTextBackground.Enabled := Condition;
  sbTextBackgroundColor.Enabled := Condition;
  pbBackColor.Enabled := Condition;
  cbTextUseHighlight.Enabled := Condition;
  pbTextHighlight.Enabled := Condition;
  sbTextHighlightColor.Enabled := Condition;
  laCellFont.Enabled := Condition;
  cbCellFont.Enabled := Condition;
  laCellFontSize.Enabled := Condition;
  cbCellFontSize.Enabled := Condition;
  btnCellColor.Enabled := Condition;
  pbCellFontColor.Enabled := Condition;
  btnCellBold.Enabled := Condition;
  btnCellItalic.Enabled := Condition;
  btnCellStrikeOut.Enabled := Condition;
  btnCellUnderlineSingle.Enabled := Condition;
  btnCellLeft.Enabled := Condition;
  btnCellCenter.Enabled := Condition;
  btnCellRight.Enabled := Condition;
  btnCellJustify.Enabled := Condition;
  btnCellVerTop.Enabled := Condition;
  btnCellVerCenter.Enabled := Condition;
  btnCellVerBottom.Enabled := Condition;
  cbCellUseBackground.Enabled := Condition;
  sbCellBackground.Enabled := Condition;
  pbCellBackground.Enabled := Condition;
  cbCellUseHighlight.Enabled := Condition;
  sbCellHighlight.Enabled := Condition;
  pbCellHighlight.Enabled := Condition;
end;

procedure TfmQExport4ODTEditor.GetCurrentStyle;
begin
  FCurrCellStyle := nil;
  FCurrTextStyle := nil;
  FCurrState := -1;
  if pcStyleEditor.ActivePage = tsOptions then
  begin
    if (not Assigned(lvOptions.ItemFocused)) or
      (not Assigned(lvOptions.Items[lvOptions.ItemFocused.Index])) then
    begin
      SetCurrentStatus;
      Exit;
    end;
    if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
      {$IFDEF WIN32}QExportLoadStr(QED_ODT_Header){$ENDIF}
      {$IFDEF LINUX}QED_ODT_Header{$ENDIF} then
    begin
      FCurrTextStyle := HrStyle;
      FCurrState := 0;
    end;
    if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
      {$IFDEF WIN32}QExportLoadStr(QED_ODT_Footer){$ENDIF}
      {$IFDEF LINUX}QED_ODT_Footer{$ENDIF} then
    begin
      FCurrTextStyle := FrStyle;
      FCurrState := 0;
    end;
    if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
    {$IFDEF WIN32}QExportLoadStr(QED_ODT_CaptionRow){$ENDIF}
    {$IFDEF LINUX}QED_ODT_CaptionRow{$ENDIF} then
    begin
      FCurrCellStyle := CRStyle;
      FCurrState := 1;
    end;
    if lvOptions.Items[lvOptions.ItemFocused.Index].Caption =
      {$IFDEF WIN32}QExportLoadStr(QED_ODT_Data){$ENDIF}
      {$IFDEF LINUX}QED_ODT_Data{$ENDIF} then
    begin
      FCurrCellStyle := DStyle;
      FCurrState := 1;
    end;
  end;
  if pcStyleEditor.ActivePage = tsStyles then
  begin
    if (not Assigned(lvSStyles.ItemFocused)) or
      (not Assigned(lvSStyles.Items[lvSStyles.ItemFocused.Index])) then
    begin
      SetCurrentStatus;
      Exit;
    end;
    FCurrState := 1;
    if lvSStyles.ItemFocused.Index < SStylesList.Count then
      FCurrCellStyle := SStylesList[lvSStyles.ItemFocused.Index];
  end;
  SetCurrentStatus;
end;

procedure TfmQExport4ODTEditor.SetCurrentStatus;
begin
  if FCurrState >= 0 then
  begin
    if FCurrState = 0 then
      pcAllOptions.ActivePage := tsCommonTextStyle
    else
      pcAllOptions.ActivePage := tsCommonCellStyle;
    BlockUnBlock(true);
    TuneOptionsList;
  end
  else
  begin
    BlockUnBlock(false);
    pbSampleText.Repaint;
  end;
end;

procedure TfmQExport4ODTEditor.TuneOptionsList;
begin
  if not (csDestroying in ComponentState) then
  begin
    if FCurrState = 0 then
    begin
      if not assigned(FCurrTextStyle) then Exit;
      cbTextFont.ItemIndex := cbTextFont.Items.IndexOf(FCurrTextStyle.Font.Name);
      cbTextFontSize.Text := IntToStr(FCurrTextStyle.Font.Size);
      TuneBackgroundControls(FCurrTextStyle.AllowBackground);
      TuneHighlightControls(FCurrTextStyle.AllowHighlight);
      btnTextLeft.Down := FCurrTextStyle.Alignment = taODFLeft;
      btnTextRight.Down := FCurrTextStyle.Alignment = taODFRight;
      btnTextCenter.Down := FCurrTextStyle.Alignment = taODFCenter;
      btnTextJustify.Down := FCurrTextStyle.Alignment = taODFJustify;
      btnTextBold.Down := fsBold in FCurrTextStyle.Font.Style;
      btnTextItalic.Down := fsItalic in FCurrTextStyle.Font.Style;
      btnTextUnderLine.Down := fsUnderline in FCurrTextStyle.Font.Style;
      btnTextStrikeOut.Down := fsStrikeOut in FCurrTextStyle.Font.Style;
      pbTextFontColor.Repaint;
      pbSampleText.Repaint;
    end;
    if FCurrState = 1 then
    begin
      if not assigned(FCurrCellStyle) then Exit;
      cbCellFont.ItemIndex := cbCellFont.Items.IndexOf(FCurrCellStyle.Font.Name);
      cbCellFontSize.Text := IntToStr(FCurrCellStyle.Font.Size);
      TuneBackgroundControls(FCurrCellStyle.AllowBackground);
      TuneHighlightControls(FCurrCellStyle.AllowHighlight);
      btnCellLeft.Down := FCurrCellStyle.Alignment = taODFLeft;
      btnCellRight.Down := FCurrCellStyle.Alignment = taODFRight;
      btnCellCenter.Down := FCurrCellStyle.Alignment = taODFCenter;
      btnCellJustify.Down := FCurrCellStyle.Alignment = taODFJustify;
      btnCellVerTop.Down := FCurrCellStyle.VerticalAligment = taODFTop;
      btnCellVerCenter.Down := FCurrCellStyle.VerticalAligment = taODFMiddle;
      btnCellVerBottom.Down := FCurrCellStyle.VerticalAligment = taODFBottom;
      btnCellBold.Down := fsBold in FCurrCellStyle.Font.Style;
      btnCellItalic.Down := fsItalic in FCurrCellStyle.Font.Style;
      btnCellUnderlineSingle.Down := fsUnderline in FCurrCellStyle.Font.Style;
      btnCellStrikeOut.Down := fsStrikeOut in FCurrCellStyle.Font.Style;
      pbCellFontColor.Repaint;
      pbSampleText.Repaint;
    end;
  end;
end;

procedure TfmQExport4ODTEditor.lvOptionsChange(Sender: TObject;
  Item: TListItem; Change: TItemChange);
begin
  GetCurrentStyle;
end;

procedure TfmQExport4ODTEditor.pcStyleEditorChange(Sender: TObject);
begin
  GetCurrentStyle;
  TuneBorderControls;
end;

procedure TfmQExport4ODTEditor.TuneBackgroundControls(Condition: Boolean);
begin
  if FCurrState = 0 then
  begin
    cbTextBackground.Checked := Condition;
    sbTextBackgroundColor.Enabled := Condition;
    pbBackColor.Enabled := Condition;
    if Condition then
      pbBackColor.Repaint;
  end;
  if FCurrState = 1 then
  begin
    cbCellUseBackground.Checked := Condition;
    sbCellBackground.Enabled := Condition;
    pbCellBackground.Enabled := Condition;
    if Condition then
      pbCellBackground.Repaint;
  end;
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.TuneHighlightControls(Condition: Boolean);
begin
  if FCurrState = 0 then
  begin
    cbTextUseHighlight.Checked := Condition;
    sbTextHighlightColor.Enabled := Condition;
    pbTextHighlight.Enabled := Condition;
    if Condition then
      pbTextHighlight.Repaint;
  end;
  if FCurrState = 1 then
  begin
    cbCellUseHighlight.Checked := Condition;
    sbCellHighlight.Enabled := Condition;
    pbCellHighlight.Enabled := Condition;
    if Condition then
      pbCellHighlight.Repaint;
  end;
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.cbCellUseBackgroundClick(Sender: TObject);
begin
  if not Assigned(FCurrCellStyle) then Exit;
  FCurrCellStyle.AllowBackground := cbCellUseBackground.Checked;
  TuneBackgroundControls(cbCellUseBackground.Checked);
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.cbCellUseHighlightClick(Sender: TObject);
begin
  if not Assigned(FCurrCellStyle) then Exit;
  FCurrCellStyle.AllowHighlight:= cbCellUseHighlight.Checked;
  TuneHighlightControls(cbCellUseHighlight.Checked);
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.sbCellBackgroundClick(Sender: TObject);
begin
  if not Assigned(FCurrCellStyle) then Exit;
  if ColorDialog.Execute then
    if FCurrCellStyle.AllowBackground then
      if ColorDialog.Color <> -1 then
        FCurrCellStyle.BackgroundColor := ColorDialog.Color
      else
        FCurrCellStyle.BackgroundColor := clWhite;
  pbCellBackground.Repaint;
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.sbCellBackgroundMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  IncLeftAndTop(pbCellBackground);
end;

procedure TfmQExport4ODTEditor.sbCellBackgroundMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  DecLeftAndTop(pbCellBackground);
end;

procedure TfmQExport4ODTEditor.pbCellBackgroundPaint(Sender: TObject);
begin
  if not Assigned(FCurrCellStyle) then Exit;
  if not FCurrCellStyle.AllowBackground then Exit;
  PaintStandardColors(pbCellBackground, FCurrCellStyle.BackgroundColor);
end;

procedure TfmQExport4ODTEditor.sbCellHighlightClick(Sender: TObject);
begin
  if not Assigned(FCurrCellStyle) then Exit;
  if ColorDialog.Execute then
    if FCurrCellStyle.AllowHighlight then
      if ColorDialog.Color <> -1 then
        FCurrCellStyle.HighlightColor := ColorDialog.Color
      else
        FCurrCellStyle.HighlightColor := clWhite;
  pbCellHighlight.Repaint;
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.sbCellHighlightMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  IncLeftAndTop(pbCellHighlight);
end;

procedure TfmQExport4ODTEditor.sbCellHighlightMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  DecLeftAndTop(pbCellHighlight);
end;

procedure TfmQExport4ODTEditor.pbCellHighlightPaint(Sender: TObject);
begin
  if not Assigned(FCurrCellStyle) then Exit;
  if not FCurrCellStyle.AllowHighlight then Exit;
  PaintStandardColors(pbCellHighlight, FCurrCellStyle.HighlightColor);
end;

procedure TfmQExport4ODTEditor.cbTextBackgroundClick(Sender: TObject);
begin
  if not Assigned(FCurrTextStyle) then Exit;
  FCurrTextStyle.AllowBackground := cbTextBackground.Checked;
  TuneBackgroundControls(cbTextBackground.Checked);
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.sbTextBackgroundColorClick(Sender: TObject);
begin
  if not Assigned(FCurrTextStyle) then Exit;
  if ColorDialog.Execute then
    if FCurrTextStyle.AllowBackground then
      if ColorDialog.Color <> -1 then
        FCurrTextStyle.BackgroundColor := ColorDialog.Color
      else
        FCurrTextStyle.BackgroundColor := clWhite;
  pbBackColor.Repaint;
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.sbTextBackgroundColorMouseDown(
  Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
  IncLeftAndTop(pbBackColor);
end;

procedure TfmQExport4ODTEditor.sbTextBackgroundColorMouseUp(
  Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
  DecLeftAndTop(pbBackColor);
end;

procedure TfmQExport4ODTEditor.pbBackColorPaint(Sender: TObject);
begin
  if not Assigned(FCurrTextStyle) then Exit;
  if not FCurrTextStyle.AllowBackground then Exit;
  PaintStandardColors(pbBackColor, FCurrTextStyle.BackgroundColor);
end;

procedure TfmQExport4ODTEditor.cbTextUseHighlightClick(Sender: TObject);
begin
  if not Assigned(FCurrTextStyle) then Exit;
  FCurrTextStyle.AllowHighlight := cbTextUseHighlight.Checked;
  TuneHighlightControls(cbTextUseHighlight.Checked);
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.sbTextHighlightColorClick(Sender: TObject);
begin
  if not Assigned(FCurrTextStyle) then Exit;
  if ColorDialog.Execute then
    if FCurrTextStyle.AllowHighlight then
      if ColorDialog.Color <> -1 then
        FCurrTextStyle.HighlightColor := ColorDialog.Color
      else
        FCurrTextStyle.HighlightColor := clWhite;
  pbTextHighlight.Repaint;
  pbSampleText.Repaint;
end;

procedure TfmQExport4ODTEditor.sbTextHighlightColorMouseDown(
  Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
  IncLeftAndTop(pbTextHighlight);
end;

procedure TfmQExport4ODTEditor.sbTextHighlightColorMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -