index abe28200530d5cf003f0e6fb1eca2974aa41f9fe..0682e3570d4fb3ae2f696eebe291419a7cd05ec8 100644 (file)
unsigned span_index;
if (chunk_index) {
span_index = _lineToSpan(_chunks[chunk_index].in_line);
- for ( ; span_index < _spans.size() && _spans[span_index].in_chunk < chunk_index ; span_index++);
+ for ( ; span_index < _spans.size() && _spans[span_index].in_chunk < chunk_index ; span_index++){};
} else
span_index = 0;
for ( ; span_index < _spans.size() && _spans[span_index].in_chunk == chunk_index ; span_index++)
return sourceToIterator(source_cookie, Glib::ustring::const_iterator(std::string::const_iterator(NULL)));
}
-boost::optional<Geom::Rect> Layout::glyphBoundingBox(iterator const &it, double *rotation) const
+Geom::OptRect Layout::glyphBoundingBox(iterator const &it, double *rotation) const
{
if (rotation) *rotation = _glyphs[it._glyph_index].rotation;
return _glyphs[it._glyph_index].span(this).font->BBox(_glyphs[it._glyph_index].glyph);
}
}
+boost::optional<Geom::Point> Layout::baselineAnchorPoint() const
+{
+ iterator pos = this->begin();
+ Geom::Point left_pt = this->characterAnchorPoint(pos);
+ pos.thisEndOfLine();
+ Geom::Point right_pt = this->characterAnchorPoint(pos);
+
+ if (this->_blockProgression() == LEFT_TO_RIGHT || this->_blockProgression() == RIGHT_TO_LEFT) {
+ left_pt = Geom::Point(left_pt[Geom::Y], left_pt[Geom::X]);
+ right_pt = Geom::Point(right_pt[Geom::Y], right_pt[Geom::X]);
+ }
+
+ switch (this->paragraphAlignment(pos)) {
+ case LEFT:
+ case FULL:
+ return left_pt;
+ break;
+ case CENTER:
+ return (left_pt + right_pt)/2; // middle point
+ break;
+ case RIGHT:
+ return right_pt;
+ break;
+ default:
+ return boost::optional<Geom::Point>();
+ break;
+ }
+}
+
Geom::Point Layout::chunkAnchorPoint(iterator const &it) const
{
unsigned chunk_index;
@@ -260,8 +289,8 @@ Geom::Rect Layout::characterBoundingBox(iterator const &it, double *rotation) co
int unused = 0;
Path::cut_position *midpoint_otp = const_cast<Path*>(_path_fitted)->CurvilignToPosition(1, &midpoint_offset, unused);
if (midpoint_offset >= 0.0 && midpoint_otp != NULL && midpoint_otp[0].piece >= 0) {
- NR::Point midpoint;
- NR::Point tangent;
+ Geom::Point midpoint;
+ Geom::Point tangent;
Span const &span = _characters[char_index].span(this);
const_cast<Path*>(_path_fitted)->PointAndTangentAt(midpoint_otp[0].piece, midpoint_otp[0].t, midpoint, tangent);
}
g_free(path_parameter_list);
- NR::Point point;
- NR::Point tangent;
+ Geom::Point point;
+ Geom::Point tangent;
const_cast<Path*>(_path_fitted)->PointAndTangentAt(path_parameter.piece, path_parameter.t, point, tangent);
if (x < 0.0)
point += x * tangent;
@@ -518,7 +547,7 @@ void Layout::simulateLayoutUsingKerning(iterator const &from, iterator const &to
unsigned prev_cluster_char_index;
for (prev_cluster_char_index = char_index - 1 ;
prev_cluster_char_index != 0 && !_characters[prev_cluster_char_index].char_attributes.is_cursor_position ;
- prev_cluster_char_index--);
+ prev_cluster_char_index--){};
if (_characters[char_index].span(this).in_chunk == _characters[char_index - 1].span(this).in_chunk) {
// dx is zero for the first char in a chunk
// this algorithm works by comparing the summed widths of the glyphs with the observed
unsigned line_index = _parent_layout->_characters[_char_index].chunk(_parent_layout).in_line;
if (line_index == _parent_layout->_lines.size() - 1)
return false; // nowhere to go
- else
+ else
n = MIN (n, static_cast<int>(_parent_layout->_lines.size() - 1 - line_index));
if (_parent_layout->_lines[line_index + n].in_shape != _parent_layout->_lines[line_index].in_shape) {
// switching between shapes: adjust the stored x to compensate
line_index = _parent_layout->_characters[_char_index].chunk(_parent_layout).in_line;
if (line_index == 0)
return false; // nowhere to go
- else
+ else
n = MIN (n, static_cast<int>(line_index));
if (_parent_layout->_lines[line_index - n].in_shape != _parent_layout->_lines[line_index].in_shape) {
// switching between shapes: adjust the stored x to compensate
{
bool r;
while ((r = _cursorLeftOrRightLocalX(direction))
- && !_parent_layout->_characters[_char_index].char_attributes.is_word_start);
+ && !_parent_layout->_characters[_char_index].char_attributes.is_word_start){};
return r;
}