PageRenderTime 787ms CodeModel.GetById 643ms app.highlight 2ms RepoModel.GetById 139ms 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
25#include "nsStringAPI.h"
26
27NS_IMPL_ISUPPORTS1(PDFPluginShim, PDFPlugin)
28
29PDFPluginShim::PDFPluginShim(PluginInstance* plugin) : _plugin(plugin)
30{
31  /* member initializers and constructor code */
32}
33
34PDFPluginShim::~PDFPluginShim()
35{
36  /* destructor code */
37}
38
39/* void Copy (); */
40NS_IMETHODIMP PDFPluginShim::Copy()
41{
42  [_plugin copy];
43  return NS_OK;
44}
45
46/* boolean Find (in ACString str, in boolean caseSensitive, in boolean forward); */
47NS_IMETHODIMP PDFPluginShim::Find(const nsAString & str, PRBool caseSensitive, PRBool forward, PRBool *_retval)
48{
49  char* data = ToNewUTF8String(str);
50  NSString* nsString = [NSString stringWithUTF8String:data];
51  NS_Free(data);
52  
53  *_retval = [_plugin find:nsString caseSensitive:caseSensitive forwards:forward];
54
55  return NS_OK;
56}
57
58/* boolean FindAll (in ACString str, in boolean caseSensitive); */
59NS_IMETHODIMP PDFPluginShim::FindAll(const nsAString & str, PRBool caseSensitive)
60{
61  char* data = ToNewUTF8String(str);
62  NSString* nsString = [NSString stringWithUTF8String:data];
63  NS_Free(data);
64
65  [_plugin findAll:nsString caseSensitive:caseSensitive];
66  
67  return NS_OK;
68}
69
70/* void RemoveHighlights (); */
71NS_IMETHODIMP PDFPluginShim::RemoveHighlights()
72{
73  [_plugin removeHighlights];
74  return NS_OK;
75}
76
77/* void Zoom (in long arg); */
78NS_IMETHODIMP PDFPluginShim::Zoom(PRInt32 arg)
79{
80  if (![_plugin zoom:arg]) {
81    return NS_ERROR_INVALID_ARG;
82  }
83  return NS_OK;  
84}