Skip to content

Commit

Permalink
can insert tab character
Browse files Browse the repository at this point in the history
  • Loading branch information
totravel committed Mar 2, 2024
1 parent 132a79c commit 6bafbf7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ r.AppendText("a simple sentence.");
auto r = p.AppendPageBreak();
```

#### 制表符

你可以用 `AppendTabs()` 方法插入一个或多个制表符。

```cpp
auto r = doc.AppendParagraph().AppendRun();
r.AppendText(u8"甲方:");
r.AppendTabs(4);
r.AppendText(u8"乙方:");
```

### 分节

任何文档都至少包含一个分节且不可删除。
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ Page breaks are special run that can only be appended to a paragraph by calling
auto r = p.AppendPageBreak();
```

#### Tab character

You can append one or more tab character into a run with `AppendTabs()` method.

```cpp
auto r = doc.AppendParagraph().AppendRun();
r.AppendText("The Seller: ");
r.AppendTabs(4);
r.AppendText("The Buyer: ");
```

### Section

Each document contains at least one section and you can't remove it.
Expand Down
7 changes: 7 additions & 0 deletions src/minidocx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,13 @@ namespace docx
impl_->w_r_.append_child("w:br");
}

void Run::AppendTabs(const unsigned int count)
{
if (!impl_) return;
for (unsigned int i = 0; i < count; i++)
impl_->w_r_.append_child("w:tab");
}

void Run::SetFontSize(const double fontSize)
{
if (!impl_) return;
Expand Down
1 change: 1 addition & 0 deletions src/minidocx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ namespace docx
std::string GetText();
void ClearText();
void AppendLineBreak();
void AppendTabs(const unsigned int count = 1);

// text formatting
typedef unsigned int FontStyle;
Expand Down

1 comment on commit 6bafbf7

@totravel
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#17

Please sign in to comment.