PageRenderTime 619ms CodeModel.GetById 142ms RepoModel.GetById 0ms app.codeStats 0ms

/src/PDFPluginShim.mm

http://firefox-mac-pdf.googlecode.com/
Objective C++ | 84 lines | 43 code | 13 blank | 28 comment | 1 complexity | aad102d15b4cd0b4aea23236e8f90ee5 MD5 | raw file
  1. /*
  2. * Copyright (c) 2008 Samuel Gross.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. #import "PDFPluginShim.h"
  23. #import "PluginInstance.h"
  24. #include "nsStringAPI.h"
  25. NS_IMPL_ISUPPORTS1(PDFPluginShim, PDFPlugin)
  26. PDFPluginShim::PDFPluginShim(PluginInstance* plugin) : _plugin(plugin)
  27. {
  28. /* member initializers and constructor code */
  29. }
  30. PDFPluginShim::~PDFPluginShim()
  31. {
  32. /* destructor code */
  33. }
  34. /* void Copy (); */
  35. NS_IMETHODIMP PDFPluginShim::Copy()
  36. {
  37. [_plugin copy];
  38. return NS_OK;
  39. }
  40. /* boolean Find (in ACString str, in boolean caseSensitive, in boolean forward); */
  41. NS_IMETHODIMP PDFPluginShim::Find(const nsAString & str, PRBool caseSensitive, PRBool forward, PRBool *_retval)
  42. {
  43. char* data = ToNewUTF8String(str);
  44. NSString* nsString = [NSString stringWithUTF8String:data];
  45. NS_Free(data);
  46. *_retval = [_plugin find:nsString caseSensitive:caseSensitive forwards:forward];
  47. return NS_OK;
  48. }
  49. /* boolean FindAll (in ACString str, in boolean caseSensitive); */
  50. NS_IMETHODIMP PDFPluginShim::FindAll(const nsAString & str, PRBool caseSensitive)
  51. {
  52. char* data = ToNewUTF8String(str);
  53. NSString* nsString = [NSString stringWithUTF8String:data];
  54. NS_Free(data);
  55. [_plugin findAll:nsString caseSensitive:caseSensitive];
  56. return NS_OK;
  57. }
  58. /* void RemoveHighlights (); */
  59. NS_IMETHODIMP PDFPluginShim::RemoveHighlights()
  60. {
  61. [_plugin removeHighlights];
  62. return NS_OK;
  63. }
  64. /* void Zoom (in long arg); */
  65. NS_IMETHODIMP PDFPluginShim::Zoom(PRInt32 arg)
  66. {
  67. if (![_plugin zoom:arg]) {
  68. return NS_ERROR_INVALID_ARG;
  69. }
  70. return NS_OK;
  71. }