Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1086)

Side by Side Diff: core/include/fpdfapi/fpdf_pageobj.h

Issue 1709393002: Remove PageObject's m_Type and add As<Type> functions (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_ 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_
8 #define CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_ 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_
9 9
10 #include <vector> 10 #include <vector>
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 class CPDF_PageObject : public CPDF_GraphicStates { 281 class CPDF_PageObject : public CPDF_GraphicStates {
282 public: 282 public:
283 enum Type { 283 enum Type {
284 TEXT = 1, 284 TEXT = 1,
285 PATH, 285 PATH,
286 IMAGE, 286 IMAGE,
287 SHADING, 287 SHADING,
288 FORM, 288 FORM,
289 }; 289 };
290 290
291 static CPDF_PageObject* Create(int type); 291 static CPDF_PageObject* Create(Type type);
292 virtual ~CPDF_PageObject(); 292 virtual ~CPDF_PageObject();
293 293
294 CPDF_PageObject* Clone() const; 294 CPDF_PageObject* Clone() const;
295 void Copy(const CPDF_PageObject* pSrcObject); 295 void Copy(const CPDF_PageObject* pSrcObject);
296 296
297 virtual Type GetType() const = 0;
297 virtual void Transform(const CFX_Matrix& matrix) = 0; 298 virtual void Transform(const CFX_Matrix& matrix) = 0;
299 virtual bool IsText() const { return false; }
300 virtual bool IsPath() const { return false; }
301 virtual bool IsImage() const { return false; }
302 virtual bool IsShading() const { return false; }
303 virtual bool IsForm() const { return false; }
304 virtual CPDF_TextObject* AsText() { return nullptr; }
305 virtual const CPDF_TextObject* AsText() const { return nullptr; }
306 virtual CPDF_PathObject* AsPath() { return nullptr; }
307 virtual const CPDF_PathObject* AsPath() const { return nullptr; }
308 virtual CPDF_ImageObject* AsImage() { return nullptr; }
309 virtual const CPDF_ImageObject* AsImage() const { return nullptr; }
310 virtual CPDF_ShadingObject* AsShading() { return nullptr; }
311 virtual const CPDF_ShadingObject* AsShading() const { return nullptr; }
312 virtual CPDF_FormObject* AsForm() { return nullptr; }
313 virtual const CPDF_FormObject* AsForm() const { return nullptr; }
298 314
299 void RemoveClipPath(); 315 void RemoveClipPath();
300 void AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerge); 316 void AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
301 void CopyClipPath(CPDF_PageObject* pObj); 317 void CopyClipPath(CPDF_PageObject* pObj);
302 void TransformClipPath(CFX_Matrix& matrix); 318 void TransformClipPath(CFX_Matrix& matrix);
303 void TransformGeneralState(CFX_Matrix& matrix); 319 void TransformGeneralState(CFX_Matrix& matrix);
304 void SetColorState(CPDF_ColorState state) { m_ColorState = state; } 320 void SetColorState(CPDF_ColorState state) { m_ColorState = state; }
305 FX_RECT GetBBox(const CFX_Matrix* pMatrix) const; 321 FX_RECT GetBBox(const CFX_Matrix* pMatrix) const;
306 322
307 const Type m_Type;
308 FX_FLOAT m_Left; 323 FX_FLOAT m_Left;
309 FX_FLOAT m_Right; 324 FX_FLOAT m_Right;
310 FX_FLOAT m_Top; 325 FX_FLOAT m_Top;
311 FX_FLOAT m_Bottom; 326 FX_FLOAT m_Bottom;
312 CPDF_ContentMark m_ContentMark; 327 CPDF_ContentMark m_ContentMark;
313 328
314 protected: 329 protected:
315 virtual void CopyData(const CPDF_PageObject* pSrcObject) = 0; 330 virtual void CopyData(const CPDF_PageObject* pSrcObject) = 0;
316 331
317 void RecalcBBox(); 332 void RecalcBBox();
318 CPDF_PageObject(Type type) : m_Type(type) {}
319 }; 333 };
320 334
321 struct CPDF_TextObjectItem { 335 struct CPDF_TextObjectItem {
322 FX_DWORD m_CharCode; 336 FX_DWORD m_CharCode;
323 FX_FLOAT m_OriginX; 337 FX_FLOAT m_OriginX;
324 FX_FLOAT m_OriginY; 338 FX_FLOAT m_OriginY;
325 }; 339 };
326 340
327 class CPDF_TextObject : public CPDF_PageObject { 341 class CPDF_TextObject : public CPDF_PageObject {
328 public: 342 public:
329 CPDF_TextObject(); 343 CPDF_TextObject();
330 ~CPDF_TextObject() override; 344 ~CPDF_TextObject() override;
331 345
346 // CPDF_PageObject:
347 Type GetType() const override { return TEXT; };
348 void Transform(const CFX_Matrix& matrix) override;
349 bool IsText() const override { return true; };
350 CPDF_TextObject* AsText() override { return this; };
351 const CPDF_TextObject* AsText() const override { return this; };
352
332 int CountItems() const { return m_nChars; } 353 int CountItems() const { return m_nChars; }
333 354
334 void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const; 355 void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;
335 356
336 int CountChars() const; 357 int CountChars() const;
337 358
338 void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const; 359 void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const;
339 void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const; 360 void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;
340 361
341 void GetCharRect(int index, CFX_FloatRect& rect) const; 362 void GetCharRect(int index, CFX_FloatRect& rect) const;
(...skipping 16 matching lines...) Expand all
358 void SetText(const CFX_ByteString& text); 379 void SetText(const CFX_ByteString& text);
359 380
360 void SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs); 381 void SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
361 382
362 void SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings); 383 void SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings);
363 384
364 void SetPosition(FX_FLOAT x, FX_FLOAT y); 385 void SetPosition(FX_FLOAT x, FX_FLOAT y);
365 386
366 void SetTextState(CPDF_TextState TextState); 387 void SetTextState(CPDF_TextState TextState);
367 388
368 // CPDF_PageObject:
369 void Transform(const CFX_Matrix& matrix) override;
370
371 void CalcCharPos(FX_FLOAT* pPosArray) const; 389 void CalcCharPos(FX_FLOAT* pPosArray) const;
372 390
373 void SetData(int nChars, 391 void SetData(int nChars,
374 FX_DWORD* pCharCodes, 392 FX_DWORD* pCharCodes,
375 FX_FLOAT* pCharPos, 393 FX_FLOAT* pCharPos,
376 FX_FLOAT x, 394 FX_FLOAT x,
377 FX_FLOAT y); 395 FX_FLOAT y);
378 396
379 void GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos) { 397 void GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos) {
380 nChars = m_nChars; 398 nChars = m_nChars;
(...skipping 23 matching lines...) Expand all
404 422
405 int m_nChars; 423 int m_nChars;
406 424
407 FX_DWORD* m_pCharCodes; 425 FX_DWORD* m_pCharCodes;
408 426
409 FX_FLOAT* m_pCharPos; 427 FX_FLOAT* m_pCharPos;
410 }; 428 };
411 429
412 class CPDF_PathObject : public CPDF_PageObject { 430 class CPDF_PathObject : public CPDF_PageObject {
413 public: 431 public:
414 CPDF_PathObject() : CPDF_PageObject(PATH) {} 432 CPDF_PathObject() {}
415 ~CPDF_PathObject() override {} 433 ~CPDF_PathObject() override {}
416 434
435 // CPDF_PageObject:
436 Type GetType() const override { return PATH; };
417 void Transform(const CFX_Matrix& maxtrix) override; 437 void Transform(const CFX_Matrix& maxtrix) override;
438 bool IsPath() const override { return true; };
439 CPDF_PathObject* AsPath() override { return this; };
440 const CPDF_PathObject* AsPath() const override { return this; };
418 441
419 void SetGraphState(CPDF_GraphState GraphState); 442 void SetGraphState(CPDF_GraphState GraphState);
420 443
421 void CalcBoundingBox(); 444 void CalcBoundingBox();
422 445
423 CPDF_Path m_Path; 446 CPDF_Path m_Path;
424 447
425 int m_FillType; 448 int m_FillType;
426 449
427 FX_BOOL m_bStroke; 450 FX_BOOL m_bStroke;
428 451
429 CFX_Matrix m_Matrix; 452 CFX_Matrix m_Matrix;
430 453
431 protected: 454 protected:
432 void CopyData(const CPDF_PageObject* pSrcObject) override; 455 void CopyData(const CPDF_PageObject* pSrcObject) override;
433 }; 456 };
434 457
435 class CPDF_ImageObject : public CPDF_PageObject { 458 class CPDF_ImageObject : public CPDF_PageObject {
436 public: 459 public:
437 CPDF_ImageObject(); 460 CPDF_ImageObject();
438 ~CPDF_ImageObject() override; 461 ~CPDF_ImageObject() override;
439 462
463 // CPDF_PageObject:
464 Type GetType() const override { return IMAGE; };
440 void Transform(const CFX_Matrix& matrix) override; 465 void Transform(const CFX_Matrix& matrix) override;
466 bool IsImage() const override { return true; };
467 CPDF_ImageObject* AsImage() override { return this; };
468 const CPDF_ImageObject* AsImage() const override { return this; };
441 469
442 CPDF_Image* m_pImage; 470 CPDF_Image* m_pImage;
443 471
444 CFX_Matrix m_Matrix; 472 CFX_Matrix m_Matrix;
445 473
446 void CalcBoundingBox(); 474 void CalcBoundingBox();
447 475
448 private: 476 private:
449 void CopyData(const CPDF_PageObject* pSrcObject) override; 477 void CopyData(const CPDF_PageObject* pSrcObject) override;
450 }; 478 };
451 479
452 class CPDF_ShadingObject : public CPDF_PageObject { 480 class CPDF_ShadingObject : public CPDF_PageObject {
453 public: 481 public:
454 CPDF_ShadingObject(); 482 CPDF_ShadingObject();
455 ~CPDF_ShadingObject() override; 483 ~CPDF_ShadingObject() override;
456 484
457 CPDF_ShadingPattern* m_pShading; 485 // CPDF_PageObject:
458 486 Type GetType() const override { return SHADING; };
459 CFX_Matrix m_Matrix;
460
461 void Transform(const CFX_Matrix& matrix) override; 487 void Transform(const CFX_Matrix& matrix) override;
488 bool IsShading() const override { return true; };
489 CPDF_ShadingObject* AsShading() override { return this; };
490 const CPDF_ShadingObject* AsShading() const override { return this; };
462 491
463 void CalcBoundingBox(); 492 void CalcBoundingBox();
464 493
494 CPDF_ShadingPattern* m_pShading;
495 CFX_Matrix m_Matrix;
496
465 protected: 497 protected:
466 void CopyData(const CPDF_PageObject* pSrcObject) override; 498 void CopyData(const CPDF_PageObject* pSrcObject) override;
467 }; 499 };
468 500
469 class CPDF_FormObject : public CPDF_PageObject { 501 class CPDF_FormObject : public CPDF_PageObject {
470 public: 502 public:
471 CPDF_FormObject() : CPDF_PageObject(FORM), m_pForm(nullptr) {} 503 CPDF_FormObject() : m_pForm(nullptr) {}
472 ~CPDF_FormObject() override; 504 ~CPDF_FormObject() override;
473 505
506 // CPDF_PageObject:
507 Type GetType() const override { return FORM; };
474 void Transform(const CFX_Matrix& matrix) override; 508 void Transform(const CFX_Matrix& matrix) override;
509 bool IsForm() const override { return true; };
510 CPDF_FormObject* AsForm() override { return this; };
511 const CPDF_FormObject* AsForm() const override { return this; };
512
475 void CalcBoundingBox(); 513 void CalcBoundingBox();
476 514
477 CPDF_Form* m_pForm; 515 CPDF_Form* m_pForm;
478 CFX_Matrix m_FormMatrix; 516 CFX_Matrix m_FormMatrix;
479 517
480 protected: 518 protected:
481 void CopyData(const CPDF_PageObject* pSrcObject) override; 519 void CopyData(const CPDF_PageObject* pSrcObject) override;
482 }; 520 };
483 521
484 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_ 522 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698