mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:22:45 +00:00 
			
		
		
		
	 5e1499d104
			
		
	
	
		5e1499d104
		
	
	
	
	
		
			
			This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).
This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
		
	
			
		
			
				
	
	
		
			67 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021-2022, Matthew Olsson <mattco@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/RefPtr.h>
 | |
| #include <LibPDF/Forward.h>
 | |
| 
 | |
| namespace PDF {
 | |
| 
 | |
| struct Rectangle {
 | |
|     float lower_left_x;
 | |
|     float lower_left_y;
 | |
|     float upper_right_x;
 | |
|     float upper_right_y;
 | |
| 
 | |
|     float width() const { return upper_right_x - lower_left_x; }
 | |
|     float height() const { return upper_right_y - lower_left_y; }
 | |
| };
 | |
| 
 | |
| struct Page {
 | |
|     NonnullRefPtr<DictObject> resources;
 | |
|     RefPtr<Object> contents;
 | |
|     Rectangle media_box;
 | |
|     Rectangle crop_box;
 | |
|     float user_unit;
 | |
|     int rotate;
 | |
| 
 | |
|     PDFErrorOr<ByteBuffer> page_contents(Document&) const;
 | |
| };
 | |
| 
 | |
| }
 | |
| 
 | |
| namespace AK {
 | |
| 
 | |
| template<>
 | |
| struct Formatter<PDF::Rectangle> : Formatter<FormatString> {
 | |
|     ErrorOr<void> format(FormatBuilder& builder, PDF::Rectangle const& rectangle)
 | |
|     {
 | |
|         return Formatter<FormatString>::format(builder,
 | |
|             "Rectangle {{ ll=({}, {}), ur=({}, {}) }}"sv,
 | |
|             rectangle.lower_left_x,
 | |
|             rectangle.lower_left_y,
 | |
|             rectangle.upper_right_x,
 | |
|             rectangle.upper_right_y);
 | |
|     }
 | |
| };
 | |
| 
 | |
| template<>
 | |
| struct Formatter<PDF::Page> : Formatter<FormatString> {
 | |
|     ErrorOr<void> format(FormatBuilder& builder, PDF::Page const& page)
 | |
|     {
 | |
|         return Formatter<FormatString>::format(builder,
 | |
|             "Page {{\n  resources={}\n  contents={}\n  media_box={}\n  crop_box={}\n  user_unit={}\n  rotate={}\n}}"sv,
 | |
|             page.resources->to_byte_string(1),
 | |
|             page.contents->to_byte_string(1),
 | |
|             page.media_box,
 | |
|             page.crop_box,
 | |
|             page.user_unit,
 | |
|             page.rotate);
 | |
|     }
 | |
| };
 | |
| 
 | |
| }
 |