Commit 8e0b15333228ab973571eec498af41d3cbb8ab63

Authored by Jay Berkenbilt
1 parent 72c10d86

Expose QPDFObjectHandle::addTokenFilter (fixes #580)

ChangeLog
1 1 2021-12-10 Jay Berkenbilt <ejb@ql.org>
2 2  
  3 + * Add missing QPDF_DLL to QPDFObjectHandle::addTokenFilter so that
  4 + it is actually accessible as part of the public interface as
  5 + intended. Fixes #580.
  6 +
3 7 * C API: Overhaul how errors are handle the C API's object handle
4 8 interfaces. Clarify documentation regarding object accessors and
5 9 how type errors and warnings are handled. Many cases that used to
... ...
include/qpdf/QPDFObjectHandle.hh
... ... @@ -456,6 +456,7 @@ class QPDFObjectHandle
456 456 // be applied to a page object, and which will automatically
457 457 // handle the case of pages whose contents are split across
458 458 // multiple streams.
  459 + QPDF_DLL
459 460 void addTokenFilter(PointerHolder<TokenFilter> token_filter);
460 461  
461 462 // Legacy helpers for parsing content streams. These methods are
... ...
qpdf/test_driver.cc
... ... @@ -2704,14 +2704,27 @@ void runtest(int n, char const* filename1, char const* arg2)
2704 2704 std::cout << "--- parseContents ---" << std::endl;
2705 2705 ParserCallbacks cb;
2706 2706 fx1.parseContents(&cb);
2707   - Pl_Buffer b("buffer");
2708   - fx1.addContentTokenFilter(new TokenFilter);
2709   - fx1.pipeContents(&b);
2710   - std::unique_ptr<Buffer> buf(b.getBuffer());
2711   - std::string s(
2712   - reinterpret_cast<char const*>(buf->getBuffer()),
2713   - buf->getSize());
2714   - assert(s.find("/bye") != std::string::npos);
  2707 + // Do this once with addContentTokenFilter and once with
  2708 + // addTokenFilter to show that they are the same and to ensure
  2709 + // that addTokenFilter is directly exercised in testing.
  2710 + for (int i = 0; i < 2; i++)
  2711 + {
  2712 + Pl_Buffer b("buffer");
  2713 + if (i == 0)
  2714 + {
  2715 + fx1.addContentTokenFilter(new TokenFilter);
  2716 + }
  2717 + else
  2718 + {
  2719 + fx1.getObjectHandle().addTokenFilter(new TokenFilter);
  2720 + }
  2721 + fx1.pipeContents(&b);
  2722 + std::unique_ptr<Buffer> buf(b.getBuffer());
  2723 + std::string s(
  2724 + reinterpret_cast<char const*>(buf->getBuffer()),
  2725 + buf->getSize());
  2726 + assert(s.find("/bye") != std::string::npos);
  2727 + }
2715 2728 }
2716 2729 else if (n == 73)
2717 2730 {
... ...